Skip to main content

Module rust_source

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_dir yields in filesystem order, which is neither sorted nor stable across machines. Every listing this module returns is sorted by path, because --mode check is a byte comparison (docs/design/11-documentation-plan.md §17.6).
  • Test code is not documentation. A #[cfg(test)] module and a tests.rs file 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§

SourceFile
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 .rs paths under absolute, recording them as relative/….
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 items and the contents of their inline modules to flat.
walk
Parses every .rs file under directory (repository-relative), recursively.
walk_all
Parses every .rs file under directory, test modules included.