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

rustdoc exits with an error on crate-level #![doc(hidden)] #109695

Open
jotare opened this issue Mar 28, 2023 · 4 comments
Open

rustdoc exits with an error on crate-level #![doc(hidden)] #109695

jotare opened this issue Mar 28, 2023 · 4 comments
Labels
C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jotare
Copy link

jotare commented Mar 28, 2023

Problem

Hi, I found a possible bug (or at least, bad error message) while generating documentation for a library with #![doc(hidden)]. The use case is a library with private documentation published to crates.io. The docs page is generated and failing. In the docs page you see all broken but no documentation is intended.

(It's a third party crate so I don't have decision on having no documentation)

The error thrown by cargo doc is somewhat obscure, as hiding docs is intentional:

error: couldn't generate documentation: No such file or directory (os error 2)
  |
  = note: failed to create or modify "/home/.../hidden-docs-bug/target/doc/hidden_docs_bug/all.html"

error: could not document `hidden-docs-bug`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2021 --crate-type lib --crate-name hidden_docs_bug src/lib.rs -o /home/.../hidden-docs-bug/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=105 -C metadata=5b17bc2b2d87366d -L dependency=/home/.../hidden-docs-bug/target/debug/deps --crate-version 0.1.0` (exit status: 1)

(Full paths have been trimmed)

I'd expect docs to be generated and either an empty docs page or with a simple message indicating this crate has no/hidden docs.

Steps

  1. Create a new cargo project:
cargo init hidden-docs-bug
  1. Open src/lib.rs and add a #![doc(hidden)] in the beginning of the file.
  2. Generate docs using cargo doc.

Possible Solution(s)

I'd expect something like either generating an empty docs page or with a simple message indicating docs are hidden for this crate.

Notes

No response

Version

cargo 1.68.0 (115f34552 2023-02-26)
release: 1.68.0
commit-hash: 115f34552518a2f9b96d740192addbac1271e7e6
commit-date: 2023-02-26
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.86.0-DEV (sys:0.4.59+curl-7.86.0 vendored ssl:OpenSSL/1.1.1q)
os: Ubuntu 22.04 (jammy) [64-bit]
@jotare jotare added the C-bug Category: This is a bug. label Mar 28, 2023
@ehuss ehuss transferred this issue from rust-lang/cargo Mar 28, 2023
@ehuss
Copy link
Contributor

ehuss commented Mar 28, 2023

Thanks for the report! This appears to be an issue with rustdoc, and its issue tracker lives here.

@ehuss ehuss added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Mar 28, 2023
@jyn514
Copy link
Member

jyn514 commented Mar 28, 2023

Putting doc(hidden) on the entire crate is ... a very strange decision. I am not sure what the semantics of that should be.

The use case is a library with private documentation published to crates.io.

What does this mean? docs.rs intentionally does not have an opt-out mechanism: rust-lang/docs.rs#125

@jyn514 jyn514 changed the title Library with hidden docs fails on generating them rustdoc exits with an error on crate-level !#[doc(hidden)] Mar 28, 2023
@jyn514 jyn514 changed the title rustdoc exits with an error on crate-level !#[doc(hidden)] rustdoc exits with an error on crate-level #![doc(hidden)] Mar 28, 2023
@jotare
Copy link
Author

jotare commented Mar 28, 2023

Thanks for the quick reply!

Putting doc(hidden) on the entire crate is ... a very strange decision. I am not sure what the semantics of that should be.

Yes, I also think so. In my opinion, an empty docs page (or something similar) or a better error, both might have sense

What does this mean? docs.rs intentionally does not have an opt-out mechanism: rust-lang/docs.rs#125

I first opened an issue to this crate, so I link to it so you can have more context: taiki-e/cargo-llvm-cov#248

@jyn514 jyn514 added the I-needs-decision Issue: In need of a decision. label Mar 28, 2023
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Mar 29, 2023
@GuillaumeGomez
Copy link
Member

I personally think it's an acceptable behaviour. It'll just create an empty documentation and that's it. Seems like a weird use case indeed though.

I opened #109726 which fixes the rustdoc crash in the meantime (which therefore generates empty documentation).

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 29, 2023
…=notriddle

rustdoc: Don't strip crate module

Until we decide something for rust-lang#109695, rustdoc won't crash anymore because the crate folder doesn't exist.

r? `@notriddle`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants