SW-Architecture

trlcdoc SW Architecture

This file contains the high level software architecture of trlcdoc, a configurable documentation generator for NewTec TRLC based projects.

Context

sw_arch_trlcdoc_tool

Attribute Name

Attribute Value

Description

trlcdoc documentation tool

trlcdoc is a Python 3 package providing the console application trlcdoc. It builds documentation for a TRLC based project as static HTML site from:

  • project configuration trlcdoc.yaml

  • TRLC model and records

  • PlantUML diagrams

  • project sources and tests

It contains no project specific content and orchestrates the external toolchain:

  • pytest runs the tests

  • pyTRLCConverter converts the TRLC records

  • LOBSTER creates the tracing report

  • PlantUML renders the diagrams

  • Sphinx builds the site

  • git provides version information

All generated files are written into the output folder.

Note

N/A

Satisfies

Verification Criteria

Build the documentation of a reference project with trlcdoc. Check the generated site and the console output.

Context Diagram

Context Diagram

Static View

Component overview

The software consists of eight components. The CLI runs the build steps, each step is realized by one component:

  • PlantUML Provider

  • Test Runner

  • TRLC Conversion

  • Trace Report

  • HTML Builder

All steps get their settings and paths from the Configuration component and use the Common Services for running external tools and managing the output folder.

Component Overview

Component Overview

Components

CLI

sw_arch_comp_cli

Attribute Name

Attribute Value

Description

CLI component (cli.py, __main__.py)

The CLI provides the application entry point. It

  • parses the command line with argparse

  • sets up the console output for the verbosity of the -v option (log.py)

  • locates and loads the configuration, with the output folder of the --output option

  • determines the steps to run in their fixed order, including the steps they depend on

  • runs them

The clean step removes the output folder, the check step reports the valid configuration and the table of contents findings of a project start page (pages.py), all other steps are delegated to their components. The steps clean and show only run on request.

It maps the step results to the exit codes:

  • 0: success

  • 1: findings

  • 2: build error

  • 130: interrupted

Note

N/A

Satisfies

Verification Criteria

Call trlcdoc with different step selections, with --help, --version, -v and with an invalid configuration. Check the executed steps, the console output and the exit code.

CLI Component

CLI Component

Configuration

sw_arch_comp_config

Attribute Name

Attribute Value

Description

Configuration component (config.py, schema/trlcdoc.schema.json)

Finds and loads a YAML configuration, validates it against the JSON schema and checks

  • the references between documents, includes, converter files and trace levels

  • the document ids of the {page:<id>} placeholders in the project pages

  • the location of the output folder

It provides the validated settings as a Config object, which resolves all paths:

  • the configured inputs relative to the project root

  • the output folder of the --output option, if given, relative to the current folder

  • the generated files in fixed subfolders of the output folder

It defines the page name of each document (page_name()), the single place of this rule.

Note

N/A

Satisfies

Verification Criteria

Load

  • valid configurations

  • configurations violating the schema

  • configurations with unresolved references or a forbidden output folder

Check the resolved paths and the error messages.

Configuration Component

Configuration Component

Common Services

sw_arch_comp_util

Attribute Name

Attribute Value

Description

Common Services component (util.py, log.py)

Provides services shared by all steps:

  • locating the toolchain executables of the running Python environment

  • locating the external tools on the PATH, e.g. Java and Graphviz, before a step needs them

  • running external commands

  • querying git

  • managing the output folder

  • the console output

All modules log with the standard logging module, below the trlcdoc logger. log.py writes INFO and DEBUG messages to the standard output, warnings and errors to the standard error output, and adds the level name to verbose lines. It defines the TRACE level for -vv and removes secrets from environment variables and URLs. Running a command logs it, and with -v its working folder, environment, exit code and duration.

Build errors are reported with the TrlcdocError exception. The output folder management creates the output folder with a marker file and deletes only folders inside a marked output folder.

Note

N/A

Satisfies

Verification Criteria

Run commands with success and error results. Create, clean and remove output folders, and try to delete unmarked folders with content. Check the results and errors.

Common Services Component

Common Services Component

PlantUML Provider

sw_arch_comp_plantuml

Attribute Name

Attribute Value

Description

PlantUML Provider component (plantuml.py)

Realizes the plantuml step. It selects, in this order,

  • the PlantUML jar or server from the PLANTUML environment variable

  • the jar from the configuration

  • a download of the configured version into the output folder

It exports the selection in the PLANTUML environment variable for the converters and Sphinx.

A PlantUML jar runs with the Java option -Djava.awt.headless=true:

  • the generic Sphinx configuration conf.py passes it on every system

  • pyTRLCConverter passes it on Linux, on macOS java_headless_env() sets JAVA_TOOL_OPTIONS

Java on Linux without a display and on Windows needs no option, on macOS every diagram would otherwise start the graphical user interface support of Java.

With plantuml.picoweb (default), start_picoweb() starts a selected jar once as picoweb server on a free port of 127.0.0.1 and exports its URL instead of the jar:

  • pyTRLCConverter renders through the server URL itself

  • Sphinx runs plantuml_client.py per diagram, the plantuml -pipe of the server

  • NO_PROXY gets 127.0.0.1, so requests to the server don’t go through a proxy

The server is ready when it renders a probe diagram. If it doesn’t within 30 seconds, it is stopped and the jar stays exported, with a warning. stop_picoweb() stops the server and restores the environment. The CLI calls it at the end of every run, atexit when Python exits. While the server runs, SIGTERM ends trlcdoc like sys.exit(), so both run then too.

Note

N/A

Satisfies

Verification Criteria

Run the plantuml step with the environment variable set, with a configured jar and without both. Check the exported jar path. Check the Java command of Sphinx and the environment of pyTRLCConverter on each system. Run the plantuml step with picoweb, check the exported URL, a rendered diagram and the stopped server. Check the fallback to the jar.

PlantUML Provider Component

PlantUML Provider Component

Test Runner

sw_arch_comp_testrun

Attribute Name

Attribute Value

Description

Test Runner component (testrun.py)

Realizes the tests step. It

  • runs pytest, with a coverage report if requested, or the configured test command

  • reads the JUnit XML results

  • links each test to its TRLC test cases by recorded properties or the configured name mapping

  • writes the results as SwTestCaseResult records into the output folder

It reports failed tests as findings and unlinked tests as error.

Note

N/A

Satisfies

Verification Criteria

Run the tests step with passing, failing, linked and unlinked tests. Check

  • the generated test result records

  • the coverage report

  • the reported results

Test Runner Component

Test Runner Component

TRLC Conversion

sw_arch_comp_convert

Attribute Name

Attribute Value

Description

TRLC Conversion component (convert.py, converters/)

Realizes the convert step. It runs pyTRLCConverter per TRLC document with

  • the document sources

  • the TRLC model

  • the records of the included documents

  • the configured converter, translation and render configuration

The built-in converters extend the pyTRLCConverter reStructuredText and Markdown converters for

  • the NewTec Generic types (information, images, PlantUML diagrams)

  • requirements

  • test cases

  • test results

Note

N/A

Satisfies

Verification Criteria

Convert TRLC documents with built-in and project converters into both formats. Check the output files and the rendered diagrams.

TRLC Conversion Component

TRLC Conversion Component

Trace Report

sw_arch_comp_trace

Attribute Name

Attribute Value

Description

Trace Report component (trace.py)

Realizes the trace step. It

  • extracts the trace data per configured level with lobster-trlc or the code extractor

  • runs doxygen with the level’s Doxyfile, limited to XML output, before lobster-doxygen

  • generates the LOBSTER policy from the level relations

  • runs lobster-report

  • creates the HTML tracing report with lobster-html-report

  • or the site pages with lobster-rst-report, using project relative file references

  • links the items to the repository with lobster-online-report for online reports

  • links the items of levels with a test results document to their row on the site page

The test result records are generated into the output folder, so their items are found by their level and get a link relative to the report page, after the online conversion. The HTML report is embedded at the site root, the site pages are in a folder below it. The link ends with the anchor that the built-in test results converter gives every row, derived from the TRLC file and record name. The record name is the link text.

It lists the items with missing trace links and reports them as findings.

Note

N/A

Satisfies

Verification Criteria

Run the trace step offline and online on a project with complete and with missing trace links. Check the report, its links and the listed findings.

Trace Report Component

Trace Report Component

HTML Builder

sw_arch_comp_html

Attribute Name

Attribute Value

Description

HTML Builder component (html.py, pages.py, sphinx/)

Realizes the html step. It generates the Sphinx source folder with

  • one page per document according to its type

  • the start page with the table of contents or the project start page

  • the project settings

It builds the site with Sphinx. It adds the project page header to the generated pages.

The module pages.py replaces the placeholders of the project pages, relative to each page: {project_root}, {page:<id>} and {documents}. It also checks the toctrees of a project start page against the page names of the documents for the check step.

It also realizes the show step, which opens the start page of the built site in the web browser: under WSL in the Windows default browser, otherwise with the Python webbrowser module.

The generic Sphinx configuration conf.py

  • reads the project settings

  • copies embedded HTML sites into the site

  • adds the version control state from html.py (git describe and branch) to the page footer

  • executes the project specific Sphinx configuration

The Sphinx extension sphinx_links.py resolves the relative links and images of Markdown pages against the location of the Markdown file in the project: page links for site pages, repository links at the built commit for other project files, text if there is no repository.

Note

N/A

Satisfies

Verification Criteria

Build the site from a configuration with every document type. Check

  • the start page

  • the document pages

  • the embedded sites

  • the page footer

HTML Builder Component

HTML Builder Component

Dynamic View

sw_arch_build_flow

Attribute Name

Attribute Value

Description

Build flow

A trlcdoc run loads and validates the configuration first and stops with exit code 2 if it is invalid. It then runs the selected steps in their fixed order.

  • A build error stops the run with exit code 2

  • Findings of the tests and trace steps lead to exit code 1, but do not stop the run

So the site still documents the findings.

Note

N/A

Satisfies

Verification Criteria

Run trlcdoc with an invalid configuration, a failing build step and a project with findings. Check the executed steps and the exit codes.

trlcdoc Build Sequence

trlcdoc Build Sequence

Output Folder States

sw_arch_output_folder_states

Attribute Name

Attribute Value

Description

Output folder states

Before deleting anything, trlcdoc classifies the configured output folder into one of the states Missing, Empty, Owned or Foreign.

  • Creating the folder (prepare_output) writes the marker file: Missing and Empty change to Owned

  • Cleaning subfolders keeps the folder Owned, removing it (clean step) changes it to Missing

  • A Foreign folder stays unchanged, every delete request is refused with an error

Note

N/A

Satisfies

Verification Criteria

Run the clean and build steps for an output folder in each state. Check the resulting state and the errors.

Output Folder States

Output Folder States

sw_arch_state_missing

Attribute Name

Attribute Value

Description

State Missing

The output folder does not exist. This is the initial state of a fresh project and the state after the clean step.

  • Steps writing output create the folder and change to Owned

  • The clean step reports that there is nothing to clean

Note

N/A

Satisfies

Verification Criteria

Run the clean step and a build step without output folder. Check the message and that the folder is created with the marker file.

sw_arch_state_empty

Attribute Name

Attribute Value

Description

State Empty

The output folder exists without any content, e.g. created by the user. It contains nothing that could be lost, so it is treated like a missing folder and changes to Owned when output is written.

Note

N/A

Satisfies

Verification Criteria

Run a build step with an empty output folder. Check that the marker file is written and the build succeeds.

sw_arch_state_owned

Attribute Name

Attribute Value

Description

State Owned

The output folder contains the marker file, so trlcdoc created it.

  • Steps may delete and recreate their subfolders

  • The clean step may remove the whole folder, which changes to Missing

Note

N/A

Satisfies

Verification Criteria

Run a build step twice and the clean step on a marked output folder. Check that the subfolders are recreated and the folder is removed.

sw_arch_state_foreign

Attribute Name

Attribute Value

Description

State Foreign

The output folder has content but no marker file, e.g. because paths.output names a source folder by mistake. Every step that would delete something stops with a build error and exit code 2, and the folder content stays unchanged.

Note

N/A

Satisfies

Verification Criteria

Configure a folder with content as output folder and run the clean and build steps. Check the error, the exit code and that the content is unchanged.