pub struct Item {}Expand description
One item of the crate’s surface, as declared.
Fields§
§path: StringThe full path a doc example would write: majordomus_cli::capability::model::Capability.
name: StringThe last segment: Capability.
kind: ItemKindWhat it is.
exported: boolReachable from outside the crate: declared pub, in a module chain that is pub
all the way to the crate root, or re-exported by one. This is what missing_docs
calls public and what a consumer can actually name.
declared_pub: boolDeclared pub on the item itself, whatever the modules above it are. A pub use
of a type carries its pub members out of a private module and leaves the private
ones behind, so the two facts have to be kept apart.
file: StringThe file it is declared in, repository-relative to the crate directory.
line: usizeThe line of the declaration, 1-based.
doc: StringThe documentation attached to it, doc-comment markers stripped, fences included.
examples: Vec<Example>The fenced blocks of that documentation, in order.
owner: StringThe path of the item that owns this one: the module of a free item, the type of a method, the enum of a variant.
trivial_accessor: boolA method or function whose body is one expression that only hands back what the
receiver already holds. Recorded because an example of one shows nothing that the
signature does not; see ItemKind::carries_behaviour.
provided: boolA member of a trait that the trait supplies itself: a method with a default body, a
constant with a default value. false for everything that is not a trait’s member.
Recorded because rustdoc anchors the two kinds of trait method differently — a
required one as tymethod. and a provided one as method. — and the route of a
method is therefore a fact about its declaration, not something a reader of the
inventory could guess.
deprecated: Option<String>The #[deprecated] note, when the item carries one.
Implementations§
Source§impl Item
impl Item
Sourcepub fn prose_words(&self) -> usize
pub fn prose_words(&self) -> usize
The words of the documentation, fenced blocks and the markers around them removed: the prose a reader is actually given.
use majordomus_cli::quality::source::Inventory;
let dir = tempfile::tempdir().unwrap();
let src = dir.path().join("src");
std::fs::create_dir_all(&src).unwrap();
std::fs::write(src.join("lib.rs"),
"//! Root.\n/// Answers, and says with what.\n///\n/// ```\n/// let x = 1;\n/// ```\npub fn go() {}\n").unwrap();
let item = Inventory::of_crate(dir.path()).unwrap().item("majordomus_cli::go").unwrap().clone();
assert_eq!(item.prose_words(), 5, "the fenced block is not prose");Sourcepub fn executable_examples(&self) -> Vec<&Example>
pub fn executable_examples(&self) -> Vec<&Example>
The examples of this item that the toolchain compiles.
use majordomus_cli::quality::source::Inventory;
let dir = tempfile::tempdir().unwrap();
let src = dir.path().join("src");
std::fs::create_dir_all(&src).unwrap();
std::fs::write(src.join("lib.rs"),
"//! Root.\n/// Answers.\n///\n/// ```ignore\n/// go();\n/// ```\npub fn go() {}\n").unwrap();
let item = Inventory::of_crate(dir.path()).unwrap().item("majordomus_cli::go").unwrap().clone();
assert_eq!(item.examples.len(), 1);
assert!(item.executable_examples().is_empty(), "an ignored block is not evidence");Trait Implementations§
Source§impl<'de> Deserialize<'de> for Item
impl<'de> Deserialize<'de> for Item
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Item
Source§impl JsonSchema for Item
impl JsonSchema for Item
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for Item
Auto Trait Implementations§
impl Freeze for Item
impl RefUnwindSafe for Item
impl Send for Item
impl Sync for Item
impl Unpin for Item
impl UnsafeUnpin for Item
impl UnwindSafe for Item
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.