Skip to content

Commit d108bd5

Browse files
Add documentation for --show-coverage option
1 parent 9c254c1 commit d108bd5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/doc/rustdoc/src/unstable-features.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,3 +467,36 @@ $ rustdoc src/lib.rs -Z unstable-options --runtool valgrind
467467
```
468468

469469
Another use case would be to run a test inside an emulator, or through a Virtual Machine.
470+
471+
### `--show-coverage`: get statistics about code documentation coverage
472+
473+
This option allows you to get a nice overview over your code documentation coverage, including both
474+
doc-comments and code examples in the doc-comments. Example:
475+
476+
```bash
477+
$ rustdoc src/lib.rs -Z unstable-options --show-coverage
478+
+-------------------------------------+------------+------------+------------+------------+
479+
| File | Documented | Percentage | Examples | Percentage |
480+
+-------------------------------------+------------+------------+------------+------------+
481+
| lib.rs | 4 | 100.0% | 1 | 25.0% |
482+
+-------------------------------------+------------+------------+------------+------------+
483+
| Total | 4 | 100.0% | 1 | 25.0% |
484+
+-------------------------------------+------------+------------+------------+------------+
485+
```
486+
487+
You can also use this option with the `--output-format` one:
488+
489+
```bash
490+
$ rustdoc src/lib.rs -Z unstable-options --show-coverage --output-format json
491+
{"lib.rs":{"total":4,"with_docs":4,"total_examples":4,"with_examples":1}}
492+
```
493+
494+
To be noted: the computation of code examples follows these rules:
495+
496+
1. These items aren't accounted by default:
497+
* struct/union field
498+
* enum variant
499+
* constant
500+
* static
501+
* typedef
502+
2. If one of the previously listed items has a code example, then it'll be counted.

0 commit comments

Comments
 (0)