Do not emit missing_doc_code_examples
rustdoc lint on module and a few other items
This commit is contained in:
parent
c1cfab230e
commit
7cf3f8ba7a
12 changed files with 35 additions and 64 deletions
|
@ -60,8 +60,6 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -
|
||||||
item.kind,
|
item.kind,
|
||||||
clean::StructFieldItem(_)
|
clean::StructFieldItem(_)
|
||||||
| clean::VariantItem(_)
|
| clean::VariantItem(_)
|
||||||
| clean::AssocConstItem(..)
|
|
||||||
| clean::AssocTypeItem(..)
|
|
||||||
| clean::TypeAliasItem(_)
|
| clean::TypeAliasItem(_)
|
||||||
| clean::StaticItem(_)
|
| clean::StaticItem(_)
|
||||||
| clean::ConstantItem(..)
|
| clean::ConstantItem(..)
|
||||||
|
@ -69,6 +67,15 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -
|
||||||
| clean::ImportItem(_)
|
| clean::ImportItem(_)
|
||||||
| clean::PrimitiveItem(_)
|
| clean::PrimitiveItem(_)
|
||||||
| clean::KeywordItem
|
| clean::KeywordItem
|
||||||
|
| clean::ModuleItem(_)
|
||||||
|
| clean::TraitAliasItem(_)
|
||||||
|
| clean::ForeignFunctionItem(..)
|
||||||
|
| clean::ForeignStaticItem(..)
|
||||||
|
| clean::ForeignTypeItem
|
||||||
|
| clean::AssocConstItem(..)
|
||||||
|
| clean::AssocTypeItem(..)
|
||||||
|
| clean::TyAssocConstItem(..)
|
||||||
|
| clean::TyAssocTypeItem(..)
|
||||||
// check for trait impl
|
// check for trait impl
|
||||||
| clean::ImplItem(box clean::Impl { trait_: Some(_), .. })
|
| clean::ImplItem(box clean::Impl { trait_: Some(_), .. })
|
||||||
)
|
)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"$DIR/doc-examples-json.rs":{"total":3,"with_docs":2,"total_examples":2,"with_examples":1}}
|
{"$DIR/doc-examples-json.rs":{"total":3,"with_docs":2,"total_examples":1,"with_examples":1}}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
| File | Documented | Percentage | Examples | Percentage |
|
| File | Documented | Percentage | Examples | Percentage |
|
||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
| ...tdoc-ui/coverage/doc-examples.rs | 4 | 100.0% | 1 | 25.0% |
|
| ...tdoc-ui/coverage/doc-examples.rs | 4 | 100.0% | 1 | 33.3% |
|
||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
| Total | 4 | 100.0% | 1 | 25.0% |
|
| Total | 4 | 100.0% | 1 | 33.3% |
|
||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"$DIR/json.rs":{"total":17,"with_docs":12,"total_examples":15,"with_examples":6}}
|
{"$DIR/json.rs":{"total":17,"with_docs":12,"total_examples":13,"with_examples":6}}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#![feature(rustdoc_missing_doc_code_examples)]
|
#![feature(rustdoc_missing_doc_code_examples)]
|
||||||
//~^ WARN
|
//~^ WARN
|
||||||
//~^^ WARN
|
|
||||||
|
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
#![warn(rustdoc::missing_doc_code_examples)]
|
#![warn(rustdoc::missing_doc_code_examples)]
|
||||||
|
|
|
@ -4,19 +4,20 @@ warning: missing documentation for the crate
|
||||||
LL | / #![feature(rustdoc_missing_doc_code_examples)]
|
LL | / #![feature(rustdoc_missing_doc_code_examples)]
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
LL | |
|
||||||
|
LL | | #![warn(missing_docs)]
|
||||||
... |
|
... |
|
||||||
LL | |
|
LL | |
|
||||||
LL | | pub fn foo() {}
|
LL | | pub fn foo() {}
|
||||||
| |_______________^
|
| |_______________^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/check.rs:9:9
|
--> $DIR/check.rs:8:9
|
||||||
|
|
|
|
||||||
LL | #![warn(missing_docs)]
|
LL | #![warn(missing_docs)]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: missing documentation for a function
|
warning: missing documentation for a function
|
||||||
--> $DIR/check.rs:13:1
|
--> $DIR/check.rs:12:1
|
||||||
|
|
|
|
||||||
LL | pub fn foo() {}
|
LL | pub fn foo() {}
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
@ -26,34 +27,23 @@ warning: no documentation found for this crate's top-level module
|
||||||
= help: The following guide may be of use:
|
= help: The following guide may be of use:
|
||||||
https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html
|
https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/check.rs:11:9
|
--> $DIR/check.rs:10:9
|
||||||
|
|
|
|
||||||
LL | #![warn(rustdoc::all)]
|
LL | #![warn(rustdoc::all)]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
= note: `#[warn(rustdoc::missing_crate_level_docs)]` implied by `#[warn(rustdoc::all)]`
|
= note: `#[warn(rustdoc::missing_crate_level_docs)]` implied by `#[warn(rustdoc::all)]`
|
||||||
|
|
||||||
warning: missing code example in this documentation
|
warning: missing code example in this documentation
|
||||||
--> $DIR/check.rs:5:1
|
--> $DIR/check.rs:12:1
|
||||||
|
|
|
|
||||||
LL | / #![feature(rustdoc_missing_doc_code_examples)]
|
LL | pub fn foo() {}
|
||||||
LL | |
|
| ^^^^^^^^^^^^^^^
|
||||||
LL | |
|
|
||||||
... |
|
|
||||||
LL | |
|
|
||||||
LL | | pub fn foo() {}
|
|
||||||
| |_______________^
|
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/check.rs:10:9
|
--> $DIR/check.rs:9:9
|
||||||
|
|
|
|
||||||
LL | #![warn(rustdoc::missing_doc_code_examples)]
|
LL | #![warn(rustdoc::missing_doc_code_examples)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: missing code example in this documentation
|
warning: 4 warnings emitted
|
||||||
--> $DIR/check.rs:13:1
|
|
||||||
|
|
|
||||||
LL | pub fn foo() {}
|
|
||||||
| ^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: 5 warnings emitted
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#![feature(rustdoc_missing_doc_code_examples)] //~ ERROR missing code example in this documentation
|
#![feature(rustdoc_missing_doc_code_examples)]
|
||||||
#![deny(rustdoc::missing_doc_code_examples)]
|
#![deny(rustdoc::missing_doc_code_examples)]
|
||||||
|
|
||||||
/// Some docs.
|
/// Some docs.
|
||||||
|
@ -6,7 +6,6 @@
|
||||||
pub struct Foo;
|
pub struct Foo;
|
||||||
|
|
||||||
/// And then, the princess died.
|
/// And then, the princess died.
|
||||||
//~^ ERROR missing code example in this documentation
|
|
||||||
pub mod foo {
|
pub mod foo {
|
||||||
/// Or maybe not because she saved herself!
|
/// Or maybe not because she saved herself!
|
||||||
//~^ ERROR missing code example in this documentation
|
//~^ ERROR missing code example in this documentation
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
error: missing code example in this documentation
|
error: missing code example in this documentation
|
||||||
--> $DIR/doc-without-codeblock.rs:1:1
|
--> $DIR/doc-without-codeblock.rs:10:5
|
||||||
|
|
|
|
||||||
LL | / #![feature(rustdoc_missing_doc_code_examples)]
|
LL | /// Or maybe not because she saved herself!
|
||||||
LL | | #![deny(rustdoc::missing_doc_code_examples)]
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
LL | |
|
|
||||||
LL | | /// Some docs.
|
|
||||||
... |
|
|
||||||
LL | | }
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/doc-without-codeblock.rs:2:9
|
--> $DIR/doc-without-codeblock.rs:2:9
|
||||||
|
@ -16,23 +10,11 @@ note: the lint level is defined here
|
||||||
LL | #![deny(rustdoc::missing_doc_code_examples)]
|
LL | #![deny(rustdoc::missing_doc_code_examples)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: missing code example in this documentation
|
|
||||||
--> $DIR/doc-without-codeblock.rs:8:1
|
|
||||||
|
|
|
||||||
LL | /// And then, the princess died.
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: missing code example in this documentation
|
|
||||||
--> $DIR/doc-without-codeblock.rs:11:5
|
|
||||||
|
|
|
||||||
LL | /// Or maybe not because she saved herself!
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: missing code example in this documentation
|
error: missing code example in this documentation
|
||||||
--> $DIR/doc-without-codeblock.rs:4:1
|
--> $DIR/doc-without-codeblock.rs:4:1
|
||||||
|
|
|
|
||||||
LL | /// Some docs.
|
LL | /// Some docs.
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub fn test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub mod module1 { //~ ERROR
|
pub mod module1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustdoc::missing_doc_code_examples)]
|
#[allow(rustdoc::missing_doc_code_examples)]
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: missing code example in this documentation
|
error: missing code example in this documentation
|
||||||
--> $DIR/lint-missing-doc-code-example.rs:20:1
|
--> $DIR/lint-missing-doc-code-example.rs:38:3
|
||||||
|
|
|
|
||||||
LL | pub mod module1 {
|
LL | /// doc
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/lint-missing-doc-code-example.rs:3:9
|
--> $DIR/lint-missing-doc-code-example.rs:3:9
|
||||||
|
@ -10,12 +10,6 @@ note: the lint level is defined here
|
||||||
LL | #![deny(rustdoc::missing_doc_code_examples)]
|
LL | #![deny(rustdoc::missing_doc_code_examples)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: missing code example in this documentation
|
|
||||||
--> $DIR/lint-missing-doc-code-example.rs:38:3
|
|
||||||
|
|
|
||||||
LL | /// doc
|
|
||||||
| ^^^^^^^
|
|
||||||
|
|
||||||
error: missing code example in this documentation
|
error: missing code example in this documentation
|
||||||
--> $DIR/lint-missing-doc-code-example.rs:50:1
|
--> $DIR/lint-missing-doc-code-example.rs:50:1
|
||||||
|
|
|
|
||||||
|
@ -34,5 +28,5 @@ error: missing code example in this documentation
|
||||||
LL | /// Doc
|
LL | /// Doc
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"$DIR/show-coverage-json.rs":{"total":2,"with_docs":1,"total_examples":2,"with_examples":1}}
|
{"$DIR/show-coverage-json.rs":{"total":2,"with_docs":1,"total_examples":1,"with_examples":1}}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
| File | Documented | Percentage | Examples | Percentage |
|
| File | Documented | Percentage | Examples | Percentage |
|
||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
| ...ests/rustdoc-ui/show-coverage.rs | 1 | 50.0% | 1 | 50.0% |
|
| ...ests/rustdoc-ui/show-coverage.rs | 1 | 50.0% | 1 | 100.0% |
|
||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
| Total | 1 | 50.0% | 1 | 50.0% |
|
| Total | 1 | 50.0% | 1 | 100.0% |
|
||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue