Skip to content

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

Merged
merged 5 commits into from
Jun 7, 2017
Merged

The Rustdoc book #42378

merged 5 commits into from
Jun 7, 2017

Conversation

steveklabnik
Copy link
Member

@steveklabnik steveklabnik commented Jun 2, 2017

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

@rust-highfive
Copy link
Contributor

r? @frewsxcv

(rust_highfive has picked a reviewer for you, use r? to override)

Copy link
Member

@killercup killercup left a 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)
Copy link
Member

@killercup killercup Jun 2, 2017

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
Copy link
Member

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`:
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they dont?

Copy link
Member

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.

Copy link
Member

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:
Copy link
Member

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

@steveklabnik
Copy link
Member Author

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)

Yup, agreed

@shepmaster shepmaster added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 2, 2017
Copy link
Member

@frewsxcv frewsxcv left a 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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this doing?

Copy link
Member

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

Copy link
Member Author

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!
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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
Copy link
Member

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.
Copy link
Member

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() {}
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes 😓

@steveklabnik
Copy link
Member Author

I've pushed up a commit that should address all rustdoc feedback so far.

@steveklabnik
Copy link
Member Author

steveklabnik commented Jun 5, 2017

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.

Copy link
Member

@frewsxcv frewsxcv left a 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

@steveklabnik
Copy link
Member Author

@bors: r=frewsxcv

nope; at least not for now.

@bors
Copy link
Collaborator

bors commented Jun 7, 2017

📌 Commit 9331f04 has been approved by frewsxcv

@bors
Copy link
Collaborator

bors commented Jun 7, 2017

⌛ Testing commit 9331f04 with merge f062832...

bors added a commit that referenced this pull request Jun 7, 2017
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
@bors
Copy link
Collaborator

bors commented Jun 7, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: frewsxcv
Pushing f062832 to master...

@bors bors merged commit 9331f04 into rust-lang:master Jun 7, 2017
@steveklabnik steveklabnik deleted the rustdoc-docs branch October 25, 2017 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants