sphinx-needs-trace 0.1.0__py3-none-any.whl
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.
- sphinx_needs_trace/__init__.py +38 -0
- sphinx_needs_trace/findings.py +203 -0
- sphinx_needs_trace/graph.py +162 -0
- sphinx_needs_trace/merge.py +69 -0
- sphinx_needs_trace/py.typed +0 -0
- sphinx_needs_trace/static/cytoscape.LICENSE +19 -0
- sphinx_needs_trace/static/cytoscape.min.js +32 -0
- sphinx_needs_trace/static/trace_graph.css +37 -0
- sphinx_needs_trace/static/trace_graph.js +181 -0
- sphinx_needs_trace/trace_graph_page.html +42 -0
- sphinx_needs_trace-0.1.0.dist-info/METADATA +83 -0
- sphinx_needs_trace-0.1.0.dist-info/RECORD +14 -0
- sphinx_needs_trace-0.1.0.dist-info/WHEEL +4 -0
- sphinx_needs_trace-0.1.0.dist-info/licenses/LICENSE +22 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* The standalone trace graph page of the trace-graph directive (sphinx_needs_trace/graph.py). */
|
|
2
|
+
body { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; margin: 0; height: 100vh; overflow: hidden; color: #212529; display: flex; }
|
|
3
|
+
/* Left: where to start. */
|
|
4
|
+
#side { width: 300px; flex: none; border-right: 1px solid #dee2e6; background: #fff; display: flex; flex-direction: column; }
|
|
5
|
+
#side h1 { font-size: 15px; margin: 0; padding: 14px 16px 4px; }
|
|
6
|
+
#side p { margin: 0; padding: 0 16px 10px; color: #6c757d; }
|
|
7
|
+
#side a { display: block; padding: 12px 16px 0; color: #0b5ed7; text-decoration: none; }
|
|
8
|
+
#search { margin: 0 16px 10px; height: 34px; box-sizing: border-box; padding: 0 12px; border: 1px solid #ced4da; border-radius: 4px; font-size: 14px; outline: none; }
|
|
9
|
+
#search:focus { border-color: #007bff; }
|
|
10
|
+
#list { overflow-y: auto; flex: 1; border-top: 1px solid #eee; }
|
|
11
|
+
#list h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; margin: 0; padding: 12px 16px 4px; }
|
|
12
|
+
#list div { padding: 6px 16px; cursor: pointer; }
|
|
13
|
+
#list div:hover { background: #f1f6ff; }
|
|
14
|
+
#list div.current { background: #e7f1ff; }
|
|
15
|
+
#list b { display: block; font-weight: 600; }
|
|
16
|
+
#list span { color: #6c757d; font-size: 12px; }
|
|
17
|
+
.warn { color: #c92a2a; }
|
|
18
|
+
/* Right: the graph and what floats on it. */
|
|
19
|
+
#main { position: relative; flex: 1; }
|
|
20
|
+
#cy { position: absolute; inset: 0; background: #fafbfc; }
|
|
21
|
+
.panel { position: absolute; z-index: 10; background: rgba(255,255,255,.96); border: 1px solid rgba(0,0,0,.08);
|
|
22
|
+
border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.1); }
|
|
23
|
+
#bar { top: 16px; left: 16px; padding: 8px 10px; display: flex; gap: 10px; align-items: center; }
|
|
24
|
+
#view-title { font-weight: 600; font-size: 14px; }
|
|
25
|
+
#view-count { color: #6c757d; }
|
|
26
|
+
#bar label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; margin-left: 6px; }
|
|
27
|
+
.btn { height: 32px; padding: 0 12px; background: #fff; color: #495057; border: 1px solid #ced4da; border-radius: 4px;
|
|
28
|
+
font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
|
|
29
|
+
.btn:hover { background: #f8f9fa; border-color: #adb5bd; color: #212529; }
|
|
30
|
+
.btn:disabled { opacity: .4; cursor: default; }
|
|
31
|
+
.btn.primary { background: #0b5ed7; border-color: #0b5ed7; color: #fff; }
|
|
32
|
+
#zoom { right: 16px; bottom: 16px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
|
|
33
|
+
#zoom .btn { width: 32px; padding: 0; justify-content: center; font-size: 16px; }
|
|
34
|
+
/* What you can do with the box you clicked. */
|
|
35
|
+
#selection { left: 50%; bottom: 16px; transform: translateX(-50%); padding: 10px 12px; display: none; align-items: center; gap: 10px; white-space: nowrap; }
|
|
36
|
+
#selection .name { max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
|
|
37
|
+
#selection .name span { color: #6c757d; }
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// The trace graph page of the trace-graph directive (sphinx_needs_trace/graph.py): boxes like a class diagram,
|
|
2
|
+
// a list of the trace items by type, and the trace of the chosen item up to the top of the chain and down to the test results.
|
|
3
|
+
// The settings say how to read the trace model (graph.py); no type and no link is named here.
|
|
4
|
+
const { settings, elements } = JSON.parse(document.querySelector(".trace-graph-data").textContent);
|
|
5
|
+
|
|
6
|
+
function escapeXml(text) { return text.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]); }
|
|
7
|
+
|
|
8
|
+
// A box like a class diagram: ID and title, a line, then the attributes.
|
|
9
|
+
function box(n) {
|
|
10
|
+
const header = [n.id, n.title.length > 48 ? n.title.slice(0, 47) + "…" : n.title];
|
|
11
|
+
const attributes = [`type: ${n.type_name}`];
|
|
12
|
+
if (n.platforms.length) attributes.push(`platforms: ${n.platforms.join(", ")}`);
|
|
13
|
+
if (n.result) attributes.push(`result: ${n.result}`);
|
|
14
|
+
for (const rule of n.findings) attributes.push(`finding: ${rule}`);
|
|
15
|
+
const width = Math.max(150, n.id.length * 8 + 20, ...[...header, ...attributes].map((l) => l.length * 7 + 20)); // the ID is bold, so wider
|
|
16
|
+
const sep = 2 * 16 + 10, height = sep + attributes.length * 16 + 10;
|
|
17
|
+
const red = (l) => l === "result: failed" || l.startsWith("finding:");
|
|
18
|
+
const text = (l, y, bold, fill) => `<text x="10" y="${y}"${bold ? ' font-weight="bold"' : ""} fill="${fill}">${escapeXml(l)}</text>`;
|
|
19
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width * 3}" height="${height * 3}" viewBox="0 0 ${width} ${height}" font-family="Helvetica Neue, Arial, sans-serif" font-size="12">` +
|
|
20
|
+
`<rect width="${width}" height="${sep}" fill="${settings.colors[n.type] || "#eef0f3"}" fill-opacity="0.6"/>` +
|
|
21
|
+
header.map((l, i) => text(l, 16 + i * 16, i === 0, "#212529")).join("") +
|
|
22
|
+
`<line x1="0" y1="${sep}" x2="${width}" y2="${sep}" stroke="#868e96"/>` +
|
|
23
|
+
attributes.map((l, i) => text(l, sep + 16 + i * 16, false, red(l) ? "#c92a2a" : "#495057")).join("") + "</svg>";
|
|
24
|
+
return { svg: "data:image/svg+xml;utf8," + encodeURIComponent(svg), w: width, h: height };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
for (const element of elements) {
|
|
28
|
+
if (!("source" in element.data)) Object.assign(element.data, box(element.data), { finding: element.data.findings.length > 0 });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const cy = cytoscape({
|
|
32
|
+
container: document.getElementById("cy"), elements, layout: { name: "preset" }, minZoom: 0.1, maxZoom: 3,
|
|
33
|
+
style: [
|
|
34
|
+
{ selector: "node", style: { shape: "round-rectangle", width: "data(w)", height: "data(h)", "background-color": "#fff",
|
|
35
|
+
"background-image": "data(svg)", "background-width": "100%", "background-height": "100%", "border-width": 1, "border-color": "#868e96" } },
|
|
36
|
+
{ selector: "node[?finding]", style: { "border-width": 2, "border-color": "#c92a2a" } },
|
|
37
|
+
{ selector: "edge", style: { "curve-style": "bezier", "target-arrow-shape": "triangle", width: 1.5, "line-color": "#adb5bd",
|
|
38
|
+
"target-arrow-color": "#adb5bd", label: "data(link)", "font-size": 10, color: "#6c757d", "text-background-color": "#fafbfc", "text-background-opacity": 1 } },
|
|
39
|
+
{ selector: ".start", style: { "border-width": 3, "border-color": "#0b5ed7", "underlay-color": "#0b5ed7", "underlay-opacity": 0.18, "underlay-padding": 10 } },
|
|
40
|
+
{ selector: ".selected", style: { "border-width": 3, "border-color": "#0b5ed7" } },
|
|
41
|
+
{ selector: "node[?finding].start, node[?finding].selected", style: { "border-color": "#c92a2a" } },
|
|
42
|
+
{ selector: ".faded", style: { opacity: 0.15 } },
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// A link points up the chain, except the ones the settings name: those point at what sits below.
|
|
47
|
+
const pointsDown = (edge) => settings.down_links.includes(edge.data("link"));
|
|
48
|
+
const pointsUp = (edge) => !pointsDown(edge);
|
|
49
|
+
const isResult = (n) => n.data("type") === settings.result_type;
|
|
50
|
+
const up = (n) => n.outgoers("edge").filter(pointsUp).targets().union(n.incomers("edge").filter(pointsDown).sources());
|
|
51
|
+
const down = (n) => n.incomers("edge").filter(pointsUp).sources().union(n.outgoers("edge").filter(pointsDown).targets());
|
|
52
|
+
function walk(node, step) {
|
|
53
|
+
let seen = cy.collection(), todo = node;
|
|
54
|
+
while (todo.nonempty()) { seen = seen.union(todo); todo = step(todo).difference(seen); }
|
|
55
|
+
return seen;
|
|
56
|
+
}
|
|
57
|
+
// Everything an item traces to: all the way up to the top of the chain, and all the way down to the test results.
|
|
58
|
+
function chain(node) { return walk(node, up).union(walk(node, down)); }
|
|
59
|
+
|
|
60
|
+
// A view is a title, the item it starts from (if any) and the boxes it shows. History lets Back return to the one before.
|
|
61
|
+
// The start view has every trace item; the test results come with the checkbox, as in every view.
|
|
62
|
+
const OVERVIEW = { title: "Start view", start: null, nodes: () => cy.nodes() };
|
|
63
|
+
let view = OVERVIEW, history = [], selected = null, showResults = false;
|
|
64
|
+
const el = (id) => document.getElementById(id);
|
|
65
|
+
|
|
66
|
+
function go(next) { history.push(view); view = next; render(); }
|
|
67
|
+
|
|
68
|
+
function render() {
|
|
69
|
+
let nodes = view.nodes();
|
|
70
|
+
// The checkbox is off in a view without test results.
|
|
71
|
+
el("show-results").disabled = nodes.filter(isResult).empty();
|
|
72
|
+
if (!showResults) nodes = nodes.filter((n) => !isResult(n));
|
|
73
|
+
const edges = nodes.edgesWith(nodes);
|
|
74
|
+
cy.elements().style("display", "none").removeClass("selected faded start");
|
|
75
|
+
nodes.union(edges).style("display", "element");
|
|
76
|
+
layers(nodes);
|
|
77
|
+
cy.fit(nodes, 80);
|
|
78
|
+
// A few boxes would fill the window at a huge size: never start zoomed in past normal size.
|
|
79
|
+
if (cy.zoom() > 1) { cy.zoom(1); cy.center(nodes); }
|
|
80
|
+
if (view.start) cy.getElementById(view.start).addClass("start");
|
|
81
|
+
select(null);
|
|
82
|
+
el("view-title").textContent = view.title;
|
|
83
|
+
el("view-count").textContent = `· ${nodes.length} trace items`;
|
|
84
|
+
el("back").disabled = history.length === 0;
|
|
85
|
+
el("overview").disabled = view === OVERVIEW;
|
|
86
|
+
drawList();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Layers from the top of the chain down, each row centred; a long row wraps, so the boxes stay readable.
|
|
90
|
+
const PER_ROW = 6;
|
|
91
|
+
function layers(nodes) {
|
|
92
|
+
// What a box hangs under: what it is linked up to, among the boxes shown.
|
|
93
|
+
const above = (n) => up(n).intersection(nodes);
|
|
94
|
+
const depth = new Map();
|
|
95
|
+
const depthOf = (n) => {
|
|
96
|
+
if (!depth.has(n.id())) {
|
|
97
|
+
depth.set(n.id(), 0); // also stops a cycle
|
|
98
|
+
depth.set(n.id(), above(n).reduce((max, parent) => Math.max(max, depthOf(parent) + 1), 0));
|
|
99
|
+
}
|
|
100
|
+
return depth.get(n.id());
|
|
101
|
+
};
|
|
102
|
+
const rows = [];
|
|
103
|
+
nodes.sort((a, b) => a.id().localeCompare(b.id())).forEach((n) => (rows[depthOf(n)] ||= []).push(n));
|
|
104
|
+
let y = 0;
|
|
105
|
+
for (const layer of rows.filter(Boolean)) {
|
|
106
|
+
for (let i = 0; i < layer.length; i += PER_ROW) {
|
|
107
|
+
const row = layer.slice(i, i + PER_ROW);
|
|
108
|
+
const width = row.reduce((sum, n) => sum + n.data("w") + 40, -40);
|
|
109
|
+
const height = Math.max(...row.map((n) => n.data("h")));
|
|
110
|
+
let x = -width / 2;
|
|
111
|
+
for (const n of row) { n.position({ x: x + n.data("w") / 2, y: y + height / 2 }); x += n.data("w") + 40; }
|
|
112
|
+
y += height + (i + PER_ROW < layer.length ? 30 : 90);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function traceOf(node) {
|
|
118
|
+
return { title: `Trace of ${node.id()}: ${node.data("title")}`, start: node.id(), nodes: () => chain(node) };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// A click highlights the box and its direct links, and offers what to do with it.
|
|
122
|
+
function select(node) {
|
|
123
|
+
selected = node;
|
|
124
|
+
cy.elements().removeClass("selected faded");
|
|
125
|
+
el("selection").style.display = node ? "flex" : "none";
|
|
126
|
+
if (!node) return;
|
|
127
|
+
cy.elements(":visible").not(node.closedNeighborhood()).addClass("faded");
|
|
128
|
+
node.addClass("selected");
|
|
129
|
+
el("open").disabled = !node.data("url");
|
|
130
|
+
el("selection").querySelector(".name").innerHTML = `<b>${escapeXml(node.id())}</b> <span>${escapeXml(node.data("title"))}</span>`;
|
|
131
|
+
}
|
|
132
|
+
cy.on("tap", (event) => select(event.target !== cy && event.target.isNode() ? event.target : null));
|
|
133
|
+
cy.on("dbltap", "node", (event) => go(traceOf(event.target)));
|
|
134
|
+
|
|
135
|
+
el("trace").onclick = () => go(traceOf(selected));
|
|
136
|
+
el("only").onclick = () => {
|
|
137
|
+
const node = selected, shown = node.closedNeighborhood().nodes(":visible");
|
|
138
|
+
go({ title: `${node.id()} and its direct links`, start: node.id(), nodes: () => shown });
|
|
139
|
+
};
|
|
140
|
+
el("open").onclick = () => window.open(selected.data("url"), "_blank");
|
|
141
|
+
el("back").onclick = () => { view = history.pop(); render(); };
|
|
142
|
+
el("overview").onclick = () => go(OVERVIEW);
|
|
143
|
+
el("show-results").onchange = (event) => { showResults = event.target.checked; render(); };
|
|
144
|
+
|
|
145
|
+
const zoomBy = (factor) => cy.zoom({ level: cy.zoom() * factor, renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 } });
|
|
146
|
+
el("zoom-in").onclick = () => zoomBy(1.3);
|
|
147
|
+
el("zoom-out").onclick = () => zoomBy(1 / 1.3);
|
|
148
|
+
el("fit").onclick = () => cy.fit(cy.elements(":visible"), 80);
|
|
149
|
+
|
|
150
|
+
// The list: the trace items under a heading per type, or the matches of the search.
|
|
151
|
+
function row(n) {
|
|
152
|
+
const warn = n.data("findings").length ? ' <span class="warn" title="Has a finding">⚠</span>' : "";
|
|
153
|
+
const current = view.start === n.id() ? ' class="current"' : "";
|
|
154
|
+
return `<div data-id="${escapeXml(n.id())}"${current}><b>${escapeXml(n.data("title"))}${warn}</b><span>${escapeXml(n.id())} · ${escapeXml(n.data("type_name"))}</span></div>`;
|
|
155
|
+
}
|
|
156
|
+
function drawList() {
|
|
157
|
+
const q = el("search").value.trim().toLowerCase();
|
|
158
|
+
if (q) {
|
|
159
|
+
const matches = cy.nodes().filter((n) => (showResults || !isResult(n)) && (n.id().toLowerCase().includes(q) || n.data("title").toLowerCase().includes(q)));
|
|
160
|
+
el("list").innerHTML = `<h2>${matches.length} matches</h2>` + matches.slice(0, 60).map(row).join("");
|
|
161
|
+
} else {
|
|
162
|
+
el("list").innerHTML = settings.types.map(([type, title]) => {
|
|
163
|
+
const rows = cy.nodes().filter((n) => n.data("type") === type && (showResults || !isResult(n)));
|
|
164
|
+
return rows.empty() ? "" : `<h2>${escapeXml(title)}</h2>` + rows.map(row).join("");
|
|
165
|
+
}).join("");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
el("search").addEventListener("input", drawList);
|
|
169
|
+
el("list").addEventListener("click", (event) => {
|
|
170
|
+
const item = event.target.closest("[data-id]");
|
|
171
|
+
if (item) go(traceOf(cy.getElementById(item.dataset.id)));
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// "#start=<ID>" in the address opens the page on the trace of that item; a title works too, the first type of the list wins.
|
|
175
|
+
const wanted = new URLSearchParams(location.hash.slice(1)).get("start") || "";
|
|
176
|
+
const byId = cy.getElementById(wanted);
|
|
177
|
+
const typeOrder = settings.types.map(([type]) => type);
|
|
178
|
+
const titled = cy.nodes().filter((n) => wanted && n.data("title") === wanted).sort((a, b) => typeOrder.indexOf(a.data("type")) - typeOrder.indexOf(b.data("type")));
|
|
179
|
+
const start = byId.nonempty() ? byId : titled.first();
|
|
180
|
+
if (start.nonempty()) go(traceOf(start));
|
|
181
|
+
else render();
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Trace graph: __TITLE__</title>
|
|
6
|
+
<link rel="stylesheet" href="_static/trace_graph.css">
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="side">
|
|
10
|
+
<a href="__BACK__">← Back to the report</a>
|
|
11
|
+
<h1>__TITLE__</h1>
|
|
12
|
+
<p>Choose a trace item. The graph shows everything it traces to, up and down.</p>
|
|
13
|
+
<input id="search" placeholder="Search any ID or title…" autocomplete="off">
|
|
14
|
+
<div id="list"></div>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<div id="main">
|
|
18
|
+
<div id="cy"></div>
|
|
19
|
+
<div id="bar" class="panel">
|
|
20
|
+
<button class="btn" id="back" title="The view you had before">← Back</button>
|
|
21
|
+
<button class="btn" id="overview" title="Back to the view the page starts with">⌂ Start view</button>
|
|
22
|
+
<span><span id="view-title"></span> <span id="view-count"></span></span>
|
|
23
|
+
<label title="Show the test results too; there may be many"><input type="checkbox" id="show-results"> Test results</label>
|
|
24
|
+
</div>
|
|
25
|
+
<div id="zoom" class="panel">
|
|
26
|
+
<button class="btn" id="zoom-in" title="Zoom in">+</button>
|
|
27
|
+
<button class="btn" id="zoom-out" title="Zoom out">−</button>
|
|
28
|
+
<button class="btn" id="fit" title="Fit everything shown into the window">⤢</button>
|
|
29
|
+
</div>
|
|
30
|
+
<div id="selection" class="panel">
|
|
31
|
+
<div class="name"></div>
|
|
32
|
+
<button class="btn primary" id="trace" title="Redraw with everything this item traces to, up and down">Show its whole trace</button>
|
|
33
|
+
<button class="btn" id="only" title="Redraw with only this box and the boxes directly linked to it">Hide everything else</button>
|
|
34
|
+
<button class="btn" id="open" title="Open the entry of this trace item in this report">Open in report</button>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
__DATA__
|
|
39
|
+
<script src="_static/cytoscape.min.js"></script>
|
|
40
|
+
<script src="_static/trace_graph.js"></script>
|
|
41
|
+
</body>
|
|
42
|
+
</html>
|
|
@@ -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,14 @@
|
|
|
1
|
+
sphinx_needs_trace/__init__.py,sha256=BZ0j6DsDJOaX5NyNnEmZyX6tm-AGxqjOBQvU9PsGovE,1897
|
|
2
|
+
sphinx_needs_trace/findings.py,sha256=ne3OqFM4_zCXIJyZAQ0pcFnyokuCXkBNpRyv-9PkDC4,9018
|
|
3
|
+
sphinx_needs_trace/graph.py,sha256=GQEv1LUaSIcVLXnLlylJ9AP1W6on4QALP7vFK07UW44,7694
|
|
4
|
+
sphinx_needs_trace/merge.py,sha256=riXp7Zxh_rj6dWHlcayU_a_PSTgJJnNki0OrOjkDTBg,3623
|
|
5
|
+
sphinx_needs_trace/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
sphinx_needs_trace/static/cytoscape.LICENSE,sha256=6zGcbm8jNgf3Ho4vRQORdRiDz8Dus8p-9XTBPR2cIgM,1082
|
|
7
|
+
sphinx_needs_trace/static/cytoscape.min.js,sha256=cfqevsIafKLEDP9qrMMNH2Rk42NmKtSywZfhrcdwzZQ,442752
|
|
8
|
+
sphinx_needs_trace/static/trace_graph.css,sha256=qk71fXu8sjnDiF_CR7KmlwkK_GaFT8JscjqYj7c_uG0,2838
|
|
9
|
+
sphinx_needs_trace/static/trace_graph.js,sha256=6mHWdY3XcHSlik8EKlRAKZCct3z1eOVPFWePeRyl7Do,10500
|
|
10
|
+
sphinx_needs_trace/trace_graph_page.html,sha256=WnEBkrPz-qQM3jbGm1T2xz7Bw1MhpthV8vrkwyvMdeQ,1781
|
|
11
|
+
sphinx_needs_trace-0.1.0.dist-info/METADATA,sha256=7aayn8bRLiDaRziS1ZogYTPjYpgMzeol_R8POFHM8_I,2886
|
|
12
|
+
sphinx_needs_trace-0.1.0.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
|
|
13
|
+
sphinx_needs_trace-0.1.0.dist-info/licenses/LICENSE,sha256=vnZL3nl_vqIn7qBQr9Bs7_rjw_msOztV76MEDp4RKbk,1066
|
|
14
|
+
sphinx_needs_trace-0.1.0.dist-info/RECORD,,
|
|
@@ -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.
|