Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cfengine_cli/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ def _process_markdown_code_blocks(
return

if syntax_check:
# We currently only print the filenames during linting, not formatting
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olehermanse was there a specific reason for this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

print(
f"Processing code blocks (snippets) inside {origin_paths_len} markdown files:"
)
Expand All @@ -268,6 +267,8 @@ def _process_markdown_code_blocks(
if syntax_check and not parsed_markdowns["files"][origin_path]["code-blocks"]:
print(f"{prefix}SKIP: No code blocks in '{origin_path}'")
continue
if autoformat:
print(f"Formatting '{origin_path}'")
Comment on lines +270 to +271
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

for i, code_block in enumerate(
parsed_markdowns["files"][origin_path]["code-blocks"]
):
Expand Down
Loading