61e8cc571d
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 |
||
---|---|---|
.. | ||
book@9cffbeabec | ||
edition-guide@aa0022c875 | ||
embedded-book@9e656ead82 | ||
man | ||
nomicon@f1ff93b668 | ||
reference@41493ffce5 | ||
rust-by-example@2ce92beabb | ||
rustc | ||
rustc-guide@344c4e437b | ||
rustdoc | ||
unstable-book | ||
complement-design-faq.md | ||
complement-lang-faq.md | ||
complement-project-faq.md | ||
favicon.inc | ||
footer.inc | ||
full-toc.inc | ||
grammar.md | ||
guide-crates.md | ||
guide-error-handling.md | ||
guide-ffi.md | ||
guide-macros.md | ||
guide-ownership.md | ||
guide-plugins.md | ||
guide-pointers.md | ||
guide-strings.md | ||
guide-tasks.md | ||
guide-testing.md | ||
guide-unsafe.md | ||
guide.md | ||
index.md | ||
intro.md | ||
not_found.md | ||
reference.md | ||
rust.css | ||
rust.md | ||
rustc-ux-guidelines.md | ||
rustdoc.md | ||
tutorial.md | ||
version_info.html.template |