Documentation of attributes

In standard rust crate documentation, on, where do I find documentation of attributes?

In particular I am looking at the crate Clap and I want to find the documentation for default_value_t as in this from their examples but I would like to know what technique I should employ to find documentation of attributes generally.

        default_value_t = 22,
        value_parser = clap::builder::PossibleValuesParser::new(["22", "80"])
            .map(|s| s.parse::<usize>().unwrap()),

Every attribute has a corresponding macro that interprets it. In this case, the clap::Parser derive macro is marked as #[doc(hidden)], but we can find the documentation from its original location at clap_derive::Parser. The clap maintainers decided to only write a stub for that, since they wrote the full documentation for its attributes elsewhere. Indeed, the top-level documentation for clap_derive links to the Derive Tutorial and the Derive Reference. That particular attribute is documented in the Arg Attributes section of the Derive Reference.

1 Like

That lead me to documentation of that specific thing I want, thank you. But I do not understand the general technique to find such documentation in crate documents

There is no general technique. Crate authors can write (or not write) their documentation in whatever format they please. You'll have to be creative. If the documentation is badly written so that it's not very discoverable, then unfortunately it's likely going to be hard to use. I don't think there's any specific or general technique for solving this problem (apart from the obvious but probably dissatisfying answer of asking the authors to write better docs).


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.