Search code examples
rustwarningscompiler-warnings

Is there a warning for undocumented sections?


I am writing a crate that I plan to publish. When publishing, one of the most important thing (in my opinion) is to ensure the crate is well documented. Therefore my question : is there a warning to be turned on which warms undocumented sections of the code ?


E.g.: I typically think of something like #[warn(undocumented)].


Solution

  • Yes, such a lint exists. The rustc compiler provides the missing_docs lint, which warns about missing documentation on public items when enabled. The clippy linter provides the missing_docs_in_private_items lint, which additionally warns… well, you guessed it. Note that missing_docs_in_private_items warns for all items, so you don't need missing_docs if you enable it.

    You can enable the lints using

    #![warn(missing_docs)]
    #![warn(clippy::missing_docs_in_private_items)]
    

    for warnings or

    #![deny(missing_docs)]
    #![deny(clippy::missing_docs_in_private_items)]
    

    for errors.