`#[doc(hidden)]` for `main()`?

I'm generating documentation for a tool I've built, and I'm documenting the private items so other developers can easily look things up in the documentation, but I also want to hide certain things that really don't need documentation, like the main() function especially.

The following doesn't seem to work:

#[doc(hidden)]
fn main() -> io::Result<()> {
    // ...
}

I have a feeling that the --document-private-items is conflicting with the #[doc(hidden)] on my main function.

Any ideas on a possible solution?

This should be solved in the latest or an upcoming nightly.

2 Likes

I wanted to add that I found a different solution, which is to add a lib.rs to my crate which makes it both a binary and a library, and the docs are built for the library and not the binary. Which works nicely.

Also, for anyone who doesn't know about this strategy, I already had most of the "run" logic of the binary in a different file. The logic in main.rs just declared all of my modules and contained a main function that called run from a different module. I just renamed that "run" module to lib.rs, moved the module declarations into lib.rs, made some minor import path changes, and I was good to go.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.