IndexCollectorPass
in package
implements
CompilerPass
Collects every `.. index::` entry across all documents and aggregates them into an alphabetically sorted genindex term tree, then makes it available several independent ways -- any combination may be present in a project:
- attaches the full, project-wide tree to the document (if any) marked
:template: genindex; - populates every
GenIndexNodeplaceholder left behind by GenIndexDirective (.. genindex::), wherever it was written, with either the full tree or -- if the directive was given a:scope:-- a subset filtered to documents under that path prefix; - attaches each entry's own term(s) to the SectionNode it resolved to, as
metadata (see IndexNode::TERMS_DATA_NAME), independent of genindex
entirely, so the section renders them as a
data-*attribute a search tool can read; - registers a
.. index::block given a:name:as a link target, so a:ref:can point at the section its entries are filed under.
The actual work is split across collaborators in the IndexCollector
namespace: IndexEntryCollector collects and expands .. index::
entries into a term map, GenIndexSeeResolver points see/seealso
rows at their target's anchor, GenIndexTermMapFilter scopes a term
map to a :scope: path prefix, GenIndexNodeBuilder turns a term
map into the sorted node tree, and IndexTargetRegistrar registers
named blocks as link targets. This class only orchestrates them.
Table of Contents
Interfaces
Properties
- $collector : IndexEntryCollector
- $nodeBuilder : GenIndexNodeBuilder
- $seeResolver : GenIndexSeeResolver
- $targetRegistrar : IndexTargetRegistrar
- $termMapFilter : GenIndexTermMapFilter
Methods
- __construct() : mixed
- getPriority() : int
- run() : DocumentNode[]
- findGenIndexNodes() : GenIndexNode[]
- Finds every GenIndexNode already in a document's tree -- the empty placeholders GenIndexDirective leaves behind at parse time -- so they can be populated now that the project-wide term data actually exists.
Properties
$collector read-only
private
IndexEntryCollector
$collector
$nodeBuilder read-only
private
GenIndexNodeBuilder
$nodeBuilder
$seeResolver read-only
private
GenIndexSeeResolver
$seeResolver
$targetRegistrar read-only
private
IndexTargetRegistrar
$targetRegistrar
$termMapFilter read-only
private
GenIndexTermMapFilter
$termMapFilter
Methods
__construct()
public
__construct(IndexEntryCollector $collector, GenIndexSeeResolver $seeResolver, GenIndexTermMapFilter $termMapFilter, GenIndexNodeBuilder $nodeBuilder, IndexTargetRegistrar $targetRegistrar) : mixed
Parameters
- $collector : IndexEntryCollector
- $seeResolver : GenIndexSeeResolver
- $termMapFilter : GenIndexTermMapFilter
- $nodeBuilder : GenIndexNodeBuilder
- $targetRegistrar : IndexTargetRegistrar
getPriority()
public
getPriority() : int
Return values
intrun()
public
run(DocumentNode[] $documents, CompilerContextInterface $compilerContext) : DocumentNode[]
Parameters
- $documents : DocumentNode[]
- $compilerContext : CompilerContextInterface
Return values
DocumentNode[]findGenIndexNodes()
Finds every GenIndexNode already in a document's tree -- the empty placeholders GenIndexDirective leaves behind at parse time -- so they can be populated now that the project-wide term data actually exists.
private
findGenIndexNodes(Node $node) : GenIndexNode[]
Parameters
- $node : Node