@@ -348,6 +348,18 @@ Using this flag looks like this:
348
348
$ rustdoc src/lib.rs -Z unstable-options --show-coverage
349
349
```
350
350
351
+ It generates something like this:
352
+
353
+ ``` bash
354
+ +-------------------------------------+------------+------------+------------+------------+
355
+ | File | Documented | Percentage | Examples | Percentage |
356
+ +-------------------------------------+------------+------------+------------+------------+
357
+ | lib.rs | 4 | 100.0% | 1 | 25.0% |
358
+ +-------------------------------------+------------+------------+------------+------------+
359
+ | Total | 4 | 100.0% | 1 | 25.0% |
360
+ +-------------------------------------+------------+------------+------------+------------+
361
+ ```
362
+
351
363
If you want to determine how many items in your crate are documented, pass this flag to rustdoc.
352
364
When it receives this flag, it will count the public items in your crate that have documentation,
353
365
and print out the counts and a percentage instead of generating docs.
@@ -367,17 +379,25 @@ Some methodology notes about what rustdoc counts in this metric:
367
379
Public items that are not documented can be seen with the built-in ` missing_docs ` lint. Private
368
380
items that are not documented can be seen with Clippy's ` missing_docs_in_private_items ` lint.
369
381
370
- ### ` -w ` / ` --output-format ` : output format
382
+ Calculating code examples follows these rules:
371
383
372
- When using
373
- [ ` --show-coverage ` ] ( https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#--show-coverage-get-statistics-about-code-documentation-coverage ) ,
374
- passing ` --output-format json ` will display the coverage information in JSON format. For example,
375
- here is the JSON for a file with one documented item and one undocumented item:
384
+ 1 . These items aren't accounted by default:
385
+ * struct/union field
386
+ * enum variant
387
+ * constant
388
+ * static
389
+ * typedef
390
+ 2 . If one of the previously listed items has a code example, then it'll be counted.
391
+
392
+ #### JSON output
393
+
394
+ When using ` --output-format json ` with this option, it will display the coverage information in
395
+ JSON format. For example, here is the JSON for a file with one documented item and one
396
+ undocumented item:
376
397
377
398
``` rust
378
399
/// This item has documentation
379
400
pub fn foo () {}
380
-
381
401
pub fn no_documentation () {}
382
402
```
383
403
@@ -387,10 +407,16 @@ pub fn no_documentation() {}
387
407
388
408
Note that the third item is the crate root, which in this case is undocumented.
389
409
390
- When not using ` --show-coverage ` , ` --output-format json ` emits documentation in the experimental
410
+ ### ` -w ` /` --output-format ` : output format
411
+
412
+ ` --output-format json ` emits documentation in the experimental
391
413
[ JSON format] ( https://github.com/rust-lang/rfcs/pull/2963 ) . ` --output-format html ` has no effect,
392
414
and is also accepted on stable toolchains.
393
415
416
+ It can also be used with ` --show-coverage ` . Take a look at its
417
+ [ documentation] ( #--show-coverage-get-statistics-about-code-documentation-coverage ) for more
418
+ information.
419
+
394
420
### ` --enable-per-target-ignores ` : allow ` ignore-foo ` style filters for doctests
395
421
396
422
Using this flag looks like this:
@@ -441,39 +467,6 @@ $ rustdoc src/lib.rs -Z unstable-options --runtool valgrind
441
467
442
468
Another use case would be to run a test inside an emulator, or through a Virtual Machine.
443
469
444
- ### ` --show-coverage ` : get statistics about code documentation coverage
445
-
446
- This option allows you to get a nice overview over your code documentation coverage, including both
447
- doc-comments and code examples in the doc-comments. Example:
448
-
449
- ``` bash
450
- $ rustdoc src/lib.rs -Z unstable-options --show-coverage
451
- +-------------------------------------+------------+------------+------------+------------+
452
- | File | Documented | Percentage | Examples | Percentage |
453
- +-------------------------------------+------------+------------+------------+------------+
454
- | lib.rs | 4 | 100.0% | 1 | 25.0% |
455
- +-------------------------------------+------------+------------+------------+------------+
456
- | Total | 4 | 100.0% | 1 | 25.0% |
457
- +-------------------------------------+------------+------------+------------+------------+
458
- ```
459
-
460
- You can also use this option with the ` --output-format ` one:
461
-
462
- ``` bash
463
- $ rustdoc src/lib.rs -Z unstable-options --show-coverage --output-format json
464
- {" lib.rs" :{" total" :4," with_docs" :4," total_examples" :4," with_examples" :1}}
465
- ```
466
-
467
- Calculating code examples follows these rules:
468
-
469
- 1 . These items aren't accounted by default:
470
- * struct/union field
471
- * enum variant
472
- * constant
473
- * static
474
- * typedef
475
- 2 . If one of the previously listed items has a code example, then it'll be counted.
476
-
477
470
### ` --with-examples ` : include examples of uses of items as documentation
478
471
479
472
This option, combined with ` --scrape-examples-target-crate ` and
0 commit comments