-
Notifications
You must be signed in to change notification settings - Fork 13.3k
The Rustdoc book #42378
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
The Rustdoc book #42378
Conversation
r? @frewsxcv (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start. Left a few comments.
FTR, I'd really like the passes chapter to contain the needed args to render all items, even private ones. (I'm pretty sure cargo doc -- --no-defaults --passes collapse-docs --passes unindent-comments
worked once)
like this: | ||
|
||
```text | ||
rustdoc 1.y.0 (hash date) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hash date
? Never heard of her. (I wouldn't try to make the output generic but give concrete, current outputs. People can easily see the pattern themselves and I'm not sure we want to guarantee this will always look like this.)
For example, with `--version`: | ||
|
||
```text | ||
$ rustdoc --version -v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks weird. Either -v -V
or --verbose --version
@@ -0,0 +1,358 @@ | |||
# Command-line arguments | |||
|
|||
Here's the list of arguments you can pass to `rustdoc`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a warning that these do not work with cargo doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they dont?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope:
$cargo doc --passes strip-priv-imports
error: Unknown flag: '--passes
…
I think it was once possible to do cargo doc -- args…
but with latest stable:
$ cargo doc -- --passes strip-priv-imports
error: Invalid arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, you'd have to use RUSTDOCFLAGS for this, much like RUSTFLAGS for arguments to rustc.
$ cargo doc | ||
``` | ||
|
||
Internally, this calls out to `rustdoc` like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internally*
* you can see this with cargo doc --verbose
Yup, agreed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking forward to this!
ignore my previous approval, that was an accident
as the `.rs` file. `--crate-name` lets you override this assumption with | ||
whatever name you choose. | ||
|
||
stable(optmulti("L", "library-path", "directory to add to crate search path", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also looks like these stable(...)
things are used elsewhere in this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i made this page by copy/pasting the source, and must have forgotten to remove these lines 😓
@@ -0,0 +1,3 @@ | |||
# Documentation tests | |||
|
|||
Coming soon! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intending to ship this with the "Coming soon!" test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy shipping this at whatever point, this chapter should be easy to knock out though
@@ -0,0 +1,127 @@ | |||
# What is rustdoc? | |||
|
|||
The standard Rust distribution ships with a tool called `rustdoc`. It's job is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/It's/Its
Let's give it a try! Let's create a new project with Cargo: | ||
|
||
```bash | ||
$ cargo new docs -- lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this supposed to be --lib
? isn't this the default for cargo new
?
We'll have some generated documentation. Open up `doc/docs/index.html` and | ||
check it out! It should show a link to the `foo` function's page, which | ||
is located at `doc/docs/fn.foo.html`. On that page, you'll see the "foo is | ||
a function" we put inside the documentation comment in our crate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could also maybe rustdoc --open
here, but not mandatory by any means
|
||
```rust | ||
/// foo is a function | ||
fn foo() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be pub fn
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes 😓
I've pushed up a commit that should address all rustdoc feedback so far. |
I think I would like to ship this as-is (that is, with these contents; I haven't made the build actually build the book yet), and fill out the rest later, but if everyone else wants me to finish it before merging, that's fine as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me unless you have more changes
@bors: r=frewsxcv nope; at least not for now. |
📌 Commit 9331f04 has been approved by |
The Rustdoc book A work-in-progress start for docs for rustdoc. This doesn't actually generate the docs yet; I wanted to open this PR to get feedback on this approach, the chapters headings themselves, and to see if anyone wanted to help fill in the ones that aren't done yet. Start of #42322. /cc @rust-lang/dev-tools @rust-lang/docs
☀️ Test successful - status-appveyor, status-travis |
A work-in-progress start for docs for rustdoc.
This doesn't actually generate the docs yet; I wanted to open this PR to get feedback on this approach, the chapters headings themselves, and to see if anyone wanted to help fill in the ones that aren't done yet.
Start of #42322.
/cc @rust-lang/dev-tools @rust-lang/docs