-
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
Open
hoe-jo
wants to merge
3
commits into
main
Choose a base branch
from
joho_rst_report
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
lobster-rst-report #588
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| # 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. | | ||
|
mugdhadhole1 marked this conversation as resolved.
|
||
|
|
||
| `--out` and `--out-dir` are mutually exclusive. | ||
|
|
||
| ### Choosing `--source-root` | ||
|
|
||
| File references in a `.lobster` report are relative to the workspace root | ||
| (e.g. `src/module/foo.cpp`). `--source-root` turns those paths into | ||
| clickable URLs by prepending a prefix. A trailing `/` is optional — if it is | ||
| missing, one is added automatically (so both `../../` and `../..` work). | ||
|
|
||
| **Example 1 — GitHub permalink** (links point to a specific branch/commit | ||
| on GitHub): | ||
|
|
||
| ```bash | ||
| lobster-rst-report report.lobster \ | ||
| --out-dir docs/traceability/ \ | ||
| --source-root "https://github.com/org/repo/blob/main/" | ||
| # src/module/foo.cpp → https://github.com/org/repo/blob/main/src/module/foo.cpp | ||
| ``` | ||
|
|
||
| **Example 2 — Relative local link** (links point to source files served | ||
| alongside the HTML documentation): | ||
|
|
||
| ``` | ||
| project/ | ||
| src/module/foo.cpp ← file reference: "src/module/foo.cpp" | ||
| docs/ | ||
| conf.py | ||
| traceability/ ← --out-dir target, two levels below project root | ||
| ``` | ||
|
|
||
| ```bash | ||
| lobster-rst-report report.lobster \ | ||
| --out-dir docs/traceability/ \ | ||
| --source-root "../../" | ||
| # src/module/foo.cpp → ../../src/module/foo.cpp (relative to the RST file) | ||
| ``` | ||
|
|
||
| If `--source-root` is omitted, file references appear as plain text paths | ||
| without hyperlinks. | ||
|
|
||
| ### 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"] | ||
| ``` | ||
|
|
||
| > **Note:** `project`, `author`, and `copyright` are standard Sphinx | ||
| > settings that you configure for your own documentation project. | ||
| > `lobster-rst-report` generates RST content only — it does not create or | ||
| > modify `conf.py`. Each project sets these values independently. | ||
|
|
||
| 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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) 2026 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()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.