Skip to main content

Module outline

Module outline 

Source
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§

OutlineItem
One node in the document-symbol outline tree.

Enums§

LabelContext
What a \label at some offset labels: the classification driving label hover (kind + nearest heading/caption). Like OutlineItem, LSP-agnostic and classified from the curated signature::builtin DB only.
OutlineSymbol
The kind of an outline entry, driving the LSP SymbolKind mapping.

Functions§

label_context
Classify the \label whose key sits at offset: 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. None in unclassifiable plain text before any section.
outline
Build the outline tree for root.