Doc for private functions

How to generate doc-description for private function?
Flag --document-private-items not working.

Cargo.toml :

[lib]
name = "libmy_sys"
path = "src/lib.rs"
rustdocflags = ["--document-private-items"]

lib.rs :

extern {
    /// Foo
    /// # Arguments
    ///
    /// * `bar` - lorem ipsum
    fn My_init_function( bar: *const c_char ) -> c_uchar;
}

cargo doc --open

via https://doc.rust-lang.org/reference/items/external-blocks.html

External blocks provide declarations of items that are not defined in the current crate and are the basis of Rust's foreign function interface. These are akin to unchecked imports.

There's no point in exposing documentation in your codebase on these. It's not coming from your code.

rustdocflags is not a valid Cargo.toml key. You need to invoke cargo doc --document-private-items --open or set the RUSTDOCFLAGS environment variable, or modify .cargo/config.

1 Like

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.