Skip to main content

Supports the conversion from TRLC files to other formats.

Project description

pyTRLCConverter

License Repo Status CI Repo Status

pyTRLCConverter is a command-line tool to convert TRLC files to different output formats. Since the definition of TRLC types is project-specific, the built-in converters can be extended in an object-oriented manner.

Currently out of the box supported formats:

  • Markdown
  • docx
  • reStructuredText
  • dump

Find the requirements, test cases, coverage and etc. on the github pages.

Table of Contents

Overview

context

Find the requirements, test cases, coverage and etc. deployed on github pages.

Installation

Follow these steps to setup an editable pyTRLCConverter workspace using a virtual python environment.

Clone this Project

git clone https://github.com/NewTec-GmbH/pyTRLCConverter.git
cd pyTRLCConverter

Setup a virtual Python Environment

python -m venv .venv
.venv\Scripts\activate.ps1 # <- Windows Power Shell version

Note:

  • For Windows CMD shell, use .venv\Scripts\activate.bat to activate the virtual environment.
  • For Linux/Macos, use source .venv/bin/activate to activate the virtual environment.

Tool Installation

pip install -e .

Usage

Conversion to Markdown format

The tool requires two kinds of TRLC input sources for the conversion. These are the requirements (*.trlc) files and the model (*.tls) files. These input files are specified using one or more --source or -s options followed by a file name or directory path. If a path is given, all files with a .trlc or .tls extension are read by the tool.

pyTRLCConverter --source doc/models --source doc/sw-requirement markdown

It will create a Markdown file with the same name as the requirements file (*.trlc) in the current directory, but with the Markdown extension (.md).

If the requirements are split into several files, a Markdown file will be created for each. To generate a single Markdown file the argument --single-document can be used, which will create an output.md file by default.

The converter supports additional arguments that are shown by adding the --help option after the markdown subcommand.

pyTRLCConverter markdown --help

usage: pyTRLCConverter markdown [-h] [-n NAME] [-sd] [-tl TOP_LEVEL]

options:
  -h, --help            show this help message and exit
  -n NAME, --name NAME  Name of the generated output file inside the output folder (default = output.md) in case a single document is generated.
  -sd, --single-document
                        Generate a single document instead of multiple files. The default is to generate multiple files.
  -tl TOP_LEVEL, --top-level TOP_LEVEL
                        Name of the top level heading, required in single document mode. (default = Specification)

More examples are shown in the examples folder.

Conversion to docx format

Similar to the Markdown conversion, minimal required are the requirements (*.trlc) and the model (*.tls). Both can be added by file name or just the path where they are located.

pyTRLCConverter --source doc/models --source doc/sw-requirement docx

It will create a docx file with default name output.docx in the current directory.

If the requirements are split in several files, they will be all part of a single docx file.

The converter supports additional arguments that are shown by adding the --help option after the docx subcommand.

pyTRLCConverter docx --help

usage: pyTRLCConverter docx [-h] [-t TEMPLATE] [-n NAME]

options:
  -h, --help            show this help message and exit
  -t TEMPLATE, --template TEMPLATE
                        Load the given docx file as a template to append to.
  -n NAME, --name NAME  Name of the generated output file inside the output folder (default = output.docx).

Conversion to reStructuredText format

The tool requires two kinds of TRLC input sources for the conversion. These are the requirements (*.trlc) files and the model (*.tls) files. These input files are specified using one or more --source or -s options followed by a file name or directory path. If a path is given, all files with a .trlc or .tls extension are read by the tool.

pyTRLCConverter --source doc/models --source doc/sw-requirement rst

If the requirements are split into several files (*.trlc), a reStructuredText file will be created for each. To generate a single reStructuredText file the argument --single-document can be used, which will create an output.md file by default.

The converter supports additional arguments that are shown by adding the --help option after the reStructuredText subcommand.

pyTRLCConverter rst --help

usage: pyTRLCConverter rst [-h] [-e EMPTY] [-n NAME] [-sd] [-tl TOP_LEVEL]

options:
  -h, --help            show this help message and exit
  -e EMPTY, --empty EMPTY
                        Every attribute value which is empty will output the string (default = N/A).
  -n NAME, --name NAME  Name of the generated output file inside the output folder (default = output.rst) in case a single document is generated.
  -sd, --single-document
                        Generate a single document instead of multiple files. The default is to generate multiple files.
  -tl TOP_LEVEL, --top-level TOP_LEVEL
                        Name of the top level heading, required in single document mode (default = Specification).

More examples are shown in the examples folder.

Dump TRLC item list to console

Mainly for development all TRLC items can be dumped to the console.

pyTRLCConverter --source doc/models --source doc/sw-requirement dump

Show tool version

Show the version of the tool to see whether the required one is used.

pyTRLCConverter --help

PlantUML

With the PlantUML extension the tool supports the automatic diagram generation out of a PlantUML file.

Activate the support by adding the path to the java jar file to the PLANTUML environment variable.

Examples

Check out the all the Examples.

Compile into an executable

It is possible to create an executable file that contains the tool and all its dependencies. "PyInstaller" is used for this. Just run the following command on the root of the folder:

pyinstaller --noconfirm --onefile --console --name "pyTRLCConverter" --add-data "./pyproject.toml;."  "./src/pyTRLCConverter/__main__.py"

SW Documentation

More information on the deployment and architecture can be found in the documentation

For Detailed Software Design run $ /doc/detailed-design/make html to generate the detailed design documentation that then can be found in the folder /doc/detailed-design/_build/html/index.html

Tools

Tools used for development or automations, see Tools.

Used Libraries

Used 3rd party libraries which are not part of the standard Python package:

Library Description License
PlantUML Generate UML diagrams. GPL-3.0
python-docx Creation of Microsoft Word 2007+ (.docx) files. MIT
requests HTTP processing Apache-2.0
sphinx Using Sphinx for documentation deployment. BSD
toml Parsing TOML MIT
trlc Treat Requirements Like Code GPL-3.0

see also requirements.txt

Issues, Ideas And Bugs

If you have further ideas or you found some bugs, great! Create an issue or if you are able and willing to fix it by yourself, clone the repository and create a pull request.

License

The whole source code is published under GPL-3.0. Consider the different licenses of the used third party libraries too!

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytrlcconverter-1.0.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytrlcconverter-1.0.0-py3-none-any.whl (50.4 kB view details)

Uploaded Python 3

File details

Details for the file pytrlcconverter-1.0.0.tar.gz.

File metadata

  • Download URL: pytrlcconverter-1.0.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pytrlcconverter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8e386e6ba6301dd5c58d58a8514058fbdf6fcf487061994e8a2d9ca2020bbe58
MD5 df38bfdb687a365760e0c5806d4aa872
BLAKE2b-256 a563c6035eae7efdec78ca87ea977971bcd0f5d6d62c4353abc541b339d5b718

See more details on using hashes here.

File details

Details for the file pytrlcconverter-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytrlcconverter-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f2cefbadf51e6e563e6dc62369ab5836feec7fe7c02a208a0a48df043bdee17
MD5 c927fde6f850e1649297bea07d31e0e0
BLAKE2b-256 253ea74d8b72507115035064846be8912fe0933f075761c21fef70753c94fb40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page