-
Notifications
You must be signed in to change notification settings - Fork 18
lobster-rst-report #588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
lobster-rst-report #588
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # lobster-rst-report | ||
|
|
||
| Generate reStructuredText (RST) traceability reports from LOBSTER | ||
| report files, for inclusion in a Sphinx documentation project. | ||
|
|
||
| ## Overview | ||
|
|
||
| `lobster-rst-report` converts a `.lobster` report file into RST that | ||
| can be built by Sphinx. The output uses | ||
| [sphinx-design](https://sphinx-design.readthedocs.io/) directives | ||
| (dropdowns, grids, cards) for a rich presentation and | ||
| [sphinx.ext.graphviz](https://www.sphinx-doc.org/en/master/usage/extensions/graphviz.html) | ||
| for the tracing policy diagram. | ||
|
|
||
| Two output modes are available: | ||
|
|
||
| * **Single-page** (`--out FILE`) — one RST file containing the entire | ||
| report. | ||
| * **Multi-page** (`--out-dir DIR`) — an `index.rst` plus one RST file | ||
| per tracing level, linked via `toctree` directives. | ||
|
|
||
| ## Installation | ||
|
|
||
| `lobster-rst-report` is included in the `bmw-lobster-core` and | ||
| `bmw-lobster-monolithic` packages. | ||
|
|
||
| Your Sphinx project additionally requires: | ||
|
|
||
| ``` | ||
| pip install sphinx-design | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ``` | ||
| lobster-rst-report [LOBSTER_REPORT] [--out FILE | --out-dir DIR] [--source-root PREFIX] | ||
| ``` | ||
|
|
||
| | Argument | Description | | ||
| |---|---| | ||
| | `LOBSTER_REPORT` | Path to the `.lobster` report file (default: `report.lobster`). | | ||
| | `--out FILE` | Write a single-page RST report to `FILE` (default: `lobster_report.rst`). | | ||
| | `--out-dir DIR` | Write a multi-page RST report to `DIR` (index.rst + one page per level). | | ||
| | `--source-root PREFIX` | Prefix prepended to file reference URLs. Use this when the RST output directory differs from the workspace root. | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| `--out` and `--out-dir` are mutually exclusive. | ||
|
|
||
| ### Example | ||
|
|
||
| ```bash | ||
| # Generate a multi-page RST report | ||
| lobster-rst-report report.lobster --out-dir docs/traceability | ||
|
|
||
| # Generate a single-page RST report | ||
| lobster-rst-report report.lobster --out docs/traceability.rst | ||
| ``` | ||
|
|
||
| ## Sphinx project setup | ||
|
|
||
| Your Sphinx `conf.py` must load the required extensions: | ||
|
|
||
| ```python | ||
| extensions = ["sphinx_design", "sphinx.ext.graphviz"] | ||
| ``` | ||
|
|
||
| For multi-page mode, include the generated `index.rst` via a `toctree` | ||
| in your main documentation: | ||
|
|
||
| ```rst | ||
| .. toctree:: | ||
| :maxdepth: 2 | ||
| :caption: Traceability | ||
|
|
||
| traceability/index | ||
| ``` | ||
|
|
||
| ### Optional: custom CSS | ||
|
|
||
| The generated RST uses the CSS class `lobster-issue-card` for issue | ||
| message cards. You can style them in a custom stylesheet: | ||
|
|
||
| ```css | ||
| .lobster-issue-card .sd-card-body { | ||
| background-color: #f8d7da; | ||
| } | ||
| .lobster-issue-card { | ||
| border: 2px solid #dc3545; | ||
| } | ||
| ``` | ||
|
|
||
| ## Bazel integration | ||
|
|
||
| The tool is available as a Bazel subrule for use in custom rules: | ||
|
|
||
| ```starlark | ||
| load("//:lobster.bzl", "subrule_lobster_rst_report") | ||
| ``` | ||
|
|
||
| The subrule accepts a `.lobster` report file and produces a single-page | ||
| `.rst` file. It automatically computes `--source-root` based on the | ||
| package depth so that file reference links resolve correctly. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/usr/bin/env python3 | ||
| # | ||
| # LOBSTER - Lightweight Open BMW Software Traceability Evidence Report | ||
| # Copyright (C) 2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Affero General Public License as | ||
| # published by the Free Software Foundation, either version 3 of the | ||
| # License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, but | ||
| # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| # Affero General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Affero General Public | ||
| # License along with this program. If not, see | ||
| # <https://www.gnu.org/licenses/>. | ||
|
|
||
| import sys | ||
|
|
||
| from lobster.tools.core.rst_report.rst_report import main | ||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/usr/bin/env python3 | ||
| # | ||
| # LOBSTER - Lightweight Open BMW Software Traceability Evidence Report | ||
| # Copyright (C) 2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Affero General Public License as | ||
| # published by the Free Software Foundation, either version 3 of the | ||
| # License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, but | ||
| # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| # Affero General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Affero General Public | ||
| # License along with this program. If not, see | ||
| # <https://www.gnu.org/licenses/>. | ||
| """Shared Graphviz utilities for LOBSTER report tools.""" | ||
|
|
||
| import subprocess | ||
| from typing import Optional | ||
|
|
||
|
|
||
| def is_dot_available(dot: Optional[str] = None) -> bool: | ||
| """Return True if the ``dot`` executable (Graphviz) is on PATH. | ||
|
|
||
| Args: | ||
| dot: Optional explicit path to the ``dot`` binary. When ``None`` | ||
| (default) the system PATH is searched. | ||
|
|
||
| Returns: | ||
| ``True`` if Graphviz ``dot`` is available, ``False`` otherwise. | ||
| """ | ||
| try: | ||
| subprocess.run( | ||
| [dot if dot else "dot", "-V"], | ||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.PIPE, | ||
| encoding="UTF-8", | ||
| check=True, | ||
| timeout=5, | ||
| ) | ||
| return True | ||
| except (FileNotFoundError, subprocess.TimeoutExpired, | ||
| subprocess.CalledProcessError): | ||
| return False |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can someone generate a visualized report using these rst files?
Should generating html files be part of the rst tool?