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

TRPL: Documentation #22549

Merged
merged 1 commit into from
Mar 7, 2015
Merged

TRPL: Documentation #22549

merged 1 commit into from
Mar 7, 2015

Conversation

steveklabnik
Copy link
Member

This chapter covers writing documentation in depth.

Fixes #4361
Fixes #12862
Fixes #14070
Fixes #14967

@rust-highfive
Copy link
Collaborator

r? @pcwalton

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

@Manishearth
Copy link
Member

If doctests pass for this locally, let me know (post review) and I'll include it in the current rollup.

@steveklabnik
Copy link
Member Author

They all pass for me:

$ rustdoc --test src/doc/trpl/documentation.md 

running 32 tests
test _0 ... ignored
test _10 ... ok
test _1 ... ok
test _11 ... ok
test _12 ... ok
test _13 ... ok
test _16 ... ok
test _14 ... ok
test _15 ... ok
test _2 ... ignored
test _17 ... ok
test _19 ... ok
test _18 ... ok
test _20 ... ok
test _21 ... ok
test _22 ... ok
test _23 ... ok
test _24 ... ok
test _25 ... ok
test _29 ... ignored
test _27 ... ok
test _30 ... ignored
test _28 ... ok
test _26 ... ok
test _3 ... ok
test _31 ... ok
test _5 ... ok
test _4 ... ok
test _6 ... ok
test _7 ... ok
test _8 ... ok
test _9 ... ok

test result: ok. 28 passed; 0 failed; 4 ignored; 0 measured

@Manishearth
Copy link
Member

Awesome, thanks. Will rollup when this gets an r+

struct Whizbang;
~~~
Rust keeps track of these comments, and uses them when generating
documentation. This is important when documenting things like enums:
Copy link
Member

Choose a reason for hiding this comment

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

This enum example seems to be placed very prominently for something of an edge case? Maybe I'm missing how often it occurs.

Also, it's not not clear to me what "this" is and how it interacts with the position of doc-comments.

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've heard people ask about it two or three times, they're not used to comments being anything but 'ignore this'

@huonw
Copy link
Member

huonw commented Feb 19, 2015

Is the name "Rustdoc" or "rustdoc"?

@steveklabnik
Copy link
Member Author

rustdoc

@steveklabnik
Copy link
Member Author

@huonw largely updated, one or two questions remaining

@steveklabnik
Copy link
Member Author

@huonw ping!

Documentation comments are written in Markdown.

Rust keeps track of these comments, and uses them when generating
documentation. This is important when documenting things like enums:
Copy link
Member

Choose a reason for hiding this comment

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

"document"/"documentation" has been said a lot in the three paragraphs from line 35 to this one; maybe things could be tweaked to be a little more streamlined?

Copy link
Member

Choose a reason for hiding this comment

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

Also, I'm still unsure what "this" is here? (It's not clear to me why rust keeping track of the comments is important for enums in particular.)

Copy link
Member Author

Choose a reason for hiding this comment

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

"This" refers to the previous sentence: Rust understanding comments, rather than just ignoring them. I don't think most languages have documentation-specific comments, this behavior is different than people expect.

only shows the part you care about.

```
/// ```should_fail
Copy link
Member

Choose a reason for hiding this comment

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

cc #21824

(The description sentence below can probably be updated for that too.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh, the description describes exactly why i left it as fail :) Anyway, fixed

@steveklabnik
Copy link
Member Author

@huonw updated for everything but the panic change. Maybe you could suggest some language you're happy with? :) I'd like to get this wrapped up!

@huonw
Copy link
Member

huonw commented Mar 4, 2015

Unrecoverable misuses of a function (i.e. programming errors) in Rust are usually indicated by panics, which kill the whole current thread at the very least. If your function has a non-trivial contract like this, that is detected/enforced by panics, documenting it is very important:

This chapter covers writing documentation in depth.

Fixes rust-lang#4361
Fixes rust-lang#12862
Fixes rust-lang#14070
Fixes rust-lang#14967
@steveklabnik
Copy link
Member Author

@huonw: sounds great. I've fixed that, squashed, and rebased.

@huonw
Copy link
Member

huonw commented Mar 7, 2015

@bors r+

@bors
Copy link
Contributor

bors commented Mar 7, 2015

@bors r=huonw 977d789

@bors
Copy link
Contributor

bors commented Mar 7, 2015

⌛ Testing commit 977d789 with merge 36cd65f...

bors added a commit that referenced this pull request Mar 7, 2015
This chapter covers writing documentation in depth.

Fixes #4361
Fixes #12862
Fixes #14070
Fixes #14967
@bors bors merged commit 977d789 into rust-lang:master Mar 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants