trlcdoc.pages
Placeholders of project owned pages and the check of their tables of contents.
Project owned pages (html.index, html.page_header, rst and markdown documents) are copied into the generated Sphinx folder at different depths. Their placeholders are replaced per page:
{project_root}: the relative path from the page to the project root
{page:<id>}: the page name of a document, relative to the page
{documents}: the page names of the documents in configuration order, one per line, without the documents a toctree of a project page lists explicitly
With a project start page, the project owns the table of contents. The check compares its toctree entries with the page names of the documents, which depend on the document type and the format of the tracing report.
Attributes
Functions
|
Replace the placeholders of a project owned page. |
|
Get the page names listed in the toctrees of a page. |
|
Check the tables of contents of a project start page against the page names of the documents. |
Module Contents
- trlcdoc.pages.PROJECT_ROOT_PLACEHOLDER = '{project_root}'
- trlcdoc.pages.DOCUMENTS_PLACEHOLDER
- trlcdoc.pages.RST_TOCTREE
- trlcdoc.pages.MD_TOCTREE
- trlcdoc.pages.TITLED_ENTRY
- trlcdoc.pages.SOURCE_SUFFIXES = ('.rst', '.md')
- trlcdoc.pages.replace_placeholders(cfg: trlcdoc.config.Config, text: str, page_file: pathlib.Path) str[source]
Replace the placeholders of a project owned page.
The page names of documents and the project root are relative to the page, so the same file works in pages at different depths of the Sphinx folder. Unknown document ids are left unchanged, the configuration check reports them.
{documents} leaves out the documents that a toctree of a project page lists explicitly, by {page:<id>} or by page name, so a page can list a document in a toctree of its own, e.g. the license in a separate section, without listing it twice.
- Parameters:
cfg (Config) – Project configuration.
text (str) – Page content with placeholders.
page_file (Path) – The page in the Sphinx source folder.
- Returns:
The content with replaced placeholders.
- Return type:
str
- trlcdoc.pages.toctree_entries(text: str, markdown: bool = False) list[str][source]
Get the page names listed in the toctrees of a page.
Entries with explicit title (‘Title <page>’) give their page, a leading ‘/’ and a source suffix are removed. ‘self’, URLs and glob patterns are no page names and are skipped.
- Parameters:
text (str) – Content of a reStructuredText or Markdown (MyST) page.
markdown (bool) – The page is Markdown, with MyST toctree directives in code fences.
- Returns:
The page names in the order of the page.
- Return type:
list[str]
- trlcdoc.pages.check_toctrees(cfg: trlcdoc.config.Config) list[str][source]
Check the tables of contents of a project start page against the page names of the documents.
Without html.index, trlcdoc generates the table of contents itself and there is nothing to check. Otherwise the toctrees of html.index and of the rst and markdown documents are read, after replacing their placeholders, and checked for
entries which are no page, with a hint if a document has a similar page name
documents whose page is in no toctree
Entries in folders that belong to no document, e.g. pages of Sphinx extensions like sphinx-autoapi, cannot be checked and are accepted.
- Parameters:
cfg (Config) – Project configuration.
- Returns:
Findings, empty if the tables of contents list every document correctly.
- Return type:
list[str]