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
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,24 @@ Exit code is non-zero if any errors are present, making it suitable for CI/CD pi

### Rendering

Render a SysML v2 workspace to SVG or PNG:
Render a SysML v2 workspace to SVG or PNG. `--output` names an output *directory*
(default: current directory); `--format` selects `svg` (default) or `png`:

```bash
# Render to SVG (auto-selects the single view in the workspace)
sysml2tools render model.sysml --output diagram.svg
sysml2tools render model.sysml --output out --format svg

# Render to PNG
sysml2tools render model.sysml --output diagram.png
sysml2tools render model.sysml --output out --format png

# Render a named view from a multi-view workspace
sysml2tools render "src/**/*.sysml" --view SystemContext --output context.svg
sysml2tools render "src/**/*.sysml" --view SystemContext --output out --format svg

# Auto-render the top-level part def when no view is defined
sysml2tools render model.sysml --auto --output diagram.svg
sysml2tools render model.sysml --auto --output out --format svg

# Limit nesting depth (truncated parts show "+N more…")
sysml2tools render model.sysml --output diagram.svg --depth 3
sysml2tools render model.sysml --output out --depth 3
```

### Querying
Expand Down Expand Up @@ -160,8 +161,8 @@ sysml2tools [-v|--version] [-?|-h|--help] [--silent]
sysml2tools help [lint|render|query [<query-verb>]]
```

`<verb>` is `lint`, `render`, or `query <query-verb>` (11 query verbs — see
[Querying](#querying)).
`<verb>` is `lint`, `render`, or `query <query-verb>` (11 query verbs — see the *Querying*
section above).

### Global Options

Expand All @@ -186,16 +187,17 @@ sysml2tools help [lint|render|query [<query-verb>]]
| Option | Description |
| --- | --- |
| `<globs>` | One or more glob patterns for `.sysml` input files |
| `--output <file>` | Output file path; extension determines format (`.svg` or `.png`) |
| `--view <name>` | Name of the view to render (required when workspace has multiple views) |
| `--output <dir>` | Output directory for rendered files (default: current directory) |
| `--format svg\|png` | Renderer format (default: `svg`) |
| `--view <name>` | Name of the view to render; omit to render every declared view (default) |
| `--auto` | Auto-render the BDD of the top-level `part def` when no view is defined |
| `--depth <#>` | Limit rendered nesting depth; truncated parts show `+N more…` |

### `query` Options

| Option | Description |
| --- | --- |
| `<verb>` | One of the 11 supported query verbs — see [Querying](#querying) |
| `<verb>` | One of the 11 supported query verbs — see the *Querying* section above |
| `<globs>` | One or more glob patterns for `.sysml` input files |
| `--element <name>`, `-e <name>` | Qualified name of the target element; required for every verb except `list`/`find` |
| `--format markdown\|json` | Output format (default: `markdown`); distinct from `render`'s `--format` (`svg`/`png`) |
Expand All @@ -218,9 +220,10 @@ sysml2tools help [lint|render|query [<query-verb>]]
| --- | --- |
| Exactly one view in workspace | Render it |
| Zero views, `--auto` specified | Auto-render BDD of top-level `part def` silently |
| Zero views, no `--auto` | Warn and auto-render |
| Multiple views, none specified | Error: lists available view names and exits non-zero |
| Multiple views, `--view <name>` | Render the named view |
| Zero views, no `--auto` | Informational message; no output files written |
| Multiple views, none specified | Render every declared view (one output file per view) |
| Multiple views, `--view <name>` | Render only the named view |
| `--view <name>` names a view that does not exist | Error: lists available view names and exits non-zero |

## NuGet Packages

Expand Down
3 changes: 3 additions & 0 deletions docs/design/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ reviewers an explicit navigation aid from design to code:
- **DemaConsulting.SysML2Tools.Tool/** — dotnet tool CLI wrapper
- **Cli/** — command-line interface subsystem
- **Lint/** — lint command subsystem
- **Render/** — render command subsystem
- **Help/** — help command subsystem
- **Query/** — query command subsystem
- **SelfTest/** — self-validation subsystem
- **Utilities/** — shared utilities subsystem
- **Tools/StdlibGen/** — build-time stdlib pre-compiler tool
Expand All @@ -172,6 +174,7 @@ reviewers an explicit navigation aid from design to code:
- **lint/** — Lint subsystem design
- **render/** — Render subsystem design (render.md)
- **help.md** — Help subsystem design
- **query.md** — Query subsystem design
- **self-test/** — SelfTest subsystem design
- **utilities/** — Utilities subsystem design

Expand Down
23 changes: 16 additions & 7 deletions docs/design/sysml2-tools-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Architecture

The `DemaConsulting.SysML2Tools.Tool` is a command-line application built on .NET. It is structured as one
system containing one top-level unit (`Program`) and three subsystems (`Cli`, `SelfTest`,
`Utilities`):
system containing one top-level unit (`Program`) and seven subsystems (`Cli`, `Lint`, `Render`,
`Help`, `Query`, `SelfTest`, `Utilities`):

```mermaid
flowchart TD
Expand All @@ -15,6 +15,12 @@ flowchart TD
subgraph Lint
LintCommand
end
subgraph Render
RenderCommand
end
subgraph Help
HelpCommand
end
subgraph Query
QueryCommand
end
Expand All @@ -26,18 +32,21 @@ flowchart TD
end
Program --> Context
Program --> LintCommand
Program --> RenderCommand
Program --> HelpCommand
Program --> QueryCommand
Program --> Validation
Validation --> Program
Validation --> PathHelpers
```

`Program` is the entry point. It creates a `Context` from the `Cli` subsystem, dispatches to
`LintCommand` when the `lint` subcommand is passed, dispatches to `QueryCommand` when the
`query` subcommand is passed, dispatches to `Validation` when `--validate` is passed, and
returns the exit code from `Context`. `Validation` calls `Program.Run` recursively
to exercise the tool during self-testing, and uses `PathHelpers` to construct safe temporary file
paths.
`LintCommand` when the `lint` subcommand is passed, dispatches to `RenderCommand` when the
`render` subcommand is passed, dispatches to `HelpCommand` when the `help` subcommand (or
`--help`) is passed, dispatches to `QueryCommand` when the `query` subcommand is passed,
dispatches to `Validation` when `--validate` is passed, and returns the exit code from
`Context`. `Validation` calls `Program.Run` recursively to exercise the tool during
self-testing, and uses `PathHelpers` to construct safe temporary file paths.

## External Interfaces

Expand Down
31 changes: 24 additions & 7 deletions docs/design/sysml2-tools-tool/render.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ Entry point for the render command. Steps:
`Program` only reaches here when `Context.Create` has already populated it) and validates
that `options.Files` is non-empty; calls `context.WriteError` and returns when no patterns
are supplied.
2. Calls `WorkspaceLoader.LoadAsync(options.Files)` to load the workspace.
2. Calls `StdlibProvider.GetSymbolTable()` to obtain the pre-resolved OMG stdlib symbol table,
then calls `WorkspaceLoader.LoadAsync(options.Files, stdlibTable)` to load the workspace,
seeded with the stdlib symbol table so stdlib elements resolve without re-parsing them.
3. Reports all diagnostics from `loadResult.Diagnostics`, writing errors via
`context.WriteError` and other messages via `context.WriteLine`.
4. Calls `DiagramRenderer.GetViewNames(workspace)` to enumerate renderable views.
5. When `viewNames.Count > 1` and `options.ViewName` is null, calls `context.WriteError`
with a message listing the available names and returns early.
5. Calls `DiagramRenderer.GetViewNames(loadResult.Workspace)` again (via the same call at step
4) to validate `options.ViewName` when supplied: when `options.ViewName` is not null and does
not match any declared view name, calls `context.WriteError` with a message listing the
available view names and returns early. When `options.ViewName` is null, no validation is
performed here — every declared view will be rendered in step 7.
6. Resolves `format = options.Format ?? "svg"` and eagerly rejects any value other than
`"svg"`/`"png"` (case-insensitive) with `ArgumentException` naming the bad value — mirroring
the `query` command's `--format` validation style. This is validated here, in `RunAsync`, not
Expand Down Expand Up @@ -71,8 +76,14 @@ future-locale story, which applies identically here.

- Missing file patterns: `context.WriteError` is called and the method returns early.
- Load diagnostics: reported to the context; non-fatal; rendering proceeds regardless.
- Multiple views without `--view`: `context.WriteError` lists available view names and
returns early.
- Multiple views without `--view`: no error; every declared view is rendered (one output file
per view), supporting bulk "render everything" exports.
- Output file name collision: when rendering all views (`--view` not specified) with more than
one output, and two or more views' sanitized display names produce the same output file
name, `context.WriteError` reports every colliding group (listing the colliding qualified
view names and the shared file name) and the method returns before any file is written for
this run, rather than silently overwriting one view's output with another's.
- Unknown `--view` name: `context.WriteError` lists available view names and returns early.
- Unsupported `--format` value: `ArgumentException` is thrown naming the bad value and the
valid values (`svg`, `png`); propagates to `Program.Main`'s expected-exception handler.
- No view declarations: informational message; no output files written; returns normally.
Expand All @@ -81,8 +92,12 @@ future-locale story, which applies identically here.

##### Dependencies

- `StdlibProvider` (in `DemaConsulting.SysML2Tools.Stdlib`) — supplies the pre-resolved OMG
stdlib symbol table used to seed `WorkspaceLoader.LoadAsync`
- `WorkspaceLoader` (in `DemaConsulting.SysML2Tools.Semantic`) — loads workspace
- `DiagramRenderer` (in `DemaConsulting.SysML2Tools.Rendering`) — renders views
- `DiagramRenderer` (in `DemaConsulting.SysML2Tools.Rendering`) — renders views; also exposes
`GetViewIdentities` used to attribute colliding output file names back to their originating
qualified view names
- `SvgRenderer` (in `DemaConsulting.Rendering.Svg`) — produces SVG output
- `PngRenderer` (in `DemaConsulting.Rendering.Skia`) — produces PNG output
- `Themes.Light` (in `DemaConsulting.Rendering.Abstractions`) — default theme
Expand All @@ -104,6 +119,8 @@ future-locale story, which applies identically here.
| SysML2Tools-Tool-Render-Output | Output directory resolution in `RunAsync` |
| SysML2Tools-Tool-Render-Empty | Empty-outputs message in `RunAsync` |
| SysML2Tools-Tool-Render-DepthLimit | `DepthLimit` passed to `RenderOptions` in `RunAsync` |
| SysML2Tools-Tool-Render-MultipleViewError | Multi-view guard using `GetViewNames` in `RunAsync` |
| SysML2Tools-Tool-Render-AllViewsExport | Default render-all-views logic using `viewNames` in `RunAsync` |
| SysML2Tools-Tool-Render-UnknownViewError | Unknown `--view` name guard using `viewNames` in `RunAsync` |
| SysML2Tools-Tool-Render-ViewSelection | `viewFilter` passed to `RenderWorkspace` in `RunAsync` |
| SysML2Tools-Tool-Render-FormatValidation | Eager `--format` value guard in `RunAsync` |
| SysML2Tools-Tool-Render-FileNameCollision | Output file name collision guard in `RunAsync` |
42 changes: 33 additions & 9 deletions docs/reqstream/sysml2-tools-tool/render.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,35 @@ sections:
tests:
- RenderSubsystem_WithDepth_LimitsNesting

- id: SysML2Tools-Tool-Render-MultipleViewError
- id: SysML2Tools-Tool-Render-AllViewsExport
title: >-
The render command shall render every declared view in the workspace, producing
one output file per view, when --view is not specified.
justification: |
Rendering every declared view by default supports bulk "render everything"
exports for CI pipelines and design-doc publishing without requiring the user
to invoke the command once per view.
tests:
- RenderSubsystem_MultipleViews_NoViewFlag_RendersAllViews

- id: SysML2Tools-Tool-Render-UnknownViewError
title: >-
The render command shall report an error listing all available view names when
the workspace contains multiple renderable views and --view is not specified.
--view specifies a view name that does not exist in the workspace.
justification: |
Requiring explicit view selection prevents rendering the wrong diagram when
a model contains multiple views, and the error lists choices so the user knows
what to supply.
Reporting an error with the list of available view names gives users an
actionable message when they mistype or misremember a view's display name.
tests:
- RenderSubsystem_MultipleViews_NoViewFlag_ReportsError
- RenderSubsystem_MultipleViews_NoViewFlag_ListsAvailableViews
- RenderSubsystem_UnknownViewFlag_ReportsErrorWithAvailableViews

- id: SysML2Tools-Tool-Render-ViewSelection
title: >-
The render command shall render only the view whose display name matches the
value supplied via --view.
value supplied via --view, when --view is specified.
justification: |
View selection enables targeting a single diagram for output in multi-view
models without generating every diagram in the workspace.
models without generating every diagram in the workspace; it is always
optional, narrowing the default render-all behavior to one view on request.
tests:
- RenderSubsystem_MultipleViews_WithViewFlag_RendersSelectedView

Expand All @@ -106,6 +116,20 @@ sections:
tests:
- RenderSubsystem_UnsupportedFormat_ThrowsArgumentException

- id: SysML2Tools-Tool-Render-FileNameCollision
title: >-
The render command shall detect and report, before writing any output files, when
rendering all declared views (--view not specified) would produce two or more
output files with the same sanitized file name, naming the colliding views and the
shared file name, and shall abort without writing any files for that run.
justification: |
Two declared views in different packages that share the same simple name sanitize
to the same output file name. Without a collision guard, the second file written
silently overwrites the first while the final "Rendered N view(s)." message still
misreports both views as rendered, masking data loss from the user.
tests:
- RenderSubsystem_DuplicateViewFileNames_ReportsCollisionError

- id: SysML2Tools-Tool-Render-LocalizableHelpText
title: >-
The render command's help text (RenderCommand.PrintHelp) shall be sourced from
Expand Down
22 changes: 12 additions & 10 deletions docs/user_guide/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ sysml2tools lint model.sysml
sysml2tools lint "src/**/*.sysml"

# Multiple patterns
sysml2tools render "common/**/*.sysml" "system/**/*.sysml" --output diagram.svg
sysml2tools render "common/**/*.sysml" "system/**/*.sysml" --output out
```

# Linting
Expand All @@ -80,20 +80,21 @@ This structured output is suitable for:
# Rendering

The `render` command loads a workspace, resolves a view, and renders it to SVG or PNG.
The output format is determined by the file extension of `--output`.
`--output` names an output *directory* (default: current directory); `--format` selects
`svg` (default) or `png`.

```bash
# Render to SVG
sysml2tools render model.sysml --output diagram.svg
sysml2tools render model.sysml --output out --format svg

# Render to PNG
sysml2tools render model.sysml --output diagram.png
sysml2tools render model.sysml --output out --format png

# Render a named view from a multi-view workspace
sysml2tools render "src/**/*.sysml" --view SystemContext --output context.svg
sysml2tools render "src/**/*.sysml" --view SystemContext --output out --format svg

# Auto-render the top-level part def when no view is defined
sysml2tools render model.sysml --auto --output diagram.svg
sysml2tools render model.sysml --auto --output out --format svg
```

## View Selection
Expand All @@ -102,9 +103,10 @@ sysml2tools render model.sysml --auto --output diagram.svg
| --- | --- |
| Exactly one view in workspace | Render it |
| Zero views, `--auto` specified | Auto-render BDD of top-level `part def` silently |
| Zero views, no `--auto` | Warn: "define a view or use --auto", then auto-render |
| Multiple views, none specified | Error: lists available view names, exits non-zero |
| Multiple views, `--view <name>` | Render the named view |
| Zero views, no `--auto` | Informational message; no output files written |
| Multiple views, none specified | Render every declared view (one output file per view) |
| Multiple views, `--view <name>` | Render only the named view |
| `--view <name>` names a view that does not exist | Error: lists available view names, exits non-zero |

## Depth Limiting

Expand All @@ -113,7 +115,7 @@ with an ellipsis footer (`+N more…`). Silent omission is never used — trunca
visible in the output.

```bash
sysml2tools render model.sysml --output diagram.svg --depth 3
sysml2tools render model.sysml --output out --depth 3
```

## Output Formats
Expand Down
Loading
Loading