How to generate `cargo doc` for `pub(crate)` items or files?

cargo doc is helpful to generate API documentations for public items. However, I also want the contributors of the crate to quickly get the idea what each mod is doing, what are their crate-public (pub(crate)) APIs, etc. Therefore, I wonder how to generate cargo doc for pub(crate) items or files? Thanks!

cargo doc --document-private-items

6 Likes

Thank you so much! I am so silly not to find this

So, I wonder whether it is possible to hide documents for fn, but only show pub(crate) fn? Since for example, one mod may have only several pub(crate) functions, which should be used by other mods, but can contain a ton of private functions, which is only implementation details and I do not want people to be distracted by being presented all these.

I'm not aware of an option to do that directly or automatically. You can (manually) mark things you don't want shown as hidden.

https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html#hidden

That sounds a bit tedious... Anyway thank you all the same!