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 rustdoc doc #66267

Merged
merged 2 commits into from
Nov 12, 2019
Merged

Add rustdoc doc #66267

merged 2 commits into from
Nov 12, 2019

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez force-pushed the add-rustdoc-doc branch 2 times, most recently from 0543358 to 8e41089 Compare November 10, 2019 11:18
Comment on lines 3 to 6
This chapter intends to explain how to not only write documentation but also on
how to write **good** ones. But something to keep in mind when writing
documentation: you write as much for others as for you so it's important to be
clear! The more the better. If an item is public, then it should be documented.
Copy link
Contributor

Choose a reason for hiding this comment

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

Multiline suggestions don't work, but I'd suggest:

This chapter covers not only how to write documentation but specifically
how to write **good** documentation.  Something to keep in mind when
writing documentation is that your audience is not just yourself but others
who simply don't have the context you do.  It is important to be as clear
as you can, and as complete as possible.  As a rule of thumb, the more
documentation you write for your crate, the better.  If an item is public
then it should be documented.


## Basic structure

If possible, each item's documentation should try to follow this structure:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
If possible, each item's documentation should try to follow this structure:
It is recommended that each item's documentation follows this basic structure:

Comment on lines 22 to 24
Pretty simple but important to follow. The code example is really important:
it might help your users to have a better understanding of what an item is
used for and/or how to use it.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's risky to describe documentation as 'simple' to produce. Perhaps:

This basic structure should be straightforward to follow when writing your
documentation and, while you might think that a code example is trivial,
the examples are really important because they can help your users to
understand what an item is, how it is used, and for what purpose it exists.

used for and/or how to use it.

Let's see an example coming from the [standard library] by taking a look at the
[env::args] function:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[env::args] function:
[`std::env::args()`][env::args] function:

Comment on lines 67 to 68
The documentation is using the [commonmark markdown specification]. You might be
interested into taking a look at their website to see what's possible to do!
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I think it's important to make it clear that rustdoc uses commonmark, and if possible some of the text about taking a look should try and link to the requisite part of the commonmark site. I also dislike the ! 😄


Here is the list of the lints provided by `rustdoc`:

## intra_doc_link_resolution_failure
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we label this one "nightly only" ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also should we say this is warn-by-default?

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 for both!

@GuillaumeGomez
Copy link
Member Author

Updated.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-11-10T13:07:10.9486773Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-11-10T13:07:10.9760687Z ##[command]git config gc.auto 0
2019-11-10T13:07:10.9830879Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-11-10T13:07:10.9903002Z ##[command]git config --get-all http.proxy
2019-11-10T13:07:11.6027166Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/66267/merge:refs/remotes/pull/66267/merge
---
2019-11-10T14:05:15.9948576Z .................................................................................................... 1500/9220
2019-11-10T14:05:22.0146647Z .................................................................................................... 1600/9220
2019-11-10T14:05:31.2021249Z .................................................................................................i.. 1700/9220
2019-11-10T14:05:39.4949715Z .................................................................................................... 1800/9220
2019-11-10T14:05:46.0034007Z .................................................................................iiiii.............. 1900/9220
2019-11-10T14:06:06.7355468Z .................................................................................................... 2100/9220
2019-11-10T14:06:09.0970406Z .................................................................................................... 2200/9220
2019-11-10T14:06:11.6540476Z .................................................................................................... 2300/9220
2019-11-10T14:06:25.0075256Z .................................................................................................... 2400/9220
---
2019-11-10T14:09:11.1639992Z ...........................................................................i...............i........ 4700/9220
2019-11-10T14:09:19.3262693Z .................................................................................................... 4800/9220
2019-11-10T14:09:27.6719214Z .................................................................................................... 4900/9220
2019-11-10T14:09:32.7936426Z .................................................................................................... 5000/9220
2019-11-10T14:09:43.9101757Z .............................................................................ii.ii...........i...... 5100/9220
2019-11-10T14:09:52.4173821Z ............i....................................................................................... 5300/9220
2019-11-10T14:10:02.5453377Z .................................................................................................... 5400/9220
2019-11-10T14:10:08.8862969Z ...........................................................i........................................ 5500/9220
2019-11-10T14:10:15.8911223Z .................................................................................................... 5600/9220
2019-11-10T14:10:15.8911223Z .................................................................................................... 5600/9220
2019-11-10T14:10:25.4897832Z .................................................................................................... 5700/9220
2019-11-10T14:10:32.6340583Z ............................................ii...i..ii...........i.................................. 5800/9220
2019-11-10T14:10:54.5400573Z .................................................................................................... 6000/9220
2019-11-10T14:11:01.9440131Z .................................................................................................... 6100/9220
2019-11-10T14:11:01.9440131Z .................................................................................................... 6100/9220
2019-11-10T14:11:07.5197505Z ...............................................................i..ii................................ 6200/9220
2019-11-10T14:11:35.2054367Z .................................................................................................... 6400/9220
2019-11-10T14:11:37.1536053Z ...............................i.................................................................... 6500/9220
2019-11-10T14:11:39.3471944Z .................................................................................................... 6600/9220
2019-11-10T14:11:41.6988771Z ...............i.................................................................................... 6700/9220
---
2019-11-10T14:16:44.0285621Z  finished in 5.547
2019-11-10T14:16:44.0477206Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-11-10T14:16:44.2224284Z 
2019-11-10T14:16:44.2224547Z running 156 tests
2019-11-10T14:16:46.9678012Z iiii....iii......iii..iiii...i.............................i..i..................i....i...........ii 100/156
2019-11-10T14:16:48.8254521Z .i.i..iiii..............i.........iii.i.........ii......
2019-11-10T14:16:48.8259014Z 
2019-11-10T14:16:48.8260843Z  finished in 4.778
2019-11-10T14:16:48.8457312Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-11-10T14:16:49.0211819Z 
---
2019-11-10T14:16:50.8751663Z  finished in 2.029
2019-11-10T14:16:50.8925232Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-11-10T14:16:51.0467673Z 
2019-11-10T14:16:51.0467947Z running 9 tests
2019-11-10T14:16:51.0468849Z iiiiiiiii
2019-11-10T14:16:51.0469265Z 
2019-11-10T14:16:51.0469313Z  finished in 0.154
2019-11-10T14:16:51.0652054Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-11-10T14:16:51.2390029Z 
---
2019-11-10T14:17:09.8956452Z  finished in 18.830
2019-11-10T14:17:09.9146243Z Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-11-10T14:17:10.0891079Z 
2019-11-10T14:17:10.0891248Z running 123 tests
2019-11-10T14:17:33.9192151Z .iiiii...i.....i..i...i..i.i.i..i.ii..i.i.....i..i....ii..........iiii..........i...ii...i.......ii. 100/123
2019-11-10T14:17:38.4714354Z i.i.i......iii.i.....ii
2019-11-10T14:17:38.4715844Z 
2019-11-10T14:17:38.4720617Z  finished in 28.557
2019-11-10T14:17:38.4729858Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-11-10T14:17:38.4731740Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2019-11-10T14:29:12.5904372Z 
2019-11-10T14:29:12.5905590Z    Doc-tests core
2019-11-10T14:29:17.2883438Z 
2019-11-10T14:29:17.2884517Z running 2418 tests
2019-11-10T14:29:27.5713577Z ......iiiii......................................................................................... 100/2418
2019-11-10T14:29:37.7122614Z ................................................................................ii.................. 200/2418
2019-11-10T14:30:01.2445083Z ..i................................................................................................. 400/2418
2019-11-10T14:30:01.2445083Z ..i................................................................................................. 400/2418
2019-11-10T14:30:11.1578883Z ..................................................i..i.................iiii......................... 500/2418
2019-11-10T14:30:30.4562305Z .................................................................................................... 700/2418
2019-11-10T14:30:40.1941229Z .................................................................................................... 800/2418
2019-11-10T14:30:50.2231750Z .................................................................................................... 900/2418
2019-11-10T14:31:00.0883383Z .................................................................................................... 1000/2418
---
2019-11-10T14:35:00.2992338Z 
2019-11-10T14:35:00.2992591Z running 1000 tests
2019-11-10T14:35:20.1192357Z i................................................................................................... 100/1000
2019-11-10T14:35:30.9237610Z .................................................................................................... 200/1000
2019-11-10T14:35:38.5755187Z ...................iii......i......i...i......i..................................................... 300/1000
2019-11-10T14:35:43.6848722Z .................................................................................................... 400/1000
2019-11-10T14:35:50.9268077Z ...........................................i..i.................................ii.................. 500/1000
2019-11-10T14:36:04.3268529Z .................................................................................................... 700/1000
2019-11-10T14:36:04.3268529Z .................................................................................................... 700/1000
2019-11-10T14:36:11.5067852Z ..........................iiii...................................................................... 800/1000
2019-11-10T14:36:26.4329308Z .................................................................................................... 900/1000
2019-11-10T14:36:33.7201143Z ................................................iiii................................................ 1000/1000
2019-11-10T14:36:33.7201994Z test result: ok. 980 passed; 0 failed; 20 ignored; 0 measured; 0 filtered out
2019-11-10T14:36:33.7202414Z 
2019-11-10T14:36:33.7262376Z  finished in 185.336
2019-11-10T14:36:33.7277154Z Testing term stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2019-11-10T14:54:00.3089228Z  finished in 39.135
2019-11-10T14:54:00.3435728Z Check compiletest suite=run-make-fulldeps mode=run-make (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-11-10T14:54:00.5367722Z 
2019-11-10T14:54:00.5368036Z running 203 tests
2019-11-10T14:54:29.7914951Z ....................i...ii...................................................................i...... 100/203
2019-11-10T14:55:04.4620917Z .................................iiii.......i...........iiii.iii.................................... 200/203
2019-11-10T14:55:04.9414235Z i..
2019-11-10T14:55:04.9418221Z 
2019-11-10T14:55:04.9418380Z  finished in 64.598
2019-11-10T14:55:04.9426208Z doc tests for: /checkout/src/doc/rustdoc/src/command-line-arguments.md
2019-11-10T14:55:04.9501951Z doc tests for: /checkout/src/doc/rustdoc/src/documentation-tests.md
---
2019-11-10T14:55:06.3681245Z ---- /checkout/src/doc/rustdoc/src/lints.md - Lints (line 6) stdout ----
2019-11-10T14:55:06.3681430Z error: missing documentation for crate
2019-11-10T14:55:06.3681830Z  --> /checkout/src/doc/rustdoc/src/lints.md:5:1
2019-11-10T14:55:06.3682278Z   |
2019-11-10T14:55:06.3682422Z 1 | / #![allow(unused)]
2019-11-10T14:55:06.3682588Z 2 | | #![allow(missing_docs)] // allowing the lint, no message
2019-11-10T14:55:06.3682730Z 3 | | #![warn(missing_docs)] // warn if there is missing docs
2019-11-10T14:55:06.3682891Z 4 | | #![deny(missing_docs)] // rustdoc will fail if there is missing docs
2019-11-10T14:55:06.3683032Z 5 | | fn main() {
2019-11-10T14:55:06.3683335Z 7 | | }
2019-11-10T14:55:06.3683468Z   | |_^
2019-11-10T14:55:06.3683597Z   |
2019-11-10T14:55:06.3683750Z note: lint level defined here
2019-11-10T14:55:06.3683750Z note: lint level defined here
2019-11-10T14:55:06.3684165Z  --> /checkout/src/doc/rustdoc/src/lints.md:8:9
2019-11-10T14:55:06.3684343Z   |
2019-11-10T14:55:06.3684504Z 4 | #![deny(missing_docs)] // rustdoc will fail if there is missing docs
2019-11-10T14:55:06.3684762Z 
2019-11-10T14:55:06.3684915Z error: aborting due to previous error
2019-11-10T14:55:06.3685035Z 
2019-11-10T14:55:06.3685400Z Couldn't compile the test.
---
2019-11-10T14:55:06.3749196Z   local time: Sun Nov 10 14:55:06 UTC 2019
2019-11-10T14:55:06.4010073Z   network time: Sun, 10 Nov 2019 14:55:06 GMT
2019-11-10T14:55:06.4012396Z == end clock drift check ==
2019-11-10T14:55:12.9507677Z 
2019-11-10T14:55:12.9654477Z ##[error]Bash exited with code '1'.
2019-11-10T14:55:12.9699413Z ##[section]Starting: Checkout
2019-11-10T14:55:12.9701411Z ==============================================================================
2019-11-10T14:55:12.9701491Z Task         : Get sources
2019-11-10T14:55:12.9701542Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

This looks great! ❤️

Comment on lines +90 to +91
This lint is **allowed by default**. It detects documentation tests when they
are on a private item. For example:
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this could have a brief comment explaining why someone might want to use it? From what I understand, private doc tests are tested, it's just that they do not have access to private items, so its usefulness is limited, is that correct?

My initial reading, I was thinking maybe private doc tests were not tested or something.

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 is not where we should give this explanation from my point of view.

Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

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

Looking pretty solid

writing documentation is that your audience is not just yourself but others
who simply don't have the context you do. It is important to be as clear
as you can, and as complete as possible. As a rule of thumb, the more
documentation you write for your crate, the better. If an item is public
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
documentation you write for your crate, the better. If an item is public
documentation you write for your crate the better. If an item is public

Looks like I left a spurious comma in before

how to write **good** documentation. Something to keep in mind when
writing documentation is that your audience is not just yourself but others
who simply don't have the context you do. It is important to be as clear
as you can, and as complete as possible. As a rule of thumb, the more
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
as you can, and as complete as possible. As a rule of thumb, the more
as you can, and as complete as possible. As a rule of thumb: the more

Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

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

I'm happy with this as a first step on the way to good "how to write docs" section. 👍

@GuillaumeGomez
Copy link
Member Author

Then let's get it in!

@bors: r=kinnison rollup

@bors
Copy link
Contributor

bors commented Nov 11, 2019

📌 Commit 528b059 has been approved by kinnison

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 11, 2019
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Nov 12, 2019
bors added a commit that referenced this pull request Nov 12, 2019
Rollup of 11 pull requests

Successful merges:

 - #65965 (Clean up librustc_typeck error_codes file)
 - #66230 (remove vestigial comments referring to defunct numeric trait hierarchy)
 - #66241 (bump openssl version)
 - #66257 (Drop long-section-names linker workaround for windows-gnu)
 - #66263 (make the error message more readable)
 - #66267 (Add rustdoc doc)
 - #66276 (Move lock into CodeStats)
 - #66278 (Fix error message about exported symbols from proc-macro crates)
 - #66280 (Fix HashSet::union performance)
 - #66299 (support issue = "none" in unstable attributes )
 - #66309 (Tiny cleanup to size assertions)

Failed merges:

r? @ghost
@bors bors merged commit 528b059 into rust-lang:master Nov 12, 2019
@GuillaumeGomez GuillaumeGomez deleted the add-rustdoc-doc branch November 12, 2019 22:41
Centril added a commit to Centril/rust that referenced this pull request Mar 23, 2020
…vel-doc, r=Dylan-DPC

Add lint when no doc is present at the crate-level

Follow-up of rust-lang#66267.

r? @kinnison
Centril added a commit to Centril/rust that referenced this pull request Mar 23, 2020
…vel-doc, r=Dylan-DPC

Add lint when no doc is present at the crate-level

Follow-up of rust-lang#66267.

r? @kinnison
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 28, 2020
…l-doc, r=Dylan-DPC

Add lint when no doc is present at the crate-level

Follow-up of rust-lang#66267.

r? @kinnison
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants