Skip to content

Commit 8469f9c

Browse files
committed
Integrated prettier and black with CFEngine CLI
Signed-off-by: Ole Herman Schumacher Elgesem <ole@northern.tech>
1 parent ecda115 commit 8469f9c

File tree

3 files changed

+9
-33
lines changed

3 files changed

+9
-33
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
*~

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

0 commit comments

Comments
 (0)