Guides

IndexCollectorPass
in package
implements CompilerPass

FinalYes

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 GenIndexNode placeholder 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

CompilerPass

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

Methods

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
Return values
GenIndexNode[]
On this page

Search results