Skip to content

Commit f17f46a

Browse files
authored
Merge pull request #3482 from olehermanse/master
Integrated prettier and black with CFEngine CLI
2 parents 911c66d + 8469f9c commit f17f46a

File tree

5 files changed

+45
-74
lines changed

5 files changed

+45
-74
lines changed

.github/workflows/formatting.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,9 @@ jobs:
2525
pipx install cfengine black
2626
- name: Run formatting command to (hopefully not) make changes
2727
run: |
28-
# TODO: We can integrate these commands into cfengine dev docs-format
29-
# https://northerntech.atlassian.net/browse/CFE-4572
3028
# TODO: There are (small) diffs between cfbs pretty and prettier
3129
# https://northerntech.atlassian.net/browse/CFE-4571
32-
find . -name '*.markdown' -type f | parallel -j16 prettier -w {}
33-
black .
3430
cfengine dev docs-format
35-
- name: Check output.log file for warnings
36-
run: |
37-
! grep WARNING output.log
3831
- name: Check if there are changes
3932
run: |
4033
git diff --exit-code

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Build artifacts
22
cfdoc_log.markdown
33

4-
# Log file from running markdowner.py:
5-
output.log
6-
74
# emacs
85

96
*~

DOCTOOLS.README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Git workflow.
3535
1. Using Windows Explorer, open a directory where you wish to store CFEngine related Git repositories (e.g. D:\Projects\CFEngine).
3636
2. Right click to bring up the contextual menu.
3737
3. Select `Git Bash`
38-
![Contextual Menu With Git Bash](Doctools-ReadMe-Git-Bash.png)
38+
![Contextual Menu With Git Bash](Doctools-ReadMe-Git-Bash.png)
3939
4. A `Command Prompt` style window will open. This is where you will enter Git commands.
4040

4141
### Using Git
@@ -44,12 +44,12 @@ Git is a very powerful and robust command line tool at its heart. While it has a
4444

4545
#### Good Git commands to learn
4646

47-
* clone
48-
* add
49-
* commit
50-
* push
51-
* pull
52-
* reset
47+
- clone
48+
- add
49+
- commit
50+
- push
51+
- pull
52+
- reset
5353

5454
#### Basic examples
5555

@@ -77,6 +77,6 @@ Note: If working with a clone that you do not have rights to push to then you wi
7777

7878
### Git (and related) resources
7979

80-
* The Wikipedia article on Git provides a good overview of the software: http://en.wikipedia.org/wiki/Git_(software).
81-
* The official Git documentation has excellent content for learning how to use Git: http://git-scm.com/documentation.
82-
* GitHub's Help section has many useful tips and tricks, as well as guidance on how to setup Git, create Git repos, fork of repos and contribute to Git supported software projects: https://help.github.com/
80+
- The Wikipedia article on Git provides a good overview of the software: http://en.wikipedia.org/wiki/Git_(software).
81+
- The official Git documentation has excellent content for learning how to use Git: http://git-scm.com/documentation.
82+
- GitHub's Help section has many useful tips and tricks, as well as guidance on how to setup Git, create Git repos, fork of repos and contribute to Git supported software projects: https://help.github.com/

README.md

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -169,33 +169,19 @@ To the markdown parser, it doesn't matter how you wrap your sentences, a complet
169169

170170
### Tools and automatic formatting
171171

172-
**prettier**
172+
We use a combination of tools to automatically format the documentation.
173+
If you want to run them locally, install them:
173174

174-
It is recommended, but not required, to use [`prettier`](https://prettier.io/) to automatically format markdown files.
175-
This replaces some cases where two characters would produce the same output, and prefers the less ambiguous one, i.e. `-` instead of `*` for bulleted lists, `_` instead of `*` for italics.
176-
It also eliminates some common inconsistencies, such as trailing whitespace, too many / too few consecutive newline characters, etc.
177-
It doesn't help you with everything, for example, the one sentence per line style mentioned above is not something `prettier`
178-
does automatically, so you'd still have to do that manually.
179-
Formatting with `prettier` is currently not enforced, but recommended, especially if you are creating new files.
180-
181-
**markdowner.py**
182-
183-
We have a Python script and GitHub Action to automatically fix some common markdown mistakes.
184-
This is intentionally not very strict, it only fixes very specific things, such as:
185-
186-
- Trims trailing whitespace at the end of lines
187-
- Replace some utf-8 symbols which have an ascii lookalike
188-
- Ensures exactly 1 newline before the end of the file
189-
- De-indents code blocks where everything inside the code block is indented
175+
```
176+
pipx install cfengine black
177+
npm install --global prettier
178+
```
190179

191-
When someone makes one of these "mistakes" it is highlighted in the Pull Request by the GitHub Action.
192-
If you want to run this script locally and have it fix these things for you, you can:
180+
And run the command:
193181

194-
```bash
195-
find . -name '*.markdown' -type f -exec python3 .github/workflows/markdowner.py {} all \;
196182
```
197-
198-
In many cases, you can also configure your editor to help you with these things.
183+
cfengine dev docs-format
184+
```
199185

200186
## Documentation structure
201187

generator/build/README.md

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,58 @@
1-
Building docs in a container
2-
============================
1+
# Building docs in a container
32

43
This set of scripts lets you build docs in a container.
54
Currently, it's aimed towards using buildah on oslo-dc.
65

7-
Prereq
8-
------
6+
## Prereq
97

108
You will need to have the following repos checked out:
119

12-
* core (used for changelog, examples)
13-
* nova (used for changelog)
14-
* enterprise (used for changelog)
15-
* masterfiles (used to document masterfies)
16-
* documentation
10+
- core (used for changelog, examples)
11+
- nova (used for changelog)
12+
- enterprise (used for changelog)
13+
- masterfiles (used to document masterfies)
14+
- documentation
1715

18-
Usage
19-
-----
16+
## Usage
2017

2118
If you have buildah installed:
2219

2320
1. clone the above repos (run `clone.sh`)
2421

2522
2. export the following env variables:
23+
- `$BRANCH` - Branch that we're actually building artifacts for,
24+
for example, 3.18, master, or pr
2625

27-
* `$BRANCH` - Branch that we're actually building artifacts for,
28-
for example, 3.18, master, or pr
26+
- `$PACKAGE_JOB` - where to take CFEngine HUB package from,
27+
a dir at http://buildcache.cloud.cfengine.com/packages/,
28+
usually `testing-pr`
2929

30-
* `$PACKAGE_JOB` - where to take CFEngine HUB package from,
31-
a dir at http://buildcache.cloud.cfengine.com/packages/,
32-
usually `testing-pr`
30+
- `$PACKAGE_UPLOAD_DIRECTORY` - where to take CFEngine HUB package from,
31+
a dir at http://buildcache.cloud.cfengine.com/packages/testing-pr/,
32+
for example, `jenkins-master-nightly-pipeline-943`
3333

34-
* `$PACKAGE_UPLOAD_DIRECTORY` - where to take CFEngine HUB package from,
35-
a dir at http://buildcache.cloud.cfengine.com/packages/testing-pr/,
36-
for example, `jenkins-master-nightly-pipeline-943`
37-
38-
* `$PACKAGE_BUILD` - RELEASE of the build to be downloaded, usually 1
34+
- `$PACKAGE_BUILD` - RELEASE of the build to be downloaded, usually 1
3935

4036
3. `cd` to directory with all repos and run `run.sh` from this dir
4137

42-
Details
43-
-------
38+
## Details
4439

4540
To make a container, cd to this directory and run:
4641

47-
buildah build-using-dockerfile -t docs .
42+
buildah build-using-dockerfile -t docs .
4843

4944
or
5045

51-
docker build --tag docs .
46+
docker build --tag docs .
5247

5348
To run docs job in a container, run:
5449

55-
c=$(buildah from -v $PWD:/nt docs)
56-
buildah run $c bash -x documentation/generator/build/main.sh $BRANCH $PACKAGE_JOB $PACKAGE_UPLOAD_DIRECTORY $PACKAGE_BUILD
57-
buildah run $c bash -x documentation/generator/_scripts/_publish.sh $BRANCH
58-
buildah rm $c
50+
c=$(buildah from -v $PWD:/nt docs)
51+
buildah run $c bash -x documentation/generator/build/main.sh $BRANCH $PACKAGE_JOB $PACKAGE_UPLOAD_DIRECTORY $PACKAGE_BUILD
52+
buildah run $c bash -x documentation/generator/_scripts/_publish.sh $BRANCH
53+
buildah rm $c
5954

6055
or
6156

62-
docker run --rm -it -v $PWD:/nt docs bash -x documentation/generator/build/main.sh $BRANCH $PACKAGE_JOB $PACKAGE_UPLOAD_DIRECTORY $PACKAGE_BUILD
63-
docker run --rm -it -v $PWD:/nt docs bash -x documentation/generator/_scripts/_publish.sh $BRANCH
57+
docker run --rm -it -v $PWD:/nt docs bash -x documentation/generator/build/main.sh $BRANCH $PACKAGE_JOB $PACKAGE_UPLOAD_DIRECTORY $PACKAGE_BUILD
58+
docker run --rm -it -v $PWD:/nt docs bash -x documentation/generator/_scripts/_publish.sh $BRANCH

0 commit comments

Comments
 (0)