If the reason for wanting to save the docc diagnostics to a file is to parse them then I should point out that both the main and the release/5.9 branches of DocC have a built-in option to write the full fidelity diagnostics to a JSON file by passing --diagnostics-file path/to/some-file-name.json. You can check the docc "features.json" file to check if the DocC you're using supports this flag.
I noticed just now that we don't have an OpenAPI spec for the structure of that JSON but the Codable struct definition can be found in DiagnosticFile.swift.
We have one diagnostic OpenAPI spec file but that's for a previous file format that we intend to deprecate in the future. ↩︎
But I found if i pass --diagnostics-file, The warning log also output in the terminal.
Is that possible --diagnostics-file flag only write the diagnostics to file, not output in the terminal.
It looks like this flag did two things, write json diagnostics and output to terminal.
(But it doesn't matter, I can ignore the log! ^_^ )
Yes, the way that the diagnostic file option is currently intended to work specifies output to a file in addition to the output to standard error.
I wasn't sure if it would be more or less confusing for the diagnostic file option to also stop writing diagnostics to standard error but I'd be interested in changing that behavior if there's a consensus on which behavior is less confusing.