trlcdoc.config

Loading, validation and path resolution of the trlcdoc project configuration.

Attributes

PACKAGE_DIR

SCHEMA_FILE

BUILTIN_DIR

BUILTIN_PREFIX

TESTS_COVERAGE

TRLC_DOCUMENT_TYPES

PAGE_PLACEHOLDER

ConfigPath

ConfigError

Classes

Config

Validated project configuration with resolved paths.

Functions

load_config(config_file[, output]) → Config

Load and validate the project configuration.

find_config(start) → pathlib.Path

Find the default configuration file trlcdoc.yaml in a folder or its parents.

Module Contents

trlcdoc.config.PACKAGE_DIR
trlcdoc.config.SCHEMA_FILE
trlcdoc.config.BUILTIN_DIR
trlcdoc.config.BUILTIN_PREFIX = 'builtin:'
trlcdoc.config.TESTS_COVERAGE = 'tests:coverage'
trlcdoc.config.TRLC_DOCUMENT_TYPES = ('trlc', 'test_results')
trlcdoc.config.PAGE_PLACEHOLDER
trlcdoc.config.ConfigPath
trlcdoc.config.ConfigError
class trlcdoc.config.Config(data: dict[str, Any], config_file: pathlib.Path, output: pathlib.Path | None = None)[source]

Validated project configuration with resolved paths.

data
config_file
output_option
root
documents: list[dict[str, Any]]
tests: dict[str, Any] | None
trace: dict[str, Any] | None
project: dict[str, Any]
html: dict[str, Any]
plantuml: dict[str, Any]
path(value: str) → pathlib.Path[source]

Resolve a configured path against the project root.

Parameters:

value (str) – Absolute path or path relative to the project root.

Returns:

The absolute path.

Return type:

Path

property output: pathlib.Path

the –output option, else paths.output.

Type:

Folder for all generated files

property trlc_model: pathlib.Path

Folder with the TRLC model files.

property plantuml_dir: pathlib.Path

Folder for the downloaded PlantUML jar and the log of the picoweb server.

convert_dir(fmt: str, doc_id: str) → pathlib.Path[source]

Output folder of a converted document.

Parameters:
  • fmt (str) – Output format, rst or markdown.

  • doc_id (str) – Document id.

Returns:

The output folder.

Return type:

Path

property tests_dir: pathlib.Path

Output folder of the tests step.

property junit_file: pathlib.Path

JUnit XML file with the test results.

property coverage_dir: pathlib.Path

HTML coverage report folder.

property test_results_dir: pathlib.Path

Folder with the TRLC test result records generated from the JUnit XML.

property trace_dir: pathlib.Path

Output folder of the trace step.

property trace_report_html: pathlib.Path

The HTML tracing report.

property trace_report_rst: pathlib.Path

Folder of the reStructuredText tracing report, one page per level.

property trace_report_format: str

‘html’ (default) or ‘rst’.

Type:

Format of the tracing report

property sphinx_dir: pathlib.Path

Generated Sphinx source folder.

property html_dir: pathlib.Path

Generated HTML site.

document(doc_id: str) → dict[str, Any][source]

Get a document by its id.

Parameters:

doc_id (str) – Document id.

Returns:

The document configuration.

Return type:

dict[str, Any]

page_name(doc: dict[str, Any]) → str[source]

Get the Sphinx page name of a document, the name used in a table of contents.

Documents with several pages are a folder with an index page: TRLC documents and the reStructuredText tracing report. All other documents are a single page.

Parameters:

doc (dict[str, Any]) – Document configuration.

Returns:

‘<id>/index’ for a folder of pages, otherwise ‘<id>’.

Return type:

str

placeholder_files() → list[tuple[str, ConfigPath, pathlib.Path]][source]

Get the project owned files whose placeholders are replaced.

Returns:

Configuration location, its entry path and the path of html.index, html.page_header and the rst and markdown documents, except documents with ‘placeholders: false’.

Return type:

list[tuple[str, ConfigPath, Path]]

trlc_sources(doc: dict[str, Any]) → list[pathlib.Path][source]

Get the TRLC source folders of a TRLC document.

Parameters:

doc (dict[str, Any]) – Document of type trlc or test_results.

Returns:

The source folders.

Return type:

list[Path]

included_documents(doc: dict[str, Any]) → list[dict[str, Any]][source]

Get all documents included by a document, transitively.

Parameters:

doc (dict[str, Any]) – The including document.

Returns:

Included documents, without the document itself.

Return type:

list[dict[str, Any]]

included_sources(doc: dict[str, Any]) → list[pathlib.Path][source]

Get the TRLC source folders of all documents included by a document.

Parameters:

doc (dict[str, Any]) – The including document.

Returns:

The source folders.

Return type:

list[Path]

file_reference(value: str) → pathlib.Path[source]

Resolve a converter, translation or render configuration file reference.

Parameters:

value (str) – ‘builtin:<file>’ or a path relative to the project root.

Returns:

The absolute file path.

Return type:

Path

html_source(doc: dict[str, Any]) → pathlib.Path[source]

Resolve the HTML folder of a document of type html or command.

Parameters:

doc (dict[str, Any]) – Document of type html or command.

Returns:

The HTML folder.

Return type:

Path

property repository: str

Configured repository URL or ‘auto’.

trlcdoc.config.load_config(config_file: pathlib.Path, output: pathlib.Path | None = None) → Config[source]

Load and validate the project configuration.

Parameters:
  • config_file (Path) – The trlcdoc YAML configuration file.

  • output (Path | None) – Output folder from the command line, replaces paths.output. A relative path is relative to the current folder.

Returns:

The validated configuration.

Return type:

Config

Raises:

TrlcdocError – If the file is missing or invalid.

trlcdoc.config.find_config(start: pathlib.Path) → pathlib.Path[source]

Find the default configuration file trlcdoc.yaml in a folder or its parents.

Parameters:

start (Path) – Folder to start the search in.

Returns:

The configuration file, or start/trlcdoc.yaml if none was found.

Return type:

Path