Stop generating cards from registry descriptions
The extension shows descriptions as tooltips in its Elements panel; the resolver no longer adds cards to a diagram.
This commit is contained in:
1 parent
c68f7df108
commit
90a0c0d109
4 files changed
+3
-26
No files matched your search
@@ -175,7 +175,7 @@ Diagrams next to `main.archify` are listed first, ungrouped; deeper ones by fold
|
||||
- **Links are relative to the model root**, never to the file, and must end in `.archify` and exist. `..` is refused.
|
||||
- **A second `main.archify` deeper down** is reported, not nested. One model per tree.
|
||||
- **Diagram kinds other than architecture** take `ref` too (workflow and dataflow `nodes`, sequence `participants`, lifecycle `states`), but the registry `type` must fit that kind: lifecycle states use their own type enum, and sequence participants have no `tag`.
|
||||
- **Cards come from the registry.** A model diagram without `cards:` gets one card per drawn shared element that has a description. To show something else below the diagram, write `cards:` yourself; to show nothing, write `cards: []`.
|
||||
- **Descriptions stay in the registry.** The extension shows an element's description as a tooltip in its Elements panel; nothing is generated into the diagram. Write `cards:` in a diagram only when you want text blocks below it.
|
||||
- **No em dashes or smart quotes in ids**; ids match `^[a-zA-Z][a-zA-Z0-9_-]*$`.
|
||||
|
||||
## References
|
||||
|
||||
@@ -100,7 +100,3 @@ For each diagram file under the root (and a single file outside a model):
|
||||
5. Hand the result to `archify validate <kind> <json> --json` (or `render`).
|
||||
|
||||
`task model:resolve -- --file=… --out=x.json` writes step 4's result.
|
||||
|
||||
## Cards under a model diagram
|
||||
|
||||
Archify shows `cards` (a coloured dot, a title, a few lines) below a diagram. An architecture diagram inside a model that draws shared elements and defines no `cards` of its own gets one card per drawn element that has a `description` in the registry, in drawing order, with the dot colour of the element's type (frontend cyan, backend emerald, database violet, cloud amber, security rose, messagebus orange, external slate). `model:resolve` and the extension both add them; write your own `cards:` in the diagram to replace them.
|
||||
@@ -28,18 +28,6 @@ const COPY = {
|
||||
};
|
||||
// What a diagram may override on a shared element. Everything else in COPY is fixed.
|
||||
export const OVERRIDE = ['label', 'sublabel', 'tag'];
|
||||
// Archify card dot colour per component type (the colour Archify gives the node).
|
||||
const DOT_BY_TYPE = { frontend: 'cyan', backend: 'emerald', database: 'violet', cloud: 'amber', security: 'rose', messagebus: 'orange', external: 'slate' };
|
||||
export const dotForType = (type) => DOT_BY_TYPE[type ?? ''] ?? 'slate';
|
||||
|
||||
// Archify info cards for shared elements: one per element with a description,
|
||||
// titled by its label. An architecture diagram without cards of its own gets
|
||||
// these for the elements it draws, as the extension does.
|
||||
export function cardsFromElements(elements) {
|
||||
return elements
|
||||
.filter((element) => typeof element.description === 'string' && element.description.trim())
|
||||
.map((element) => ({ dot: dotForType(element.type), title: element.label ?? element.id, items: [element.description.trim()] }));
|
||||
}
|
||||
// Registry-only fields, never sent to Archify.
|
||||
const REGISTRY_ONLY = ['description', 'diagram'];
|
||||
const SKIP_DIRS = new Set(['node_modules', '.git']);
|
||||
@@ -253,11 +241,6 @@ export function resolveDiagram(file, { root, elements } = {}) {
|
||||
}
|
||||
return merged;
|
||||
});
|
||||
if (type === 'architecture' && diagram.cards === undefined && refs.length) {
|
||||
const drawn = [...new Set(refs)].map((ref) => elements?.[ref]).filter(Boolean);
|
||||
const cards = cardsFromElements(drawn);
|
||||
if (cards.length) diagram.cards = cards;
|
||||
}
|
||||
result.resolved = diagram;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -80,10 +80,8 @@ try {
|
||||
assert(json.model === undefined, 'model block leaked into the resolved JSON');
|
||||
const api = json.components.find((c) => c.id === 'api');
|
||||
assert(api && api.type === 'backend' && api.brand === 'node-js' && api.description === undefined && api.diagram === undefined, 'api was not resolved from the registry');
|
||||
const cards = json.cards ?? [];
|
||||
assert(cards.length === 7 && cards.every((c) => c.dot && c.title && c.items.length === 1), `expected 7 generated cards, got ${JSON.stringify(cards).slice(0, 200)}`);
|
||||
assert(cards.find((c) => c.title === 'API')?.dot === 'emerald', 'API card has the backend colour');
|
||||
notes.push(`${json.components.length} components, refs expanded, ${cards.length} cards from the registry`);
|
||||
assert(json.cards === undefined, 'nothing is generated into the diagram beyond the expanded refs');
|
||||
notes.push(`${json.components.length} components, refs expanded`);
|
||||
});
|
||||
|
||||
check('model-resolve prints the JSON inline without --out', ['--action', 'model-resolve', '--file', path.join(example, 'main.archify')], (r) => {
|
||||
|
||||
Reference in new issue
Block a user