TocRenderer
in package
implements
TypeRenderer
The table of contents of a manual as one JSON file.
"toc.json" at the root of a rendered manual: what pages there are, in the order the table of contents puts them and nested the way it nests them, each with its title and the anchor a reference to it is built from.
A tool that wants to read a manual has to learn its shape first, and nothing published so far says it. "objects.inv.json" comes closest, but it is an index rather than a table of contents: a flat map without order or nesting, which repeats the project title and version in every one of its entries and knows only ".html" addresses. This file states those once, at the top, and leaves each page with what belongs to the page alone. For a manual the size of TYPO3 Explained that is 348 KB against 4.2 MB.
Everything here is what any project knows about itself. A theme that knows more -- how its pages are addressed, what else a page carries -- adds it through ModifyTocProject and ModifyTocPage.
Table of Contents
Interfaces
Constants
- FORMAT : mixed = 'llm_toc'
- The output format that writes this file.
Properties
- $anchorNormalizer : AnchorNormalizer
- $eventDispatcher : EventDispatcherInterface
- $outputFiles : DocumentOutputFiles
Methods
- __construct() : mixed
- render() : void
- anchor() : string
- The label a reference to the page is built from, or "" when it has none.
- collect() : void
- describe() : PageDescriptor
- One page and, nested below it, the pages its table of contents leads to.
- orphans() : array<int, DocumentEntryNode>
- Every page no table of contents leads to, in the order the project knows them.
- project() : TocProject
- What the manual says about itself, once.
Constants
FORMAT
The output format that writes this file.
public
mixed
FORMAT
= 'llm_toc'
Properties
$anchorNormalizer read-only
private
AnchorNormalizer
$anchorNormalizer
$eventDispatcher read-only
private
EventDispatcherInterface
$eventDispatcher
$outputFiles read-only
private
DocumentOutputFiles
$outputFiles
Methods
__construct()
public
__construct(AnchorNormalizer $anchorNormalizer, DocumentOutputFiles $outputFiles, EventDispatcherInterface $eventDispatcher) : mixed
Parameters
- $anchorNormalizer : AnchorNormalizer
- $outputFiles : DocumentOutputFiles
- $eventDispatcher : EventDispatcherInterface
render()
public
render(RenderCommand $renderCommand) : void
Parameters
- $renderCommand : RenderCommand
anchor()
The label a reference to the page is built from, or "" when it has none.
private
anchor(DocumentEntryNode $entry, DocumentNode|null $document) : string
The explicit label of the first section, the way a ":ref:" to the page names it, and otherwise the id derived from its title -- which the inventory registers as well, so a reference built on it resolves.
Parameters
- $entry : DocumentEntryNode
- $document : DocumentNode|null
Return values
stringcollect()
private
collect(DocumentEntryNode $entry, array<string, true> &$reached) : void
Parameters
- $entry : DocumentEntryNode
- $reached : array<string, true>
describe()
One page and, nested below it, the pages its table of contents leads to.
private
describe(DocumentEntryNode $entry, array<string, DocumentNode> $documents[, bool $orphan = false ]) : PageDescriptor
Parameters
- $entry : DocumentEntryNode
- $documents : array<string, DocumentNode>
- $orphan : bool = false
Return values
PageDescriptororphans()
Every page no table of contents leads to, in the order the project knows them.
private
orphans(ProjectNode $projectNode) : array<int, DocumentEntryNode>
Parameters
- $projectNode : ProjectNode
Return values
array<int, DocumentEntryNode>project()
What the manual says about itself, once.
private
project(ProjectNode $projectNode) : TocProject
Parameters
- $projectNode : ProjectNode