Expand description
Build a document-symbol outline from the CST: the sectioning hierarchy
(\part … \subparagraph), with float/theorem environments, \labels, and a
.dtx’s documented macros/environments (via doc_associations) as leaves.
LSP-agnostic by design (byte ranges, no lsp_types) so it is
unit-testable without the language server; the lsp module converts the
OutlineItem tree into lsp_types::DocumentSymbol.
Classification reads the built-in signature DB: a command’s
sectioning level and an environment’s
outline category. User-defined
sectioning commands are out of scope here — sectioning is a static, standard
set — so we consult signature::builtin directly rather than the scanned
two-tier signature::Signatures.
Two passes. [collect] walks the CST in document order into a flat list of
(level, item) pairs: sectioning commands carry their level, while floats,
theorems, and labels carry None. Non-outline environments (document,
itemize, …) are transparent — their contents splice into the parent stream
so a \label inside itemize still surfaces. [nest_sections] then folds the
flat list into the hierarchy with a level stack (sectioning commands are CST
siblings; nesting is implied by level, not tree shape), attaching each
non-section item to the deepest open section and stretching each section’s
range to where it closes.
Structs§
- Outline
Item - One node in the document-symbol outline tree.
Enums§
- Label
Context - What a
\labelat some offset labels: the classification driving label hover (kind + nearest heading/caption). LikeOutlineItem, LSP-agnostic and classified from the curatedsignature::builtinDB only. - Outline
Symbol - The kind of an outline entry, driving the LSP
SymbolKindmapping.
Functions§
- label_
context - Classify the
\labelwhose key sits atoffset: the innermost classifying ancestor wins (float/theorem/math/list environment), matching how the label resolves in TeX; a label in plain prose falls back to the nearest preceding sectioning command.Nonein unclassifiable plain text before any section. - outline
- Build the outline tree for
root.