rust/src/doc
Mazdak Farrokhzad 61e8cc571d
Rollup merge of #58626 - QuietMisdreavus:doc-coverage, r=GuillaumeGomez
rustdoc: add option to calculate "documentation coverage"

This PR adds a new flag to rustdoc, `--show-coverage`. When passed, this flag will make rustdoc count the number of items in a crate with documentation instead of generating docs. This count will be output as a table of each file in the crate, like this (when run on my crate `egg-mode`):

```
+-------------------------------------+------------+------------+------------+
| File                                | Documented |      Total | Percentage |
+-------------------------------------+------------+------------+------------+
| src/auth.rs                         |         16 |         16 |     100.0% |
| src/common/mod.rs                   |          1 |          1 |     100.0% |
| src/common/response.rs              |          9 |          9 |     100.0% |
| src/cursor.rs                       |         24 |         24 |     100.0% |
| src/direct/fun.rs                   |          6 |          6 |     100.0% |
| src/direct/mod.rs                   |         41 |         41 |     100.0% |
| src/entities.rs                     |         50 |         50 |     100.0% |
| src/error.rs                        |         27 |         27 |     100.0% |
| src/lib.rs                          |          1 |          1 |     100.0% |
| src/list/fun.rs                     |         19 |         19 |     100.0% |
| src/list/mod.rs                     |         22 |         22 |     100.0% |
| src/media/mod.rs                    |         27 |         27 |     100.0% |
| src/place/fun.rs                    |          8 |          8 |     100.0% |
| src/place/mod.rs                    |         35 |         35 |     100.0% |
| src/search.rs                       |         26 |         26 |     100.0% |
| src/service.rs                      |         74 |         74 |     100.0% |
| src/stream/mod.rs                   |         49 |         49 |     100.0% |
| src/tweet/fun.rs                    |         15 |         15 |     100.0% |
| src/tweet/mod.rs                    |         73 |         73 |     100.0% |
| src/user/fun.rs                     |         24 |         24 |     100.0% |
| src/user/mod.rs                     |         87 |         87 |     100.0% |
+-------------------------------------+------------+------------+------------+
| Total                               |        634 |        634 |     100.0% |
+-------------------------------------+------------+------------+------------+
```

Trait implementations are not counted because by default they "inherit" the docs from the trait, even though an impl can override those docs. Similarly, inherent impl blocks are not counted at all, because for the majority of cases such docs are not useful. (The usual pattern for inherent impl blocks is to throw all the methods on a type into a single impl block. Any docs you would put on that block would be better served on the type itself.)

In addition, `--show-coverage` can be combined with `--document-private-items` to get the coverage counts for everything in the crate, not just public items.

The coverage calculation is implemented as a late pass and two new sets of passes which strip out most of the work that rustdoc otherwise does when generating docs. The is because after the new pass is executed, rustdoc immediately closes instead of going on to generate documentation.

Many examples of coverage calculations have been included as `rustdoc-ui` tests.

r? @rust-lang/rustdoc
2019-03-09 17:18:13 +01:00
..
book@9cffbeabec Update books 2019-03-08 12:25:36 -08:00
edition-guide@aa0022c875 Update books 2019-03-08 12:25:36 -08:00
embedded-book@9e656ead82 Update books 2019-03-08 12:25:36 -08:00
man Remove references to AUTHORS.txt file 2018-07-30 07:47:12 +02:00
nomicon@f1ff93b668 Update books 2019-03-08 12:25:36 -08:00
reference@41493ffce5 Update books 2019-03-08 12:25:36 -08:00
rust-by-example@2ce92beabb update books 2018-11-20 21:22:31 -05:00
rustc Rollup merge of #55632 - ollie27:deny_overflowing_literals, r=Centril 2019-02-25 11:42:18 +01:00
rustc-guide@344c4e437b Fix failing tidy (line endings on Windows) 2018-12-02 00:19:06 +03:00
rustdoc tweak docs for rustdoc's --show-coverage 2019-02-28 16:13:55 -06:00
unstable-book Add c_variadic to the unstable-book 2019-02-27 10:21:45 -05:00
complement-design-faq.md
complement-lang-faq.md
complement-project-faq.md
favicon.inc
footer.inc
full-toc.inc
grammar.md Rollup merge of #50791 - bstrie:null, r=QuietMisdreavus 2018-05-17 13:51:25 -06:00
guide-crates.md
guide-error-handling.md Convert old doc links to current edition 2019-02-13 14:39:25 +00:00
guide-ffi.md
guide-macros.md
guide-ownership.md Convert old doc links to current edition 2019-02-13 14:39:25 +00:00
guide-plugins.md
guide-pointers.md Convert old doc links to current edition 2019-02-13 14:39:25 +00:00
guide-strings.md
guide-tasks.md
guide-testing.md Convert old doc links to current edition 2019-02-13 14:39:25 +00:00
guide-unsafe.md
guide.md
index.md Add Rustlings to the doc index 2019-02-05 15:32:59 +01:00
intro.md
not_found.md dro -> duckduckgo 2018-10-05 08:52:44 -07:00
reference.md
rust.css remove remaining copyright headers 2018-12-28 21:50:33 +01:00
rust.md
rustc-ux-guidelines.md Rename trans to codegen everywhere. 2018-05-17 15:08:30 +03:00
rustdoc.md
tutorial.md Update tutorial.md 2018-05-17 12:25:24 -07:00
version_info.html.template