-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #76196 - r-52:r-coverage-allow-missing-docs, r=jyn514
rustdoc: skip #[allow(missing docs)] for docs in coverage report During the document coverage reporting with: ```bash rustdoc something.rs -Z unstable-options --show-coverage ``` the coverage report counts code that is marked with `#[allow(missing_docs)]` for the calculation, which outputs lower numbers in the coverage report even though these parts should be ignored for the calculation. Right now I'm not sure how this can be tested (CI)? (I verified it by hand and ran the unit tests) r? `@jyn514` **Reference:** Fixes #76121
- Loading branch information
Showing
5 changed files
with
104 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// compile-flags:-Z unstable-options --show-coverage | ||
// check-pass | ||
|
||
//! Make sure to have some docs on your crate root | ||
#[allow(missing_docs)] | ||
pub mod mod_foo { | ||
pub struct Bar; | ||
} | ||
|
||
/// This is a struct with a `#[allow(missing_docs)]` | ||
pub struct AllowTheMissingDocs { | ||
#[allow(missing_docs)] | ||
pub empty_str: String, | ||
|
||
/// This has | ||
#[allow(missing_docs)] | ||
/// but also has documentation comments | ||
pub hello: usize, | ||
|
||
/// The doc id just to create a boilerplate comment | ||
pub doc_id: Vec<u8>, | ||
} | ||
|
||
/// A function that has a documentation | ||
pub fn this_is_func() {} | ||
|
||
#[allow(missing_docs)] | ||
pub struct DemoStruct { | ||
something: usize, | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub mod bar { | ||
#[warn(missing_docs)] | ||
pub struct Bar { //~ WARN | ||
pub f: u32, //~ WARN | ||
} | ||
|
||
pub struct NeedsNoDocs; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
warning: missing documentation for a struct | ||
--> $DIR/allow_missing_docs.rs:36:5 | ||
| | ||
LL | pub struct Bar { | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/allow_missing_docs.rs:35:12 | ||
| | ||
LL | #[warn(missing_docs)] | ||
| ^^^^^^^^^^^^ | ||
|
||
warning: missing documentation for a struct field | ||
--> $DIR/allow_missing_docs.rs:37:9 | ||
| | ||
LL | pub f: u32, | ||
| ^^^^^^^^^^ | ||
|
||
warning: 2 warnings emitted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
+-------------------------------------+------------+------------+------------+------------+ | ||
| File | Documented | Percentage | Examples | Percentage | | ||
+-------------------------------------+------------+------------+------------+------------+ | ||
| ...i/coverage/allow_missing_docs.rs | 5 | 71.4% | 0 | 0.0% | | ||
+-------------------------------------+------------+------------+------------+------------+ | ||
| Total | 5 | 71.4% | 0 | 0.0% | | ||
+-------------------------------------+------------+------------+------------+------------+ |