Format-check the documentation examples in CI - #5386
Merged
Conversation
The file uses "json & /*parsed*/" in three lambda parameter lists, which astyle rewrites to "json& /*parsed*/" per --align-reference=type. The drift went unnoticed because CI never format-checked the documentation examples; "make pretty" does cover them. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
The examples live in docs/mkdocs/docs/examples, but both format checks still referenced the long-gone docs/examples path: - check_amalgamation.yml passed it to find, which printed an error for the missing path and carried on, so astyle only ever saw include and tests. The step still exited 0. - ci.cmake globbed it into INDENT_FILES, and a GLOB_RECURSE over a missing directory silently yields nothing, so the ci_test_amalgamation target skipped the examples too. Either way the 231 example files have never been format-checked. Point both at the real path, and guard the workflow with an explicit directory check so a future rename fails the job instead of quietly shrinking the file list again. Also drop the dead docs/examples/** path filter from publish_documentation.yml; docs/mkdocs/** already covers the examples. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
nlohmann
added a commit
that referenced
this pull request
Aug 21, 2026
#5386 reformatted this example on develop and extended the CI format check to cover docs/mkdocs/docs/examples, which this branch predates. astyle rewrites "json & /*parsed*/" to "json& /*parsed*/" per --align-reference=type; the result is byte-identical to develop's copy. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The documentation examples have never been format-checked by CI. Both format checks pointed at
docs/examples, a path that does not exist — the examples live indocs/mkdocs/docs/examples. In each case the missing path failed silently rather than erroring:.github/workflows/check_amalgamation.ymlfindprinted an error for the missing path and exited nonzero, but its status was swallowed by command substitution. astyle simply received a shorter file list and the step exited 0.cmake/ci.cmakefile(GLOB_RECURSE ...)over a missing directory silently yields nothing, so theci_test_amalgamationtarget (still active via.github/workflows/ubuntu.yml) skipped the examples too..github/workflows/publish_documentation.ymldocs/examples/**path filter.Both checks now resolve 231 example files, up from 0.
For
publish_documentation.ymlthe filter was removed rather than repointed:docs/mkdocs/**is already listed and coversdocs/mkdocs/docs/examples, so repointing would have been redundant.Formatting fix
With the check repaired,
make amalgamatereformats exactly one file that had drifted behind it:docs/mkdocs/docs/examples/parser_callback_t.cpp, where three lambda parameters readjson & /*parsed*/instead ofjson& /*parsed*/(--align-reference=type).To confirm nothing else had drifted in the meantime, astyle was run over the full 384-file post-fix list — no further changes — and no verbatim copies of the old spelling remain elsewhere in the docs.
Failing loudly on a future rename
A rename silently shrinking the file list is the root cause here, not the stale path itself. The workflow now checks each source directory exists before the
findand fails with a GitHub error annotation if one does not:Verified in both directions: it passes on the current paths, and fails with exactly that message when fed the old one.
Guarding
find's own exit status instead would not have been enough here without also addingset -o pipefail— this workflow uses the defaultbash -e {0}shell and the file list is piped throughsort, so the pipeline reportssort's status, notfind's.Notes for reviewers
make prettywas compared against the new CI file list: it covers all 384 files plus the two amalgamated headers, which CI formats in the preceding astyle call.make amalgamatetherefore remains a faithful local pre-check.API impact
No breaking changes. This touches CI configuration and comment whitespace in one documentation example. No changes to any header, to
single_include/, or to the public API. The amalgamated headers are unchanged by this PR.make amalgamate.This pull request was prepared by Claude Code.