Skip to content

doc(hidden) stopped working in binary crates #67851

Closed

Description

@dtolnay

rust-lang/cargo#7593 seems relevant. cc @LukasKalbertodt @Eh2406

If I have the following binary crate, cargo doc on stable 1.40.0 will correctly show g and not f, while beta will show both despite f being doc(hidden).

#[doc(hidden)]
pub fn f() {}
pub fn g() {}
fn main() {}

I understand that we want private things documented for bin crates, but I am labeling this a regression because this makes it impossible for macro-generated code to hide distracting implementation details that might overwhelm the actual useful API of the generated code.

I would like to suggest continuing to leave doc(hidden) items out of bin crate documentation as the default behavior of cargo doc.

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    T-cargoRelevant to the cargo team, which will review and decide on the PR/issue.
    on Jan 4, 2020
  2. Eh2406 commented on Jan 4, 2020

    @Eh2406
    Contributor

    Your suggestion seems entirely reasonable to me. I don't know what PR wuld need to go where to impl it.

  3. dtolnay commented on Jan 4, 2020

    @dtolnay
    MemberAuthor

    @rust-lang/cargo @rust-lang/rustdoc, any tips for what PRs would need to go where?

  4. LukasKalbertodt commented on Jan 4, 2020

    @LukasKalbertodt
    Contributor

    Just for reference, the PR you linked (rust-lang/cargo#7593) is not directly responsible for the buggy behavior. You can see the problem with 1.40 by cargo doc --document-private-items (which also documents f).

    Could it be that we simply have to add a STRIP_HIDDEN pass here (and potentially some other arrays in that file)?

    pub const DEFAULT_PRIVATE_PASSES: &[Pass] = &[
    COLLECT_TRAIT_IMPLS,
    COLLAPSE_DOCS,
    UNINDENT_COMMENTS,
    CHECK_PRIVATE_ITEMS_DOC_TESTS,
    STRIP_PRIV_IMPORTS,
    COLLECT_INTRA_DOC_LINKS,
    CHECK_CODE_BLOCK_SYNTAX,
    PROPAGATE_DOC_CFG,
    ];

  5. added a commit that references this issue on Jan 6, 2020
    8f42408
  6. added a commit that references this issue on Jan 7, 2020
    4b9d279
  7. added a commit that references this issue on Jan 8, 2020
    03fe834
  8. jtmoon79 commented on Jan 10, 2025

    @jtmoon79

    Relates to #66528

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-cargoRelevant to the cargo team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions