How can I write crate-wide documentation?

后端 未结 1 866
旧巷少年郎
旧巷少年郎 2021-01-08 01:21

In order to ensure that all public artifacts of my crate are documented (if minimally to start with), I specified #![deny(missing_docs)] in my lib.rs

1条回答
  •  不要未来只要你来
    2021-01-08 01:45

    I found the hidden nugget in the book's Publishing a Crate to Crates.io section.

    Regular documentation comments (starting with ///) document the next item, however a crate is nobody's next.

    The solution is to switch to using another kind of comment, this time starting with //!, which documents the enclosing item.

    And suddenly it works:

    #![deny(missing_docs)]
    
    //! Hello world example for Rust.
    
    fn main() {
        println!("Hello world!");
    }
    

    0 讨论(0)
提交回复
热议问题