sphinx-needs-trace 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+
2
+ MIT License
3
+
4
+ Copyright (c) 2026 cuinixam
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: sphinx-needs-trace
3
+ Version: 0.1.0
4
+ Summary: Traceability findings, totals, an interactive trace graph and a merge of needs.json files for sphinx-needs.
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Author: cuinixam
8
+ Author-email: cuinixam@gmail.com
9
+ Requires-Python: >=3.11
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Framework :: Sphinx :: Extension
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Natural Language :: English
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Documentation :: Sphinx
21
+ Requires-Dist: sphinx (>=7.4)
22
+ Requires-Dist: sphinx-needs (>=9.3)
23
+ Project-URL: Bug Tracker, https://github.com/yanga-project/sphinx-needs-trace/issues
24
+ Project-URL: Changelog, https://github.com/yanga-project/sphinx-needs-trace/blob/main/CHANGELOG.md
25
+ Project-URL: Repository, https://github.com/yanga-project/sphinx-needs-trace
26
+ Description-Content-Type: text/markdown
27
+
28
+ # sphinx-needs-trace
29
+
30
+ A Sphinx extension for projects that use [sphinx-needs](https://sphinx-needs.readthedocs.io): see in the report what is traced and what is missing.
31
+
32
+ - `traceability-findings`: the findings of the sphinx-needs schema rules as a table.
33
+ - `traceability-totals`: total, traced and missing per type.
34
+ - `trace-graph`: a link to an interactive trace graph page with search and a view per trace item.
35
+ - `merge_needs_files`: merge the `needs.json` files of several builds of one product into one file that `needimport` reads.
36
+
37
+ A trace item is one element of the trace chain: a requirement, a spec, an implementation, a test, a test result. sphinx-needs calls it a "need".
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install sphinx-needs-trace
43
+ ```
44
+
45
+ It needs Python 3.11 or newer and sphinx-needs 9.3 or newer.
46
+
47
+ ## Usage
48
+
49
+ In `conf.py`:
50
+
51
+ ```python
52
+ extensions = ["sphinx_needs", "sphinx_needs_trace"]
53
+ ```
54
+
55
+ On a page:
56
+
57
+ ```rst
58
+ .. traceability-totals::
59
+
60
+ .. traceability-findings::
61
+
62
+ .. trace-graph::
63
+ ```
64
+
65
+ The [documentation](docs/index.md) describes the directives, the graph page and the merge functions.
66
+
67
+ ## Third-party code
68
+
69
+ The package contains a copy of [Cytoscape.js](https://js.cytoscape.org) 3.35.0 (`src/sphinx_needs_trace/static/cytoscape.min.js`), which draws the trace graph. Cytoscape.js is under the MIT licence; its licence text is next to the copy in `cytoscape.LICENSE`.
70
+
71
+ ## Development
72
+
73
+ ```bash
74
+ pipx install pypeline-runner
75
+ pypeline run
76
+ ```
77
+
78
+ `pypeline run` creates the virtual environment with uv, runs pre-commit, the tests and the docs build. uv and pipx are needed on macOS, Ubuntu and Windows; there are no other system dependencies.
79
+
80
+ ## Licence
81
+
82
+ MIT, see [LICENSE](LICENSE).
83
+
@@ -0,0 +1,55 @@
1
+ # sphinx-needs-trace
2
+
3
+ A Sphinx extension for projects that use [sphinx-needs](https://sphinx-needs.readthedocs.io): see in the report what is traced and what is missing.
4
+
5
+ - `traceability-findings`: the findings of the sphinx-needs schema rules as a table.
6
+ - `traceability-totals`: total, traced and missing per type.
7
+ - `trace-graph`: a link to an interactive trace graph page with search and a view per trace item.
8
+ - `merge_needs_files`: merge the `needs.json` files of several builds of one product into one file that `needimport` reads.
9
+
10
+ A trace item is one element of the trace chain: a requirement, a spec, an implementation, a test, a test result. sphinx-needs calls it a "need".
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pip install sphinx-needs-trace
16
+ ```
17
+
18
+ It needs Python 3.11 or newer and sphinx-needs 9.3 or newer.
19
+
20
+ ## Usage
21
+
22
+ In `conf.py`:
23
+
24
+ ```python
25
+ extensions = ["sphinx_needs", "sphinx_needs_trace"]
26
+ ```
27
+
28
+ On a page:
29
+
30
+ ```rst
31
+ .. traceability-totals::
32
+
33
+ .. traceability-findings::
34
+
35
+ .. trace-graph::
36
+ ```
37
+
38
+ The [documentation](docs/index.md) describes the directives, the graph page and the merge functions.
39
+
40
+ ## Third-party code
41
+
42
+ The package contains a copy of [Cytoscape.js](https://js.cytoscape.org) 3.35.0 (`src/sphinx_needs_trace/static/cytoscape.min.js`), which draws the trace graph. Cytoscape.js is under the MIT licence; its licence text is next to the copy in `cytoscape.LICENSE`.
43
+
44
+ ## Development
45
+
46
+ ```bash
47
+ pipx install pypeline-runner
48
+ pypeline run
49
+ ```
50
+
51
+ `pypeline run` creates the virtual environment with uv, runs pre-commit, the tests and the docs build. uv and pipx are needed on macOS, Ubuntu and Windows; there are no other system dependencies.
52
+
53
+ ## Licence
54
+
55
+ MIT, see [LICENSE](LICENSE).
@@ -0,0 +1,144 @@
1
+ [build-system]
2
+ build-backend = "poetry.core.masonry.api"
3
+ requires = [ "poetry-core>=2,<3" ]
4
+
5
+ [project]
6
+ name = "sphinx-needs-trace"
7
+ version = "0.1.0"
8
+ description = "Traceability findings, totals, an interactive trace graph and a merge of needs.json files for sphinx-needs."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ authors = [
12
+ { name = "cuinixam", email = "cuinixam@gmail.com" },
13
+ ]
14
+ requires-python = ">=3.11"
15
+ classifiers = [
16
+ "Development Status :: 2 - Pre-Alpha",
17
+ "Framework :: Sphinx :: Extension",
18
+ "Intended Audience :: Developers",
19
+ "Natural Language :: English",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Topic :: Documentation :: Sphinx",
27
+ ]
28
+ dependencies = [
29
+ "sphinx>=7.4",
30
+ "sphinx-needs>=9.3",
31
+ ]
32
+ urls."Bug Tracker" = "https://github.com/yanga-project/sphinx-needs-trace/issues"
33
+ urls.Changelog = "https://github.com/yanga-project/sphinx-needs-trace/blob/main/CHANGELOG.md"
34
+ urls.repository = "https://github.com/yanga-project/sphinx-needs-trace"
35
+
36
+ [dependency-groups]
37
+ dev = [
38
+ "furo",
39
+ # docs
40
+ "myst-parser>=4,<6",
41
+ # the wheel test builds with the build backend
42
+ "poetry-core>=2,<3",
43
+ "pre-commit>=4,<5",
44
+ "pypeline-runner>=1,<2",
45
+ "pytest==9.*",
46
+ "pytest-cov==7.*",
47
+ "ruff>=0,<1",
48
+ # the test results of the sample project
49
+ "sphinx-test-reports>=1.3",
50
+ ]
51
+
52
+ [tool.ruff]
53
+ line-length = 180
54
+ lint.select = [
55
+ "B", # flake8-bugbear
56
+ "C4", # flake8-comprehensions
57
+ "D", # flake8-docstrings
58
+ "E", # pycodestyle
59
+ "F", # pyflake
60
+ "I", # isort
61
+ "RUF", # ruff specific
62
+ "S", # flake8-bandit
63
+ "UP", # pyupgrade
64
+ "W", # pycodestyle
65
+ ]
66
+ lint.ignore = [
67
+ "D100", # Missing docstring in public module
68
+ "D101", # Missing docstring in public class
69
+ "D102", # Missing docstring in public method
70
+ "D103", # Missing docstring in public function
71
+ "D104", # Missing docstring in public package
72
+ "D105", # Missing docstring in magic method
73
+ "D106", # Missing docstring in public nested class
74
+ "D107", # Missing docstring in `__init__`
75
+ "D203", # 1 blank line required before class docstring
76
+ "D212", # Multi-line docstring summary should start at the first line
77
+ "D401", # First line of docstring should be in imperative mood
78
+ ]
79
+ lint.per-file-ignores."tests/**/*" = [
80
+ "S101",
81
+ ]
82
+ lint.isort.known-first-party = [ "sphinx_needs_trace", "tests" ]
83
+
84
+ [tool.pyproject-fmt]
85
+ max_supported_python = "3.14"
86
+
87
+ [tool.pytest]
88
+ minversion = "9.0"
89
+ addopts = [
90
+ "-v",
91
+ "-Wonce",
92
+ "-p no:doctest",
93
+ "--cov=sphinx_needs_trace",
94
+ "--cov-report=term",
95
+ "--cov-report=xml",
96
+ ]
97
+ pythonpath = [ "src" ]
98
+ testpaths = [ "tests" ]
99
+
100
+ [tool.coverage]
101
+ run.branch = true
102
+
103
+ [tool.mypy]
104
+ check_untyped_defs = true
105
+ disallow_any_generics = true
106
+ disallow_incomplete_defs = true
107
+ disallow_untyped_defs = true
108
+ mypy_path = "src/"
109
+ no_implicit_optional = true
110
+ show_error_codes = true
111
+ warn_unreachable = true
112
+ warn_unused_ignores = true
113
+ exclude = [
114
+ "docs/.*",
115
+ "tests/sample/.*",
116
+ ]
117
+ disable_error_code = [ "import-untyped" ]
118
+
119
+ [tool.semantic_release]
120
+ allow_zero_version = true
121
+ version_toml = [ "pyproject.toml:project.version" ]
122
+ version_variables = [
123
+ "src/sphinx_needs_trace/__init__.py:__version__",
124
+ ]
125
+ build_command = """
126
+ pip install uv
127
+ uv lock
128
+ git add uv.lock
129
+ uv build
130
+ """
131
+ branches.main.match = "main"
132
+ branches.noop.match = "(?!main$)"
133
+ branches.noop.prerelease = true
134
+ changelog.exclude_commit_patterns = [
135
+ "chore(?:\\([^)]*?\\))?: .+",
136
+ "ci(?:\\([^)]*?\\))?: .+",
137
+ "refactor(?:\\([^)]*?\\))?: .+",
138
+ "style(?:\\([^)]*?\\))?: .+",
139
+ "test(?:\\([^)]*?\\))?: .+",
140
+ "build\\((?!deps\\): .+)",
141
+ "Merged? .*",
142
+ "Initial [Cc]ommit.*", # codespell:ignore
143
+ ]
144
+ changelog.environment.keep_trailing_newline = true
@@ -0,0 +1,38 @@
1
+ """
2
+ Traceability findings, totals, a trace graph and a merge of ``needs.json`` files for sphinx-needs.
3
+
4
+ ``extensions.append("sphinx_needs_trace")`` registers the directives; the merge functions need no Sphinx build.
5
+ """
6
+
7
+ from typing import Any
8
+
9
+ from sphinx.application import Sphinx
10
+ from sphinx_needs.api import add_field
11
+
12
+ from sphinx_needs_trace import findings, graph
13
+ from sphinx_needs_trace.merge import merge_needs_files, merge_trace_items, needs_file
14
+
15
+ __version__ = "0.1.0"
16
+
17
+ __all__ = ["merge_needs_files", "merge_trace_items", "needs_file", "setup"]
18
+
19
+
20
+ def setup(app: Sphinx) -> dict[str, Any]:
21
+ # The fields the merge writes, so that a project that imports a merged file declares nothing. sphinx-needs clears its fields in its own setup.
22
+ app.setup_extension("sphinx_needs")
23
+ names: dict[str, Any] = {"type": "array", "items": {"type": "string"}}
24
+ add_field("platforms", "Names of the builds that have the trace item", schema=names, default=[])
25
+ add_field("conflicting_fields", "Names of the fields that differ between the builds", schema=names, default=[])
26
+ app.add_node(findings.traceability_findings)
27
+ app.add_directive("traceability-findings", findings.TraceabilityFindingsDirective)
28
+ app.add_node(findings.traceability_totals)
29
+ app.add_directive("traceability-totals", findings.TraceabilityTotalsDirective)
30
+ app.connect("doctree-resolved", findings.fill_findings)
31
+ app.connect("doctree-resolved", findings.fill_totals)
32
+ app.connect("env-get-outdated", findings.pages_with_findings)
33
+ app.add_node(graph.trace_graph_link)
34
+ app.add_directive("trace-graph", graph.TraceGraphDirective)
35
+ app.connect("doctree-resolved", graph.fill_links)
36
+ app.connect("builder-inited", graph.add_static_files)
37
+ app.connect("build-finished", graph.write_graph_page)
38
+ return {"version": __version__, "parallel_read_safe": True, "parallel_write_safe": True}
@@ -0,0 +1,203 @@
1
+ """
2
+ The ``traceability-findings`` directive: the findings of the sphinx-needs schema rules as a table.
3
+
4
+ sphinx-needs writes its findings to ``schema_violations.json`` in the output folder when writing starts,
5
+ before any page is written, but has no directive that shows them. This directive places a node that is
6
+ filled from that file when its page is written, in every build. It never fails the build.
7
+ """
8
+
9
+ import json
10
+ import re
11
+ from collections import Counter
12
+ from collections.abc import Callable
13
+ from dataclasses import dataclass
14
+ from pathlib import Path
15
+ from typing import Any, ClassVar
16
+
17
+ from docutils import nodes
18
+ from docutils.parsers.rst import directives
19
+ from sphinx.application import Sphinx
20
+ from sphinx.environment import BuildEnvironment
21
+ from sphinx.util.docutils import SphinxDirective
22
+ from sphinx.util.typing import OptionSpec
23
+ from sphinx_needs.api import get_needs_view
24
+
25
+ FINDINGS_FILE = "schema_violations.json"
26
+ SEVERITY_ORDER = ("violation", "warning", "info")
27
+ # Set in the metadata of a page that has one of the directives.
28
+ SHOWS_FINDINGS = "traceability_findings"
29
+ NO_FINDINGS = "No findings: every trace item of this report satisfies the traceability rules."
30
+ NOT_CHECKED = f"The traceability rules were not checked: this build has no {FINDINGS_FILE}."
31
+
32
+
33
+ @dataclass(frozen=True)
34
+ class Finding:
35
+ need: str
36
+ rule: str
37
+ severity: str
38
+ message: str
39
+
40
+
41
+ def rule_name(schema_path: str) -> str:
42
+ """
43
+ The rule of a finding.
44
+
45
+ The findings file has no field for it, only ``schema_path``, whose first part is the rule's ``id``
46
+ and its index (``spec-is-tested[3] > validate > ...``).
47
+ """
48
+ return re.sub(r"\[\d+\]$", "", schema_path.split(" > ")[0])
49
+
50
+
51
+ def read_findings(report: dict[str, Any]) -> list[Finding]:
52
+ """The top-level findings of a findings file, most severe first."""
53
+ findings = [
54
+ Finding(
55
+ need=need,
56
+ rule=rule_name(warning["details"]["schema_path"]),
57
+ severity=warning["details"]["severity"],
58
+ message=warning["details"].get("user_msg") or warning["details"].get("validation_msg", ""),
59
+ )
60
+ for need, warnings in report.get("validation_warnings", {}).items()
61
+ for warning in warnings
62
+ ]
63
+ return sorted(findings, key=lambda f: (SEVERITY_ORDER.index(f.severity) if f.severity in SEVERITY_ORDER else len(SEVERITY_ORDER), f.rule, f.need))
64
+
65
+
66
+ def _table(header: list[str], rows: list[list[nodes.Node]], caption: str = "") -> nodes.table:
67
+ group = nodes.tgroup(cols=len(header))
68
+ group += [nodes.colspec(colwidth=1) for _ in header]
69
+ group += nodes.thead("", nodes.row("", *[nodes.entry("", nodes.paragraph(text=title)) for title in header]))
70
+ group += nodes.tbody("", *[nodes.row("", *[nodes.entry("", cell) for cell in row]) for row in rows])
71
+ return nodes.table("", *([nodes.title(text=caption)] if caption else []), group)
72
+
73
+
74
+ def render(
75
+ findings: list[Finding] | None,
76
+ need_link: Callable[[str], nodes.Node],
77
+ need_type: Callable[[str], str],
78
+ need_platforms: Callable[[str], str] | None = None,
79
+ ) -> list[nodes.Node]:
80
+ """The count per rule and the table of findings, or the "no findings" line. A Platforms column follows Type when ``need_platforms`` is given."""
81
+ if findings is None:
82
+ return [nodes.paragraph(text=NOT_CHECKED)]
83
+ if not findings:
84
+ return [nodes.paragraph(text=NO_FINDINGS)]
85
+ counts = Counter(finding.rule for finding in findings)
86
+ return [
87
+ _table(["Rule", "Findings"], [[nodes.paragraph(text=rule), nodes.paragraph(text=str(count))] for rule, count in sorted(counts.items())], "Findings per rule"),
88
+ _table(
89
+ ["Trace item", "Type", *(["Platforms"] if need_platforms else []), "Rule", "Severity", "Message"],
90
+ [
91
+ [
92
+ nodes.paragraph("", "", need_link(finding.need)),
93
+ nodes.paragraph(text=need_type(finding.need)),
94
+ *([nodes.paragraph(text=need_platforms(finding.need))] if need_platforms else []),
95
+ nodes.paragraph(text=finding.rule),
96
+ nodes.paragraph(text=finding.severity),
97
+ nodes.paragraph(text=finding.message),
98
+ ]
99
+ for finding in findings
100
+ ],
101
+ "Trace items with findings",
102
+ ),
103
+ ]
104
+
105
+
106
+ def totals(types: list[tuple[str, str]], trace_items: dict[str, str], findings: list[Finding]) -> list[tuple[str, int, int, int]]:
107
+ """Per type: (title, total, traced, missing). Missing counts the trace items with at least one finding."""
108
+ with_finding = {finding.need for finding in findings}
109
+ rows = []
110
+ for type_name, title in types:
111
+ ids = [item_id for item_id, item_type in trace_items.items() if item_type == type_name]
112
+ missing = sum(item_id in with_finding for item_id in ids)
113
+ rows.append((title, len(ids), len(ids) - missing, missing))
114
+ return rows
115
+
116
+
117
+ def selected_types(schema_definitions: dict[str, Any], need_types: list[dict[str, Any]]) -> list[tuple[str, str]]:
118
+ """The (type, title) of every type a schema rule selects, in the order of ``needs_types``."""
119
+ selected: set[str] = set()
120
+ for schema in schema_definitions.get("schemas", []):
121
+ type_select = schema.get("select", {}).get("properties", {}).get("type", {})
122
+ selected.update([type_select["const"]] if "const" in type_select else type_select.get("enum", []))
123
+ return [(t["directive"], t["title"]) for t in need_types if t["directive"] in selected]
124
+
125
+
126
+ class traceability_findings(nodes.General, nodes.Element):
127
+ """Filled with the findings when its page is written."""
128
+
129
+
130
+ class TraceabilityFindingsDirective(SphinxDirective):
131
+ option_spec: ClassVar[OptionSpec] = {"platforms": directives.flag}
132
+
133
+ def run(self) -> list[nodes.Node]:
134
+ self.env.metadata[self.env.docname][SHOWS_FINDINGS] = True
135
+ return [traceability_findings(platforms="platforms" in self.options)]
136
+
137
+
138
+ class traceability_totals(nodes.General, nodes.Element):
139
+ """Filled with the totals per trace item type when its page is written."""
140
+
141
+
142
+ class TraceabilityTotalsDirective(SphinxDirective):
143
+ def run(self) -> list[nodes.Node]:
144
+ self.env.metadata[self.env.docname][SHOWS_FINDINGS] = True
145
+ return [traceability_totals()]
146
+
147
+
148
+ def pages_with_findings(app: Sphinx, env: BuildEnvironment, added: set[str], changed: set[str], removed: set[str]) -> list[str]:
149
+ """A change on any page can change the findings, so a page that shows them is read again in every build."""
150
+ return [docname for docname, metadata in env.metadata.items() if metadata.get(SHOWS_FINDINGS)]
151
+
152
+
153
+ def load_findings(app: Sphinx) -> list[Finding] | None:
154
+ """The findings of this build; None when sphinx-needs wrote no findings file, so the rules did not run."""
155
+ findings_file = Path(app.outdir) / FINDINGS_FILE
156
+ return read_findings(json.loads(findings_file.read_text(encoding="utf-8"))) if findings_file.is_file() else None
157
+
158
+
159
+ def fill_totals(app: Sphinx, doctree: nodes.document, docname: str) -> None:
160
+ placeholders = list(doctree.findall(traceability_totals))
161
+ if not placeholders:
162
+ return
163
+ findings = load_findings(app)
164
+ if findings is None:
165
+ table: nodes.Node = nodes.paragraph(text=NOT_CHECKED)
166
+ else:
167
+ trace_items = {need_id: need["type"] for need_id, need in get_needs_view(app).items()}
168
+ rows = totals(selected_types(app.config.needs_schema_definitions, app.config.needs_types), trace_items, findings)
169
+ table = _table(["Type", "Total", "Traced", "Missing"], [[nodes.paragraph(text=str(value)) for value in row] for row in rows])
170
+ for placeholder in placeholders:
171
+ placeholder.replace_self(table.deepcopy())
172
+
173
+
174
+ def fill_findings(app: Sphinx, doctree: nodes.document, docname: str) -> None:
175
+ placeholders = list(doctree.findall(traceability_findings))
176
+ if not placeholders:
177
+ return
178
+ findings = load_findings(app)
179
+ needs = get_needs_view(app)
180
+
181
+ def need_link(need_id: str) -> nodes.Node:
182
+ need = needs.get(need_id)
183
+ if not need or not need["docname"]:
184
+ return nodes.Text(need_id)
185
+ uri = f"{app.builder.get_relative_uri(docname, need['docname'])}#{need_id}"
186
+ return nodes.reference("", need_id, refuri=uri, internal=True)
187
+
188
+ def need_type(need_id: str) -> str:
189
+ need = needs.get(need_id)
190
+ return need["type_name"] if need else ""
191
+
192
+ def need_platforms(need_id: str) -> str:
193
+ need = needs.get(need_id)
194
+ # A project that merges no builds has no such field.
195
+ return ", ".join(need.get("platforms") or []) if need else ""
196
+
197
+ for placeholder in placeholders:
198
+ rendered = render(findings, need_link, need_type, need_platforms if placeholder["platforms"] else None)
199
+ for table in rendered:
200
+ # A table with a caption needs an ID, or Sphinx warns when it numbers the tables.
201
+ if isinstance(table, nodes.table):
202
+ doctree.set_id(table)
203
+ placeholder.replace_self(rendered)