Skip to content

Use docsrs attribute to indicate feature-gated items in documentation #986

@newpavlov

Description

@newpavlov

In code it looks like this:

#[cfg(feature = "my_feature")]
#[cfg_attr(docsrs, doc(cfg(feature = "my_feature")))]
struct Foo;

And in Cargo.toml:

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

Rendered result can be seen for example in the digest docs.

Also I think it will be nice to document crate features and indicate those enabled by default in the lib.rs docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-docsDocumentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions