rust-lang/docs.rs

Trying to understand and reproduce the coverage statistics

Closed this issue · 5 comments

I have #![warn(missing_docs)] in my lib.rs and aim to document all public items. I have no warnings and the coverage report is:

cargo rustdoc -- --show-coverage -Z unstable-options
 Documenting pdfium v0.9.3 (/home/martin/workspace/rust/pdfium-rs)
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| src/action.rs                       |          1 |     100.0% |          0 |       0.0% |
| src/annotation.rs                   |          1 |     100.0% |          0 |       0.0% |
| src/attachment.rs                   |          1 |     100.0% |          0 |       0.0% |
| src/availability.rs                 |          1 |     100.0% |          0 |       0.0% |
| src/bitmap/mod.rs                   |          8 |     100.0% |          0 |       0.0% |
| src/bookmark.rs                     |          1 |     100.0% |          0 |       0.0% |
| src/c_api/guard.rs                  |          4 |     100.0% |          0 |       0.0% |
| src/c_api/pdfium_bindings.rs        |          1 |     100.0% |          0 |       0.0% |
| src/c_api/pdfium_constants.rs       |        199 |     100.0% |          0 |       0.0% |
| src/c_api/pdfium_handle.rs          |          1 |     100.0% |          0 |       0.0% |
| src/c_api/pdfium_types.rs           |        312 |     100.0% |          0 |       0.0% |
| src/clip_path.rs                    |          1 |     100.0% |          0 |       0.0% |
| src/color.rs                        |          1 |     100.0% |          0 |       0.0% |
| src/destination.rs                  |          1 |     100.0% |          0 |       0.0% |
| src/document/mod.rs                 |          1 |     100.0% |          0 |       0.0% |
| src/document/reader.rs              |          1 |     100.0% |          0 |       0.0% |
| src/error.rs                        |         18 |     100.0% |          0 |       0.0% |
| src/font.rs                         |          1 |     100.0% |          0 |       0.0% |
| src/form.rs                         |          1 |     100.0% |          0 |       0.0% |
| src/glyph_path.rs                   |          1 |     100.0% |          0 |       0.0% |
| src/javascript_action.rs            |          1 |     100.0% |          0 |       0.0% |
| src/lib.rs                          |          1 |     100.0% |          1 |     100.0% |
| src/link.rs                         |          1 |     100.0% |          0 |       0.0% |
| src/matrix.rs                       |          1 |     100.0% |          0 |       0.0% |
| src/page/boundaries.rs              |          1 |     100.0% |          0 |       0.0% |
| src/page/link.rs                    |          1 |     100.0% |          0 |       0.0% |
| src/page/mod.rs                     |          1 |     100.0% |          0 |       0.0% |
| src/page/object/mark.rs             |          1 |     100.0% |          0 |       0.0% |
| src/page/object/mod.rs              |          1 |     100.0% |          0 |       0.0% |
| src/page/range.rs                   |          1 |     100.0% |          0 |       0.0% |
| src/page/render.rs                  |          2 |     100.0% |          1 |     100.0% |
| src/page/text/mod.rs                |          1 |     100.0% |          0 |       0.0% |
| src/page/text/search.rs             |          2 |     100.0% |          1 |     100.0% |
| src/path_segment.rs                 |          1 |     100.0% |          0 |       0.0% |
| src/rect.rs                         |          5 |     100.0% |          0 |       0.0% |
| src/signature.rs                    |          1 |     100.0% |          0 |       0.0% |
| src/struct_element.rs               |          1 |     100.0% |          0 |       0.0% |
| src/struct_element_attr.rs          |          1 |     100.0% |          0 |       0.0% |
| src/struct_element_attr_value.rs    |          1 |     100.0% |          0 |       0.0% |
| src/struct_tree.rs                  |          1 |     100.0% |          0 |       0.0% |
| src/xobject.rs                      |          1 |     100.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |        583 |     100.0% |          3 |     100.0% |
+-------------------------------------+------------+------------+------------+------------+
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.20s

On docs.rs the stats are: Coverage: 99.49% 588 out of 591 items documented, 3 out of 8 items with examples

I would like to know:

  • why it finds 5 items more documented than I see locally (588-583)
  • which are the 3 undocumented items (591-588)
  • which are the 5 items that lack examples (8-3)
  • the rules that determine an item needs an example

You can see how docs.rs gets the coverage from here and here.

For the rules, you can find them in the rustdoc book here.

One thing to note: we enable the scrape-examples feature even in this case, so it might be the root of your issue (and maybe something we should change).

I will study the rustdoc book. There is something else I noticed.

The file src/c_api/pdfium.rs contains more than 400 functions with documentation, but these functions are not counted.

The reason might be either that the impl is in a different file than the struct definition (done here to keep stuff manageable) or because they don't follow the rust naming conventions as they map directly to C functions.

In either case I would expect them to be counted. Now we are ignoring a major part of the crate.

It's possibly a bug. If confirmed, please open an issue on rust-lang/rust and ping me on it so I can take a look.

@GuillaumeGomez so we can close this issue here?