Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@
"fileassert"
],
"rollForward": false
},
"demaconsulting.canvasnet.tool": {
"version": "0.2.0-beta.6",
"commands": [
"canvasnet"
],
"rollForward": false
}
}
}
1 change: 1 addition & 0 deletions .cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ words:
- CanvasNet
- Postconditions
- buildmark
- canvasnet
- buildtransitive
- contentfiles
- dcterms
Expand Down
97 changes: 97 additions & 0 deletions .github/skills/canvasnet/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
name: canvasnet
description: Create, render, and visually verify diagrams (SVG, OpenSCAD, VegaLite) with the CanvasNet tool. Use this when asked to draw, chart, or illustrate something for documentation, or when a diagram source in the repository needs to be updated or re-rendered.
---

# CanvasNet Skill

CanvasNet renders SVG, OpenSCAD (`.scad`), and VegaLite (`.vl.json`) sources to PNG so
an agent can create a diagram, look at the result, and refine it. For *when* a diagram
belongs in a document, follow `.github/standards/diagram-documentation.md`. This skill
covers only how to use the tool.

## Prerequisites

`canvasnet` is a local .NET tool (`DemaConsulting.CanvasNet.Tool`) pinned in
`.config/dotnet-tools.json`; add it to the manifest if it is missing. It is only available
from inside the repository:

```pwsh
dotnet tool restore
dotnet canvasnet --help
```

## Learn the tool from its own help

The tool documents itself and the help always matches the pinned version. Do not rely on
memory or on this skill for format details:

```pwsh
dotnet canvasnet formats # supported inputs and outputs
dotnet canvasnet help svg # supported SVG subset, embedding rules, limits
dotnet canvasnet help scad # supported OpenSCAD features
dotnet canvasnet help vega-lite # supported VegaLite features
dotnet canvasnet help <topic> --examples
```

Read the topic help before authoring in a format, particularly the unsupported-feature
lists, and look at an example if the format is unfamiliar.

## Workflow

1. Write the source file next to where it will be used (normally `docs/images/`).
2. Render it, using `--strict` so unsupported constructs fail instead of being silently
skipped:

```pwsh
dotnet canvasnet render docs/images/name.svg -o docs/images/name.png --strict
```

3. **View the PNG** and critique it: clipped or overlapping text, uneven spacing,
misaligned elements, unreadable labels, poor contrast. Fix the source and re-render.
Repeat until it is right; the first render is rarely the final one.
4. Check the result on both a light and a dark background when the PNG will be
published on a page of unknown theme:

```pwsh
dotnet canvasnet render docs/images/name.svg -o preview.png --background "#0d1117" --strict
```

Delete previews and other scratch output when done.

## Habits

- **Transparent output.** Rendering flattens vector sources over white by default. Pass
`--background transparent` when the diagram supplies its own card or background.
- **Rounded card.** For a diagram that must look right in light and dark themes, draw a
rounded white `<rect>` with a thin border behind the content and render transparent.
- **Solid colors, not opacity.** The PDF/A pipeline (WeasyPrint) ignores `opacity` and
`fill-opacity` on SVG shapes, so a translucent shadow turns solid black. Use solid
colors for anything that must appear in a generated PDF. VegaLite marks may have
their own default opacity (circles are translucent); set it explicitly if needed.
- **Resolution.** Render PNGs wide enough to stay sharp when scaled (for example
`--width 1800` for a diagram displayed at about 900 px).
- **Keep the data with the chart.** VegaLite data files and OpenSCAD includes must live in
the source's folder or below; do not reference remote data.
- **Derive, don't invent.** Take facts shown in a diagram (names, relationships, values)
from the source code or the SysML2 model, not from memory.

## SVG as a layout engine

An SVG may embed other sources with `<image href="...">`: rasters, other SVGs, OpenSCAD
models, VegaLite charts, and documents (PDF, PPTX, VSDX). This lets you compose panels,
labels, and arrows around charts and models in a single figure. Constraints:

- Only CanvasNet can render such an SVG. Browsers and GitHub cannot resolve the embedded
`.scad`, `.vl.json`, or document references. Always render the composed SVG to PNG and
publish the PNG.
- Embedded files must be in the SVG's folder or below.
- For how to select a page of a PDF, PPTX, or VSDX document, and for the file-count,
nesting, and pixel limits, run `dotnet canvasnet help svg`.

## Troubleshooting

- *Tool not found*: run from inside the repository after `dotnet tool restore`.
- *A feature fails under `--strict`*: it is not supported; check the topic's help for the
supported alternative rather than dropping `--strict`.
- *Render looks wrong but exits 0*: you rendered without `--strict`; re-run with it.
77 changes: 77 additions & 0 deletions .github/standards/diagram-documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: Diagram Documentation
description: Follow these standards when deciding whether, and how, to add diagrams to documentation.
globs: ["docs/**/*.md", "README.md", "docs/images/**", "!docs/**/generated/**"]
---

# Diagram Documentation Standards

A diagram is a tool for the reader, not decoration. Add one only when it explains
something faster or more accurately than prose, a table, or a code sample would. Tool
mechanics (commands, formats, flags) are in the `canvasnet` skill, not here.

# When a Diagram Earns Its Place

Add a diagram when it:

- shows **structure or flow** that is hard to follow in text (components and their
relationships, data conversion paths, state or outcome taxonomies)
- presents **quantitative data** where shape matters (a chart or matrix)
- gives a first-time reader a **mental model** before the detail starts

Do not add a diagram when it:

- repeats what the adjacent text or table already says clearly
- is decorative (logos, banners, illustrations with no information)
- would need to be maintained in many places for little reader benefit
- depicts something that is better generated from the authoritative source (see below)

# Budget and Placement

- Prefer one or two diagrams per document. If more seem necessary, the document probably
needs restructuring.
- Place the diagram where the reader needs it, after a lead-in sentence that says what
to look for, and refer to it from the text.
- Keep the README lean: a single overview diagram is typical.
- Every image has meaningful alt text describing what it shows, not "diagram". Never
rely on color alone to convey meaning.

# Choosing the Form

- **Authoritative software structure** lives in the SysML2 model under `docs/sysml2/`.
Do not hand-draw a competing description of the same structure; a diagram derived from
it is fine, and the model wins when they disagree.
- **Simple flows and relationships** in design or verification documents may use
Mermaid, but only where the documentation pipeline has Mermaid rendering configured;
otherwise it is emitted as a plain code block.
- **Illustrative or marketing-quality figures** (README, user guide): SVG.
- **Data charts**: VegaLite, with the data file kept beside the spec.
- **3D or physical objects**: OpenSCAD. Rare for software documentation.
- **Composite figures** (charts, models, or document pages arranged with labels): an SVG
that embeds the other sources.

# Source and Rendered Output

- **Always commit the source** (`.svg`, `.scad`, `.vl.json`, and any data it uses). The
source is the maintainable artifact and is reviewed like code.
- **Commit the rendered PNG only when a consumer cannot use the source directly.** For
example, the README is published in the NuGet package, which does not reliably render
external SVG, so its image is a committed PNG. Where the documentation pipeline can
consume the SVG directly, embed the SVG and commit no PNG.
- Composite SVGs that embed `.scad`, `.vl.json`, or document files can only be rendered
by CanvasNet, so a PNG is always required for them.
- Keep CanvasNet-authored sources and outputs together in `docs/images/` with matching
base names (`name.svg` and `name.png`). Embedded assets must be in that folder or below.
This does not apply to generator-managed outputs (for example SysML2 views rendered into
`docs/design/generated/`), which stay where their generator writes them.
- Render with `--strict` and review the result visually before committing. Regenerate the
PNG in the same commit whenever the source changes so the two never disagree.
- Images referenced from a README that ships in a package use absolute URLs, per the
README's own conventions.

# Maintenance

- A diagram that no longer matches the code is worse than no diagram. When a change
alters what a diagram shows, update the diagram in the same change.
- Remove a diagram when it stops earning its place.
- Do not commit scratch files, previews, or test renders.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ jobs:
dotnet versionmark --capture --job-id "build-docs" \
--output "artifacts/versionmark-build-docs.json" -- \
dotnet git node npm pandoc weasyprint sarifmark sonarmark reqstream \
buildmark versionmark reviewmark fileassert
buildmark versionmark reviewmark fileassert canvasnet
echo "✓ Tool versions captured"

# === PREPARE DOCUMENT OUTPUT ===
Expand Down
5 changes: 5 additions & 0 deletions .versionmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ tools:
fileassert:
command: dotnet tool list
regex: '(?i)demaconsulting\.fileassert\s+(?<version>\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)'

# CanvasNet (DemaConsulting.CanvasNet.Tool from dotnet tool list)
canvasnet:
command: dotnet tool list
regex: '(?i)demaconsulting\.canvasnet\.tool\s+(?<version>\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)'
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ from `.github/standards/`. Use this matrix to determine which to load:
- **Requirements**: `requirements-principles.md`, `software-items.md`, `reqstream-usage.md`
- **Design docs**: `software-items.md`, `design-documentation.md`, `technical-documentation.md`
- **Verification docs**: `software-items.md`, `verification-documentation.md`, `technical-documentation.md`
- **Diagrams in documentation**: `diagram-documentation.md` (and the `canvasnet` skill for tooling)
- **Review configuration**: `software-items.md`, `reviewmark-usage.md`
- **Any documentation**: `technical-documentation.md`

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ SysML2Tools is a free, open-source .NET CLI tool and library that parses SysML v
model files and renders them as professional nested block diagrams suitable for architecture
documentation, CI/CD pipelines, and AI-assisted modeling workflows.

![SysML2Tools architecture: model files flow from the Tool commands through the Core library and the Language library, which is seeded by the Stdlib, to produce diagnostics, diagrams, query results, and model JSON][architecture]

## Features

- **SysML v2 Parsing**: Parses SysML v2 textual notation (`.sysml` files) via an
Expand Down Expand Up @@ -335,6 +337,7 @@ Copyright (c) DEMA Consulting. Licensed under the MIT License. See [LICENSE][lin
By contributing to this project, you agree that your contributions will be licensed under the MIT License.

<!-- Badge References -->
[architecture]: https://raw.githubusercontent.com/demaconsulting/SysML2Tools/main/docs/images/architecture.png
[badge-forks]: https://img.shields.io/github/forks/demaconsulting/SysML2Tools?style=plastic
[badge-stars]: https://img.shields.io/github/stars/demaconsulting/SysML2Tools?style=plastic
[badge-contributors]: https://img.shields.io/github/contributors/demaconsulting/SysML2Tools?style=plastic
Expand Down
2 changes: 2 additions & 0 deletions docs/build_notes/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ input-files:
template: template.html
table-of-contents: true
number-sections: true
filters:
- docs/filters/canvasnet.lua
2 changes: 2 additions & 0 deletions docs/code_quality/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ input-files:
template: template.html
table-of-contents: true
number-sections: true
filters:
- docs/filters/canvasnet.lua
2 changes: 2 additions & 0 deletions docs/code_review_plan/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ input-files:
template: template.html
table-of-contents: true
number-sections: true
filters:
- docs/filters/canvasnet.lua
2 changes: 2 additions & 0 deletions docs/code_review_report/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ input-files:
template: template.html
table-of-contents: true
number-sections: true
filters:
- docs/filters/canvasnet.lua
2 changes: 2 additions & 0 deletions docs/design/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ input-files:
template: template.html
table-of-contents: true
number-sections: true
filters:
- docs/filters/canvasnet.lua
Loading
Loading