CFE-4665: cfengine dev format docs should tell you what files it formatted#144
CFE-4665: cfengine dev format docs should tell you what files it formatted#144sarakthon wants to merge 1 commit into
cfengine dev format docs should tell you what files it formatted#144Conversation
…rmatted Ticket: CFE-4665
|
Thank you for submitting a PR! Maybe @larsewi can review this? |
| return | ||
|
|
||
| if syntax_check: | ||
| # We currently only print the filenames during linting, not formatting |
There was a problem hiding this comment.
@olehermanse was there a specific reason for this?
There was a problem hiding this comment.
I think the logic is / was slightly different. During linting we always print the filenames with a pass or fail message.
On formatting we (should) print only the ones that were reformatted. I think in the beginning there was no code / return code to track whether something was reformatted or not.
It might also have been harder to get this information. When we use tools like prettier and black for formatting, they might have different patterns for their outputs. And I know we have switched in the past between running those tools on single files (slow, but more controlled) vs on entire directories (faster, but more complicated output / results).
We now do this in cfengine format, only printing on reformatting, so it makes sense to do in in cfengine dev format-docs as well.
| def _process_markdown_code_blocks( | ||
| path, languages, extract, syntax_check, output_check, autoformat, replace, cleanup | ||
| ): |
There was a problem hiding this comment.
Unrelated, but I wish there was some doc string explaining these arguments. What is autoformat?
There was a problem hiding this comment.
Automatically format the code block.
| if autoformat: | ||
| print(f"Formatting '{origin_path}'") |
There was a problem hiding this comment.
We should print messages like in cfengine format:
Policy file './content/resources/additional-topics/STIGs.cf' was reformatted
And these should only be printed if the file was reformatted (i.e. the file changed).
Ticket: CFE-4665