I have developed a closed source crate and I am needing to distribute documentation of the public API generated by cargo doc
. However, cargo doc
always includes the source code in the HTML. Is there a way to generate API documentation that doesn't also include the source code?
You can add #![doc(html_no_source)]
as a crate-level attribute and cargo doc won't add the source code to your documentation, see here: The #[doc] attribute - The rustdoc book.
Found the answer in an issue on github: Add an option to exclude source code from docs · Issue #75497 · rust-lang/rust · GitHub
5 Likes
Note that as mentioned in How can I share my lib? if you ship your closed source app as rlib, this will still leak a lot of information you might not want. Also it will only work with a single rustc version.
5 Likes
Works great! Thanks!
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.