Module rust_source
Expand description
Reading the workspace’s own Rust sources as a registry.
Four generators need the same three things — the files under a directory, the
items in them, and the doc comment on an item — and errors needed the third
one already. Doing it once here is what keeps the generators short enough to
read, and it puts the two rules that matter in one place:
- Deterministic order.
read_diryields in filesystem order, which is neither sorted nor stable across machines. Every listing this module returns is sorted by path, because--mode checkis a byte comparison (docs/design/11-documentation-plan.md§17.6). - Test code is not documentation. A
#[cfg(test)]module and atests.rsfile hold doubles —CountingSampler,BrokenStorage,AlwaysPrune— that implement the public traits and are not public API. They are skipped here so that no generator has to know they exist.
Structs§
- Source
File - One parsed source file, with the repository-relative path it came from.
Functions§
- cfg_
feature - The feature named by an item’s
#[cfg(feature = "…")], if it has one. - collect 🔒
- Collects
.rspaths underabsolute, recording them asrelative/…. - doc_
lines - The raw lines of a doc comment, one leading space stripped, in source order.
- doc_
paragraphs - A doc comment as Markdown paragraphs, with rustdoc’s links rewritten.
- doc_
summary - The first paragraph of a doc comment: the summary line rustdoc shows in a module’s item table.
- has_cfg
- Does this item carry any
#[cfg(…)]at all? - is_
test_ gated - Is this item gated on
#[cfg(test)]? - items
- Every item in a file, flattened through inline modules.
- items_
including_ tests - Every item in a file, test modules included.
- parse 🔒
- Walks and parses, with or without the test files.
- push_
items 🔒 - Appends
itemsand the contents of their inline modules toflat. - walk
- Parses every
.rsfile underdirectory(repository-relative), recursively. - walk_
all - Parses every
.rsfile underdirectory, test modules included.