Expand description
Unified syntax tree types.
This module defines the core tree data structures shared by all docstring
styles. Every parsed docstring is represented as a tree of SyntaxNodes
(branches) and SyntaxTokens (leaves), each tagged with a SyntaxKind.
The Parsed struct owns the source text and the root node, and provides
a convenience pretty_print method for debugging.
§Missing placeholders
A zero-length element is a missing placeholder: the parsers insert one
wherever a syntactically expected element is absent from the source (e.g.
the TYPE in a (), the CLOSE_BRACKET in a (int, or the
DESCRIPTION in a (int):). The equivalence is exact — zero-length ⇔
missing placeholder — and placeholders sit at the offset where the missing
element would be inserted, making them the edit API’s insertion anchors.
Placeholders are only ever replaced by a real element, never extended in
place, and trivia tokens are never zero-length. Parsed::pretty_print
renders a missing token as <missing>; use SyntaxToken::is_missing /
SyntaxNode::find_missing to detect them programmatically. The
invariants are pinned corpus-wide in tests/trivia.rs.
Structs§
- Parsed
- The result of parsing a docstring.
- Syntax
Node - A branch node in the syntax tree.
- Syntax
Token - A leaf token in the syntax tree.
Enums§
- Syntax
Element - A child element of a
SyntaxNode— either a node or a token. - Syntax
Kind - Node and token kinds for all docstring styles.
Traits§
- Visitor
- Trait for visiting syntax tree nodes and tokens.
Functions§
- walk_
tree - Walk the raw syntax tree depth-first, calling the visitor methods.