-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
cargo doc: add option to document private types #1520
Comments
I'd prefer a |
+1 |
+1 Another idea: Would it make sense to enable doc generation of private types for non-library projects by default? If you're developing a library, the docs are mainly for your users and those are not interested in private stuff. To not generate docs for private types by default makes sense here. Developers of the library can use the command line parameter to generate docs with private types for their use. If you're developing a program (non-library), what are docs for then? Normal "users" of the program don't care about the source code and the documentation. So the docs are probably mainly for developers. It makes sense to generate docs for private types here. IMO. |
I have to agree. In my Python projects, I use ePyDoc to get a structured overview of my code when I'm returning from working on something else and the Rust book didn't even mention that private types wouldn't get documented. Since my first project was an application project, that led me to get really frustrated because I thought it was something that was supposed to work and, thus, something I'd done wrong. |
In Servo we’ve worked around that by calling Cargo with a #!/bin/sh
rustdoc --no-defaults --passes collapse-docs --passes unindent-comments "$@" |
What is the state of this? |
I think |
I also would like this for hosting internal documentation of libraries for people who want to develop those libraries vs. users of those libraries. |
For the record, this seems to work:
|
Based on the newest servo rustdoc-with-private script and the I think there should be first-class support for private docs during development, so I can do something like EDIT: Well, rustdoc already shows |
How to do this is a fairly common question and though Would a PR be accepted or is an RFC required? |
I would love to be able to do |
I just wanted this feature again today. Was showing off rustdoc for a binary crate I'm working on, but it's pretty unimpressive since none of its (sub)modules is public and I couldn't quickly remember the invocation to make Add my name to the list of folks who would be happy to look into implementing this. :) |
Please make this more accessible, I've been missing this feature countless times. |
I'd also really like this feature. I also think it would be great to have a profile for "all docs", so that sites like docs.rs can build both "external" and "internal" docs -- this would mean that the internal docs are also linkable, which local doc builds aren't. |
I would also join my voice to those complaining for lack of support. Thanks to solson now I have a bash script calling into cargo, but it took me a while to find out how this is at all possible. |
I feel like it would be nice to optionally have
Where "developer docs" links to an alternate index.html compiled with Something simple and discoverable like |
A small note here, we plan on deprecating the |
For anyone stumbling upon this, rust-lang/rust#44138 has implemented the cargo rustdoc -- --document-private-items |
While |
Does anyone want |
See #5958. |
This has been implemented in #5543 and is available in 1.29 beta. I think this can be closed. |
Indeed! |
@alexcrichton What about the request to document private things by default for binary projects? I think quite a few people agree with that. And as far as I can see, the linked PR doesn't implement that. Should I create a separate issue for that? |
Document private items for binary crates by default I suggested this change in default behavior [a long time ago](#1520 (comment)) and [a year ago again](#1520 (comment)). Both time, everyone seemed to agree that this is a good idea, so I thought I could just implement it. This PR already changed the default behavior, but there are a few things we should talk about/I should do before merging: - [x] ~~Do we *really* want this changed default behavior? If not, *why* not?~~ -> [yip](#7593 (comment)) - [x] Is changing this default behavior OK regarding backwards compatibility? -> [apparently](#7593 (comment)) - [x] ~~We should also probably add a `--document-only-public-items` flag or something like that if we change the default behavior. Otherwise users have no way to not document private items for binary crates. Right?~~ -> [We can do it later](#7593 (comment)) - [x] I should probably add some tests for this new behavior -> I did - [ ] I don't like that I added `rustdoc_document_private_items` to `CompileOptions`, but this was the sanest way I could think of without rewriting a whole lot. Is this OK or how else would one do it? The flag would belong to `DocOptions`. But `compile` does not have access to that. Any ideas? Btw: If we also add `--document-only-private-items`, I would change the type from `bool` to `Option<bool>`.
The docs are currently a bit confusing since it is not apparent from the index whether an item is private. In particular, if the private-module-public-reexport pattern is used, it would result in both items being displayed, making it really confusing even for myself. Is there an option to add a private icon (similar to the unsafe icon)? |
rustdoc can include private items in the generated documentation: rust-lang/rust#15347 (comment)
This is triggered by passing
--no-defaults --passes "collapse-docs" --passes "unindent-comments"
to it. This has two issues:Could Cargo do this itself e.g. when
[lib] doc-private = true
is set inCargo.toml
?The text was updated successfully, but these errors were encountered: