Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to suppress "Generated" lines from cargo doc #13336

Closed
kpreid opened this issue Jan 22, 2024 · 4 comments · Fixed by #13557
Closed

Ability to suppress "Generated" lines from cargo doc #13336

kpreid opened this issue Jan 22, 2024 · 4 comments · Fixed by #13557
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-doc S-triage Status: This issue is waiting on initial triage.

Comments

@kpreid
Copy link
Contributor

kpreid commented Jan 22, 2024

Problem

Since Rust 1.75, when cargo doc is run without --open, it prints "Generated <path>" for each documented crate in the workspace (#5562). While this is useful when users wish to open the documentation by some other means than --open, it's clutter (~doubling the height of the output) in a large workspace when the user already has the documentation open or has other means to access the path the documentation will be generated at.

Proposed Solution

Add a configuration option which suppresses “Generated” lines.

Alternatively, make cargo doc emit only one such line for the entire workspace, in the same way that cargo doc --open picks one path; this could be an option or might even be acceptable as the default behavior.

Notes

--quiet is not an adequate solution since it hides all output, including progress when re-documenting dependencies from clean.

The reason I personally care about this is that running cargo doc is part of my normal development cycle — if I don't run it, I won't discover I've broken an intra-doc link, which happens very often. So, I want the output to be short if nothing is wrong, but still let me see progress. (If cargo check reported broken intra-doc links and other doc lints, that would be an even better alternative, but I don't expect that to be feasible.)

@kpreid kpreid added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Jan 22, 2024
@epage
Copy link
Contributor

epage commented Jan 22, 2024

For myself, I am very cautious when it comes to adding configuration as it increases the combinations of what could fail and balloons documentation, making it harder to find any other piece of related documentation, making it less likely to use any feature, lowering the value gained from those features.

In #12859, I was originally going to show only one "Generated" line but was worried about only showing one package and it confusing the user. This is different than --open where they are immediately shown the web page and see the other packages. With "Generated", the user may never follow the link or may get confused before they follow the link.

For cargo script, I've been considering finding a way to collapse down the amount of output from cargo but that only helps with everything before "Generated".

One option might be if we add a trailing "and X other packages" to the "Generated" line? And then in verbose mode, we instead print them all?

@epage epage added Command-doc A-console-output Area: Terminal output, colors, progress bar, etc. labels Jan 22, 2024
@weihanglo
Copy link
Member

One option might be if we add a trailing "and X other packages" to the "Generated" line? And then in verbose mode, we instead print them all?

If the status message of cargo doc won't be cached, this seems to be a good option. One thing to consider is that cargo test --no-run does a similar output printing Executable but hasn't got feedback like this. Should their behaviors be consistent with each other?

    Finished test [unoptimized + debuginfo] target(s) in 1m 02s
  Executable unittests src/cargo/lib.rs (target/debug/deps/cargo-52e5c7b69d837521)
  Executable tests/build-std/main.rs (target/debug/deps/build_std-aaec4da60de65b74)
  Executable tests/testsuite/main.rs (target/debug/deps/testsuite-3610deb6673c6f79)

@epage
Copy link
Contributor

epage commented Jan 22, 2024

Funny you mention that for cargo test because I want to clean up all of that :)

@kpreid
Copy link
Contributor Author

kpreid commented Jan 22, 2024

For myself, I am very cautious when it comes to adding configuration as it increases the combinations of what could fail and balloons documentation,

Which is why I mentioned a few other options (perhaps less straightforward, but not requiring configuration).

Perhaps I should just live with the disadvantage of --quiet.

One thing to consider is that cargo test --no-run does a similar output printing Executable but hasn't got feedback like this. Should their behaviors be consistent with each other?

Probably --no-run is used less often (or, at least, it certainly is by me). To me it makes sense that it works the way it does because if I'm doing a --no-run I might be intending to do something with the executables. (The last time I had reason to think about it, I was telling someone else that they could discover the executable path that way, in order to run the test under a debugger.) cargo doc's current behavior makes sense under the same logic. Perhaps the difference here is in what is the default behavior, and that cargo test by default is much more verbose (the Running lines are swamped by test harness output).

epage added a commit to epage/cargo that referenced this issue Mar 7, 2024
epage added a commit to epage/cargo that referenced this issue Mar 7, 2024
bors added a commit that referenced this issue Mar 7, 2024
fix(doc): Collapse down Generated statuses without --verbose

### What does this PR try to resolve?

This is trying to balance
- Overwhelming the user with a lot of paths
- Clarity to the user that the one path is representative of the rest

clap before:
```
    Finished dev [unoptimized + debuginfo] target(s) in 3.81s
   Generated /home/epage/src/personal/clap/target/doc/clap/index.html
   Generated /home/epage/src/personal/clap/target/doc/stdio_fixture/index.html
   Generated /home/epage/src/personal/clap/target/doc/clap_bench/index.html
   Generated /home/epage/src/personal/clap/target/doc/clap_builder/index.html
   Generated /home/epage/src/personal/clap/target/doc/clap_complete/index.html
   Generated /home/epage/src/personal/clap/target/doc/clap_complete_fig/index.html
   Generated /home/epage/src/personal/clap/target/doc/clap_complete_nushell/index.html
   Generated /home/epage/src/personal/clap/target/doc/clap_derive/index.html
   Generated /home/epage/src/personal/clap/target/doc/clap_lex/index.html
   Generated /home/epage/src/personal/clap/target/doc/clap_mangen/index.html
```
clap after:
```
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.44s
   Generated /home/epage/src/personal/clap/target/doc/clap/index.html and 9 other files
```

Fixes #13336

### How should we test and review this PR?

Tests were updated in earlier commits to help show the behavior change

### Additional information
@bors bors closed this as completed in 7bc6044 Mar 7, 2024
charmitro pushed a commit to charmitro/cargo that referenced this issue Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-doc S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants