-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to exclude source code from docs #75497
Comments
At least some guidance on how-to-implement-that would be really appreciated! |
This is more of an issue for rustdoc, so moved to rust-lang/rust where its issue tracker resides. |
The |
OMG it does! Thanks a lot, @ollie27! Although why don't we make a rustdoc flag for that? |
Well, let's add one then... |
Does it make sense to have both an attribute and a command line flag for this? This doesn't seem like something you'd want to configure on a per-invocation basis, it's more like something that's permanent for a given code base (so the attributes fits better). |
I think it fits the use case of being able to produce end-user documentation (without source links if providing binaries only) and internal documentation (with source links that may be helpful in some cases). I'm guessing it would also be more discoverable ( |
Currently the only way to find this is through rustdoc book, which may not be quite discoverable if the users didn't saw that. I wish there is a manpage for rustdoc book but still currently man pages for rust is still not very good yet since we haven't figured out how to get to show the correct man pages for the current directory. |
Well, while the attribute is kinda sufficient, it would be also great to have an option to jump-to-source-code during the development phase. On the other hand, the attribute could be disabled/enabled with a feature flag, so having a rustdoc flag is not exactly required. |
#75522 was closed as won't fix since there are already ways to do this and it's not standard to duplicate attributes as arguments. |
Is there currently any way to disable source generation for the current crate and all dependencies on stable? The suggestion from that PR requires an unstable flag that doesn't appear to have had any stabilization plans since it was added in #52355. |
no. i would like to stabilize that flag but i don't think it currently has a tracking issue. i am happy to mentor that work if you're interested in contributing :) |
I think it deserves some more discussion: on docs.rs, users will still be able to browse the source code with docs.rs code viewer. But also, when building such crates locally, nothing prevent users to actually read the code they downloaded. So maybe a broader point of view should be taken here? |
Personally the reason we had a need for this is because the docs for our project ended up getting big enough to reach a file size limit in our internal docs deployment, and so we wanted to be able to disable the source generation since we simply have no use for it and it ends up taking up a significant chunk of the output size. For now we're disabling building docs for dependencies instead, but it's rather unfortunate because having the docs for dependencies built with the correct features is very useful. |
I'm surprised that the source code files make such a big difference. Shouldn't it represent a very small portion of the total? |
In our case it represents just under 20% of the whole docs directory. |
Wow, that's a lot. With this in mind, the option makes a lot more sense. Thanks for explaining. So for next steps, just as jyn514 explained. ;) |
Describe the problem you are trying to solve
I ship a proprietary cdylib which I build from Rust code. I want to document the API using doc comments. However at the moment
cargo doc
puts the source code into target/doc/src/ which is not an option. I know I canrm target/doc/src/
however there is[src](goto source code)
button left in the top right corner of the docs.Describe the solution you'd like
cargo doc --exclude-source
Notes
The text was updated successfully, but these errors were encountered: