Skip to content
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 option to include private definition in the documentation. #15347

Closed
nwin opened this issue Jul 2, 2014 · 18 comments
Closed

Add option to include private definition in the documentation. #15347

nwin opened this issue Jul 2, 2014 · 18 comments
Assignees
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@nwin
Copy link
Contributor

nwin commented Jul 2, 2014

Please add an option for rustdoc such that rustdoc creates a proper documentation for private definitions.

While it is in general a good idea to hide these private definitions, as a crate developer it would be very valuable to have a good internal documentation of private types and functions.

@steveklabnik
Copy link
Member

I'm -1. You can use regular comments for internal documentation.

@alexcrichton
Copy link
Member

Closing, you can actually do this today!

rustdoc --no-defaults --passes collapse-docs --passes unindent-comments

By default rustdoc has a pass to strip private items, but those flags are just disabling that pass from running. rustdoc -h should give you more information.

@nwin
Copy link
Contributor Author

nwin commented Jul 2, 2014

This at least not work in my crate. All private definitions are still hidden.

Beside that, I get a strange error message "ERROR:rustdoc: unknown pass collapse-docs unindent-comments, skipping" when I use both passes.

@alexcrichton
Copy link
Member

Hm it appears that they seem to no longer work! reopening.

@alexcrichton alexcrichton reopened this Jul 2, 2014
@SimonSapin
Copy link
Contributor

I’d like this (and a way to have cargo doc enable it) for http://doc.servo.org. rustdoc is useful not only when using a library, but also when working on that library itself. Granted, the two use cases are separate so this shouldn't be on by default.

I'm -1. You can use regular comments for internal documentation.

Navigation in a text editor is not nearly as easy as in rustdoc, where clicking on most things gets you to the documentation of that thing. This is invaluable when working on a large code base that you don’t know very well.

@steveklabnik steveklabnik added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 23, 2015
@drewcrawford
Copy link
Contributor

+1. Writing a library, would benefit from being able to see private documentation while I work.

@drewcrawford
Copy link
Contributor

It does look like the workaround

--no-defaults --passes "collapse-docs" --passes "unindent-comments"

works. (Need multiple invocations for "passes").

Recommend close.

@SimonSapin
Copy link
Contributor

@drewcrawford are these rustdoc arguments? Can cargo doc be made to use them?

@drewcrawford
Copy link
Contributor

They're rustdoc arguments. cargo doc can't be taught them, but I'd encourage you to comment in rust-lang/cargo#331 on that topic.

@SimonSapin
Copy link
Contributor

We turned this on on http://doc.servo.org/ . It’s better, but not ideal: all use and extern crate statements show up as well. It’s pretty noisy. #27104

@SimonSapin
Copy link
Contributor

@alexcrichton, could you edit #15347 (comment) ?

--passes "collapse-docs unindent-comments" causes ERROR:rustdoc: unknown pass collapse-docs unindent-comments, skipping which I ignored at first since docs still seem to be generated, but all doc-comments are truncated to their first line for a reason I don’t understand. servo/servo#6668 I’m unsure if this should be filed as a rustdoc bug. It does give an error message, after all.

It should be --passes collapse-docs --passes unindent-comments, with only one value per --passes.

SimonSapin added a commit to servo/servo that referenced this issue Jul 20, 2015
`rustdoc --passes "collapse-docs unindent-comments"` doesn’t work is intended.
It still generate HTML files that look alright at a glance,
but all doc-comments are truncated to their first line
for some reason I don’t understand.

See http://doc.servo.org/script/dom/index.html for example.
The module documentation there is currently just
“The implementation of the DOM.”, but clicking the [src] link
shows a much larger doc-comment.

rust-lang/rust#15347 (comment)

The correct invokation is to use `--passes` multiple times.
bors-servo pushed a commit to servo/servo that referenced this issue Jul 20, 2015
Make doc comments not truncated again.

`rustdoc --passes "collapse-docs unindent-comments"` doesn’t work is intended. It still generate HTML files that look alright at a glance, but all doc-comments are truncated to their first line for some reason I don’t understand.

See http://doc.servo.org/script/dom/index.html for example. The module documentation there is currently just “The implementation of the DOM.”, but clicking the [src] link shows a much larger doc-comment.

The correct invocation is to use `--passes` multiple times.

rust-lang/rust#15347 (comment)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6668)
<!-- Reviewable:end -->
@gnzlbg
Copy link
Contributor

gnzlbg commented Sep 8, 2016

Would it be possible to always generate a "Developer documentation" section for crates that contains the docs of private items alongside the documentation for the public API ? Both should obviously be separated, but I think it is valuable to have both, and for users to always be able to read both.

@KalitaAlexey
Copy link
Contributor

I agree with gnzlbg. Sometimes it is good to be able to search.

@Razican
Copy link
Contributor

Razican commented Sep 8, 2016

It's something that does not change how official documentation is handled, but that could help a bunch of us.

@gnzlbg
Copy link
Contributor

gnzlbg commented Sep 8, 2016

I don't see why it shouldn't be provided for the official documentation as well, the split between public API and developer documentation would jut need to be made very clear. Say somebody properly documented some internal standard library function, and I want to read its documentation because I think doing so is FUN.

Do I really need to read it online in the source file? Or do I need to get a copy and generate it my self?

Seems like unnecessary hassle and probably is contraproductive.

Having easier ways to get people to know the internals of libraries, including the standard library is_good_. It helps people become contributors, it gets more eyes on the libraries internals and their implementation, it finds bugs if someone goes "wait a second, that doesn't make sense", or improves performance if somebody else goes "why are they using this algorithm, this other one is way better!".

jrmuizel pushed a commit to jrmuizel/gecko-cinnabar that referenced this issue Jun 12, 2017
…/doc.servo.org/ (from servo:rustdoc-private); r=Manishearth

See rust-lang/rust#15347

Source-Repo: https://github.com/servo/servo
Source-Revision: a24783df4be2641afab3aa72626f9c59f90d49af
jrmuizel pushed a commit to jrmuizel/gecko-cinnabar that referenced this issue Jun 12, 2017
…o:untruncated-docs); r=Ms2ger

`rustdoc --passes "collapse-docs unindent-comments"` doesn’t work is intended. It still generate HTML files that look alright at a glance, but all doc-comments are truncated to their first line for some reason I don’t understand.

See http://doc.servo.org/script/dom/index.html for example. The module documentation there is currently just “The implementation of the DOM.”, but clicking the [src] link shows a much larger doc-comment.

The correct invocation is to use `--passes` multiple times.

rust-lang/rust#15347 (comment)

Source-Repo: https://github.com/servo/servo
Source-Revision: 685a44e1f5017849c341850696a77418bcc14011
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Sep 30, 2019
…/doc.servo.org/ (from servo:rustdoc-private); r=Manishearth

See rust-lang/rust#15347

Source-Repo: https://github.com/servo/servo
Source-Revision: a24783df4be2641afab3aa72626f9c59f90d49af

UltraBlame original commit: 17cd2249a7c28276e340ea269ab132cd671b3105
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Sep 30, 2019
…o:untruncated-docs); r=Ms2ger

`rustdoc --passes "collapse-docs unindent-comments"` doesn’t work is intended. It still generate HTML files that look alright at a glance, but all doc-comments are truncated to their first line for some reason I don’t understand.

See http://doc.servo.org/script/dom/index.html for example. The module documentation there is currently just “The implementation of the DOM.”, but clicking the [src] link shows a much larger doc-comment.

The correct invocation is to use `--passes` multiple times.

rust-lang/rust#15347 (comment)

Source-Repo: https://github.com/servo/servo
Source-Revision: 685a44e1f5017849c341850696a77418bcc14011

UltraBlame original commit: 0efcf0a5749de8797b5692794a7dfefbe64bb1d6
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Oct 1, 2019
…/doc.servo.org/ (from servo:rustdoc-private); r=Manishearth

See rust-lang/rust#15347

Source-Repo: https://github.com/servo/servo
Source-Revision: a24783df4be2641afab3aa72626f9c59f90d49af

UltraBlame original commit: 17cd2249a7c28276e340ea269ab132cd671b3105
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Oct 1, 2019
…o:untruncated-docs); r=Ms2ger

`rustdoc --passes "collapse-docs unindent-comments"` doesn’t work is intended. It still generate HTML files that look alright at a glance, but all doc-comments are truncated to their first line for some reason I don’t understand.

See http://doc.servo.org/script/dom/index.html for example. The module documentation there is currently just “The implementation of the DOM.”, but clicking the [src] link shows a much larger doc-comment.

The correct invocation is to use `--passes` multiple times.

rust-lang/rust#15347 (comment)

Source-Repo: https://github.com/servo/servo
Source-Revision: 685a44e1f5017849c341850696a77418bcc14011

UltraBlame original commit: 0efcf0a5749de8797b5692794a7dfefbe64bb1d6
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Oct 1, 2019
…/doc.servo.org/ (from servo:rustdoc-private); r=Manishearth

See rust-lang/rust#15347

Source-Repo: https://github.com/servo/servo
Source-Revision: a24783df4be2641afab3aa72626f9c59f90d49af

UltraBlame original commit: 17cd2249a7c28276e340ea269ab132cd671b3105
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Oct 1, 2019
…o:untruncated-docs); r=Ms2ger

`rustdoc --passes "collapse-docs unindent-comments"` doesn’t work is intended. It still generate HTML files that look alright at a glance, but all doc-comments are truncated to their first line for some reason I don’t understand.

See http://doc.servo.org/script/dom/index.html for example. The module documentation there is currently just “The implementation of the DOM.”, but clicking the [src] link shows a much larger doc-comment.

The correct invocation is to use `--passes` multiple times.

rust-lang/rust#15347 (comment)

Source-Repo: https://github.com/servo/servo
Source-Revision: 685a44e1f5017849c341850696a77418bcc14011

UltraBlame original commit: 0efcf0a5749de8797b5692794a7dfefbe64bb1d6
@wraithan
Copy link

Since this had more search priority than a lot of the other issues around this topic, putting a note here that in rust-lang/cargo#5543 an option cargo doc --document-private-items was added. Sorry if this is an unwelcome comment, just wanted others who search for "cargo doc private" to be able to find the solution.

@AlbertMarashi
Copy link

+1

As both a user and maintainer of library it would be valauable to have a full "developer" section.

I'd argue that many users would benefit from also understanding internals directly from docs, even if they are not going to directly use them.

@jyn514
Copy link
Member

jyn514 commented Dec 14, 2021

Please do not leave comments on this issue - you can document private definitions with --document-private-items, this issue isn't meant to track all issues related to private items. If you'd like a better UI for it that distinguishes private and public items, feel free to comment on #68022 with the UI you think would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests