]> git.lizzy.rs Git - rust.git/commitdiff
Add documentation for --show-coverage option
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Thu, 20 Aug 2020 19:26:42 +0000 (21:26 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Thu, 20 Aug 2020 19:26:57 +0000 (21:26 +0200)
src/doc/rustdoc/src/unstable-features.md

index d16c2a9d0342c71f4512a02c4db1a1dab0d5abea..4e407c19b4128424e326663faeb7a1975a21f1a2 100644 (file)
@@ -467,3 +467,36 @@ $ rustdoc src/lib.rs -Z unstable-options --runtool valgrind
 ```
 
 Another use case would be to run a test inside an emulator, or through a Virtual Machine.
+
+### `--show-coverage`: get statistics about code documentation coverage
+
+This option allows you to get a nice overview over your code documentation coverage, including both
+doc-comments and code examples in the doc-comments. Example:
+
+```bash
+$ rustdoc src/lib.rs -Z unstable-options --show-coverage
++-------------------------------------+------------+------------+------------+------------+
+| File                                | Documented | Percentage |   Examples | Percentage |
++-------------------------------------+------------+------------+------------+------------+
+| lib.rs                              |          4 |     100.0% |          1 |      25.0% |
++-------------------------------------+------------+------------+------------+------------+
+| Total                               |          4 |     100.0% |          1 |      25.0% |
++-------------------------------------+------------+------------+------------+------------+
+```
+
+You can also use this option with the `--output-format` one:
+
+```bash
+$ rustdoc src/lib.rs -Z unstable-options --show-coverage --output-format json
+{"lib.rs":{"total":4,"with_docs":4,"total_examples":4,"with_examples":1}}
+```
+
+To be noted: the computation of code examples follows these rules:
+
+1. These items aren't accounted by default:
+  * struct/union field
+  * enum variant
+  * constant
+  * static
+  * typedef
+2. If one of the previously listed items has a code example, then it'll be counted.