);
if should_have_doc_examples {
find_testable_code(
- &i.attrs.doc_strings.iter().map(|d| d.as_str()).collect::<Vec<_>>().join("\n"),
+ &i.attrs
+ .doc_strings
+ .iter()
+ .map(|d| d.as_str())
+ .collect::<Vec<_>>()
+ .join("\n"),
&mut tests,
ErrorCodes::No,
false,
let has_doc_example = tests.found_tests != 0;
debug!("counting {:?} {:?} in {}", i.type_(), i.name, i.source.filename);
- self.items
- .entry(i.source.filename.clone())
- .or_default()
- .count_item(has_docs, has_doc_example, should_have_doc_examples);
+ self.items.entry(i.source.filename.clone()).or_default().count_item(
+ has_docs,
+ has_doc_example,
+ should_have_doc_examples,
+ );
}
}
pub struct X;
/// Bar
+///
+/// ```
+/// let x = 12;
+/// ```
pub mod bar {
/// bar
pub struct Bar;
/// X
- pub enum X { Y }
+ pub enum X {
+ /// ```
+ /// let x = "should be ignored!";
+ /// ```
+ Y
+ }
}
/// yolo
+///
+/// ```text
+/// should not be counted as a code example!
+/// ```
pub enum Yolo { X }
+impl Yolo {
+ /// ```
+ /// let x = "should be ignored!";
+ /// ```
+ pub const Const: u32 = 0;
+}
+
pub struct Xo<T: Clone> {
+ /// ```
+ /// let x = "should be ignored!";
+ /// ```
x: T,
}
+
+/// ```
+/// let x = "should be ignored!";
+/// ```
+pub static StaticFoo: u32 = 0;
+
+/// ```
+/// let x = "should be ignored!";
+/// ```
+pub const ConstFoo: u32 = 0;
+
+/// ```
+/// let x = "should be ignored!";
+/// ```
+pub type TypeFoo = u32;
-{"$DIR/json.rs":{"total":13,"with_docs":7,"with_examples":0}}
+{"$DIR/json.rs":{"total":17,"with_docs":12,"total_examples":10,"with_examples":1}}