Skip to content

rustdoc: --show-coverage --output-format=json doesn't respect -o, but the docs suggest it will. #158929

Description

@aDotInTheVoid

In the docs for --show-coverage --output-format=json we say:

If you want the JSON output to be displayed on stdout instead of having a file generated, you can
use -o -.

-- https://github.com/rust-lang/rust/blob/f10db292a3733b5c67c8da8c7661195ff4b05774/src/doc/rustdoc/src/unstable-features.md#json-output

This is true!

$ rustdoc +nightly ./lol.rs --show-coverage --output-format=json -Zunstable-options -o -
{"./lol.rs":{"total":2,"with_docs":0,"total_examples":1,"with_examples":0}}

But if you use -o file.json it still prints to stdout:

$ rustdoc +nightly ./lol.rs --show-coverage --output-format=json -Zunstable-options -o file.json
{"./lol.rs":{"total":2,"with_docs":0,"total_examples":1,"with_examples":0}}
$ ls
lol.rs

In fact, rustdoc always prints to stdout, and the -o flag does nothing:

fn print_results(&self) {
let output_format = self.ctx.output_format;
// In this case we want to ensure that the `OutputFormat` is JSON and NOT the `DocContext`.
if output_format.is_json() {
println!("{}", self.to_json());
return;
}

The docs should be updated to be clear about this.

Also, maybe --emit=dep-info shouldn't be supported when using --show-coverage, and there's no "output file" to speak of.

Metadata

Metadata

Labels

A-doc-coverageArea: Calculating how much of a crate has documentationA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.T-rustdoc-internalsRelevant to the rustdoc internals team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions