Add plugin flag argument to enable JSON pretty printing - #128
Open
lopsae wants to merge 3 commits into
Open
Conversation
Adds the jsonPrettyPrint argument flat to both plugins, used in the command line through `--json-prettyprint`. This flag adds an the `DOCC_JSON_PRETTYPRINT` variable to the docc process environment, enabling prettyprinting of json files. This environment value is mentioned in https://github.com/swiftlang/swift-docc/blob/main/CONTRIBUTING.md
with the help output for `—json-prettyprint`
Add tests for the expected properties in `doccEnvironment` when the `—json-prettyprint` flag is enabled
lopsae
marked this pull request as ready for review
June 27, 2026 02:16
Author
|
@swift-ci please test |
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.
Bug/issue #127
Summary
Add the
--json-prettyprintflag to enable the output json files to be pretty-printed and ordered. This flag can be used with bothgenerate-documentationandpreview-documentation.Implementation
The
doccexecutable already supports pretty printing by adding the environment variableDOCC_JSON_PRETTYPRINT, as described in the docc contribution guide.When the
—json-prettyprintflag is used, theProcessthat executes thedocccommand is updated with theDOCC_JSON_PRETTYPRINTenvironment property, which enables the feature. Otherwise the inherited environment for theProcessis not modified.Dependencies
No external dependencies.
Testing
For a package configured to generate docc documentation, run the
generate-documentationplugin command without--json-prettyprintInspecting any of the json files in produced in
docs, the contents should be in single line of json without any discernible order, for exampledocs/index/index.json:Run again using
--json-prettyprint:The content of the same json file now should be spaced, for example:
If the same
generate-documentationis run again, no output files should have changed indocs.Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/testscript and it succeededDiscussion
Swift Forums Discussion.