feat(cli): surface the composite doc in the graph viewer (#125)

The viewer threads the model's doc through normalizeModel into both
composite view states — appended to INFO.B (collapsed box) and INFO.C
(expanded cluster frame) — and shows the root composite's doc as a muted
header line (#rootdoc span in GRAPH_HEAD, empty when absent; the DOM
population sits in the browser-only block, the same boundary as the
breadcrumb). viewer_tooltip.mjs pins the doc'd cases beside the
byte-exact un-doc'd pins; sample-model.json gains the additive doc key;
e2e drives aura graph over a nested-doc blueprint into the emitted page.

closes #125
This commit is contained in:
2026-07-11 20:18:32 +02:00
parent 953d04a774
commit 62f6592ef6
6 changed files with 103 additions and 4 deletions
+54
View File
@@ -117,5 +117,59 @@ const expect = (actual, expected, msg) => {
);
}
// --- #125: doc'd composite + root -------------------------------------------
// A minimal model whose composite def and root both carry a "doc"; pins that
// the doc reaches INFO.B (collapsed), INFO.C (expanded), and root.doc.
//
// genDot resolves a nested composite reference via the module-scope COMP
// captured once at require time from window.AURA_MODEL (see the file-top
// comment above the `model`/`ROOT` constants and the sibling
// viewer_nested_depth.mjs guard's identical note) — reusing the
// already-required module's genDot would resolve "sub" back to THIS file's
// original doc-less "sub" composite of the same name, not docModel's. Fresh-
// require the module against docModel so its own COMP reflects the doc'd
// composite.
const docModel = {
root: {
nodes: { "0": { comp: "sub" } },
edges: [],
doc: "root rationale line",
},
composites: {
sub: {
inputs: [["f64", "any", "a"]],
outputs: [["y", "f64"]],
nodes: {},
edges: [],
doc: "why this sub-graph is wired this way",
},
},
};
const viewerPath = join(here, "..", "assets", "graph-viewer.js");
delete require.cache[require.resolve(viewerPath)];
global.window = { AURA_MODEL: docModel };
const { normalizeModel: normalizeModelDoc, genDot: genDotDoc } = require(viewerPath);
const docNorm = normalizeModelDoc(docModel);
expect(docNorm.root.doc, "root rationale line", "root doc carried");
expect(docNorm.composites.sub.doc, "why this sub-graph is wired this way", "composite doc carried");
{
const { info } = genDotDoc(docNorm.root, "root", new Set(), false);
expect(
info.B["n0"],
"**sub** <span class='dim'>· composite</span>\nparams: <span class='dim'>none</span>\nwhy this sub-graph is wired this way",
"collapsed tooltip carries the doc paragraph"
);
}
{
const { info } = genDotDoc(docNorm.root, "root", new Set(["n0"]), false);
expect(
info.C["clust_n0"],
"**sub** <span class='dim'>· composite · click frame to collapse</span>\nwhy this sub-graph is wired this way",
"expanded cluster tooltip carries the doc paragraph"
);
}
console.log("OK — INFO.B/INFO.C/INFO.P tooltip shapes and md() conversion pinned.");
process.exit(0);