Skip to content

Render doc as compartment and support SysML v2 view conditions (filter) - #83

Merged
Malcolmnixon merged 4 commits into
mainfrom
doc-annotation-rendering
Nov 12, 2026
Merged

Malcolmnixon merged 4 commits into
mainfrom
doc-annotation-rendering

Conversation

@Malcolmnixon

@Malcolmnixon Malcolmnixon commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Problem

General views of fully documented models were unreadable: every doc was drawn as a separate floating note with a leader line. The first iteration of this PR hid doc and added a custom attribute showDocumentation = true; opt-in, which is not SysML v2.

Spec basis (SysML 2.1 Beta 2 / KerML 1.1 Beta 2)

  • KerML 7.2.4.2: Documentation is an owned member of its element, so expose P::**; (or P::X::*) exposes it; a bare membership expose P::X; does not (SysML 8.3.26.2–4).
  • SysML 7.26.2 / 8.3.26.11: exposed elements are rendered only if they satisfy all view conditions (filter …;), both owned and inherited from the view definition; expose filters expose P::**[expr]; apply per-expose. Metaclass tests such as @SysML::PartUsage (7.5.4; SysML publicly imports KerML).
  • SysML 8.2.3.4: documentation-compartment (doc) inside the owner's node; comment-node + annotation-link for comments.

Behavior

  • Exposed, unfiltered documentation is drawn as a word-wrapped doc compartment inside its owner's box (General View). Never a floating note.
  • Hide it the standard way: filter not @SysML::Documentation; (comments stay), or a positive filter such as filter @SysML::PartDefinition; (hides doc and comments), or expose P::**[not @SysML::Documentation];, or inherit the condition from a view def.
  • Explicit comment elements are still drawn as notes with annotation links, subject to the same conditions.
  • Interconnection and other view types never draw documentation (unchanged).
  • The showDocumentation attribute is removed.

Implementation

  • Language: SysmlViewNode.FilterExpressionTexts (all conditions) and ViewDefinitionName (view V : Def); ReferenceResolver resolves the latter into a Typing edge.
  • Core: ExposeScopeResolver.CollectViewConditions (own + inherited through Typing/Supertype), IsAnnotationExposed, ExposedScope.FilteredEntries; FilterExpressionEvaluator.EvaluateForMetaclass, KerML:: spelling, kernel metaclass lineage (Documentation → Comment → AnnotatingElement → Element; Package); GeneralViewLayoutStrategy applies every condition to definitions, docs, and comments.
  • Gallery 01 model/images regenerated; BatterySubsystemView demonstrates filter not @SysML::Documentation;.

Validation

  • ./build.ps1: 2752 tests passed, 0 failed (all TFMs).
  • ./lint.ps1: clean (includes reqstream --lint --enforce).
  • Tests: doc compartment by default; filter not @SysML::Documentation hides it but keeps comment; positive filter hides it; inherited condition hides it; expose filter hides it; bare membership expose does not expose doc.

General views drew every comment and doc annotation as a floating note
with a leader line, which made views of fully documented models
unreadable.

- doc (Documentation) annotations are no longer drawn by any view type
  by default; explicit comments are still drawn as attached notes.
- A view opts in with `attribute showDocumentation = true;` in its body
  (captured by AstBuilder into SysmlViewNode.ShowDocumentation). The
  General View then renders doc text as a word-wrapped "doc" compartment
  inside the element's box.
- Interconnection view is unchanged (it never draws annotations).
- Requirements, design, verification, user guide, and the drone gallery
  example/images updated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 11, 2026 18:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A moderate active finding remains in AstBuilder.cs: nested view member bodies such as view def are misclassified, causing inner attributes to incorrectly update the outer view, and regression coverage is still needed.

1 open issue
What changed in this PR

This PR hides doc (Documentation) annotations by default in every view type. Explicit comment elements still draw as attached notes. A view can opt in with an owned attribute showDocumentation = true;. In an opted-in General View, each element's doc text is drawn as a word-wrapped doc compartment inside its box. The change keeps large, fully documented models such as ApiMark readable, and it adds requirements, tests, docs, and gallery updates to match.

Changes:

  • AstBuilder reads the showDocumentation = true opt-in from a view's own body into SysmlViewNode.ShowDocumentation.
  • GeneralViewLayoutStrategy draws doc text as a wrapped compartment only when opted in. Only comment annotations become notes.
  • The Interconnection view never draws documentation. Requirements, tests, design and verification docs, the user guide, and the gallery example are updated to match.
File Description
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​WorkspaceLoaderTests.cs Adds a test for the showDocumentation opt-in, including false and nested cases.
test/​DemaConsulting.SysML2Tools.Tests/​Layout/​InterconnectionViewLayoutStrategyTests.cs Adds a test that documentation is never drawn in the Interconnection view.
test/​DemaConsulting.SysML2Tools.Tests/​Layout/​GeneralViewLayoutStrategyTests.cs Tests hidden-by-default docs, the wrapped doc compartment, and word wrapping. Updates existing tests to use comment.
src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​SysmlNode.cs Adds the ShowDocumentation property to SysmlViewNode.
src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​AstBuilder.cs Reads the view's own showDocumentation = true attribute, skipping nested members.
src/​DemaConsulting.SysML2Tools.Core/​Layout/​Internal/​GeneralViewLayoutStrategy.cs Builds the opt-in doc compartment with word wrapping, and limits notes to comment annotations.
docs/​verification/​sysml2-tools-language/​semantic/​model/​sysml-node.md Maps the new ShowDocumentation property to its test.
docs/​verification/​sysml2-tools-language/​semantic/​model/​ast-builder.md Maps the new opt-in parsing to its test.
docs/​verification/​sysml2-tools-core/​layout/​internal/​interconnection-view-layout-strategy.md Records the new no-documentation test.
docs/​verification/​sysml2-tools-core/​layout/​internal/​general-view-layout-strategy.md Records the new general view tests and updates the note test descriptions.
docs/​user_guide/​introduction.md Adds a "Comments and Documentation" section that explains the opt-in.
docs/​reqstream/​sysml2-tools-language/​semantic/​model/​sysml-node.yaml Adds the ViewShowDocumentation requirement for SysmlViewNode.
docs/​reqstream/​sysml2-tools-language/​semantic/​model/​ast-builder.yaml Adds the ViewShowDocumentation requirement for AstBuilder.
docs/​reqstream/​sysml2-tools-language/​semantic/​model/​model.yaml Links the new SysmlNode and AstBuilder requirements to their parent group.
docs/​reqstream/​sysml2-tools-core/​layout/​internal/​interconnection-view-layout-strategy.yaml Adds the requirement that Interconnection views never draw documentation.
docs/​reqstream/​sysml2-tools-core/​layout/​internal/​general-view-layout-strategy.yaml Narrows the note requirement to comment and adds the hidden-by-default and doc compartment requirements.
docs/​reqstream/​sysml2-tools-core/​layout/​internal.yaml Links the new layout requirements to their parent group.
docs/​gallery/​svg/​DroneGeneralView.svg Regenerated general view; the doc text is no longer drawn as a note.
docs/​gallery/​svg/​BatterySubsystemView.svg Regenerated battery view that shows the opt-in doc compartment.
docs/​gallery/​README.md Explains that comment draws a note, doc is hidden, and the battery view opts in.
docs/​gallery/​models/​01-drone-general.sysml Adds a comment to Battery and the opt-in attribute to BatterySubsystemView.
docs/​design/​sysml2-tools-language/​semantic/​model/​sysml-node.md Documents the ShowDocumentation property.
docs/​design/​sysml2-tools-language/​semantic/​model/​ast-builder.md Documents how the opt-in is read and which nested members are ignored.
docs/​design/​sysml2-tools-core/​layout/​internal/​interconnection-view-layout-strategy.md Notes that the Interconnection view never reads annotations.
docs/​design/​sysml2-tools-core/​layout/​internal/​general-view-layout-strategy.md Documents the doc compartment, its wrapping rules, and the note behavior.

Review effort: Lite

Replace the non-standard showDocumentation attribute with spec-aligned
behavior: documentation is an owned member (KerML 7.2.4.2), so it is
exposed with its owner's members and, when it satisfies the view's
conditions (SysML 7.26.2, 8.3.26.11), is drawn as a word-wrapped doc
compartment (8.2.3.4). Parse and evaluate all owned and inherited view
conditions and expose filters with @sysml::/@KerML:: metaclass tests,
including Documentation, Comment and Package. Comments stay as notes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 12, 2026 01:15
@Malcolmnixon Malcolmnixon changed the title Hide doc annotations by default; per-view opt-in doc compartment Render doc as compartment and support SysML v2 view conditions (filter) Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved moderate findings leave nested usage documentation potentially undrawn and prevent typed views from inheriting their definition’s render target, while the API documentation also describes obsolete behavior.

3 open issues
1 resolved since last review

Review effort: Lite

A view typed by StandardViewDefinitions::GeneralView reached the
deserialized library view node, whose filter list may be null, and
crashed. Guard the list and edges, with a regression test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 12, 2026 01:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Critical correctness gaps remain because filtered-out usages can still appear in compartments and non-General/typed views do not consistently apply or inherit the new conditions.

3 open issues
4 previously missed issues

In code that hasn't changed since last review

High severity Re-filter compartment rows after applying view conditions

src/​DemaConsulting.SysML2Tools.Core/​Layout/​Internal/​GeneralViewLayoutStrategy.cs:274

Conditions narrow defs only after CollectDefinitions has built each box's compartments from every owned feature. A usage removed by a condition, such as filter @SysML::PartDefinition;, therefore still appears as a row in its parent's parts compartment. The standalone filter had this gap before this PR, and the new conditions reuse the same path. Build compartments from the admitted children, or re-filter the rows once the final set is known, before constructing the boxes.

High severity Apply view conditions across strategies or document General View scope

src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​SysmlNode.cs:382

Only GeneralViewLayoutStrategy applies view conditions. Browser, Grid, Sequence, Action Flow, State Transition, and Interconnection views ignore them, so render asTreeDiagram; filter @SysML::PartDefinition; still draws non-matching elements. The standalone filter had this gap before this PR, but the user guide now describes view conditions without this limit. Either apply the conditions in the other strategies, or document that they apply to General View only.

Medium severity Restrict KerML prefixes to kernel metaclasses

src/​DemaConsulting.SysML2Tools.Core/​Filtering/​FilterExpressionEvaluator.cs:246

MetaclassNameMatches accepts the KerML:: prefix for every metaclass, so @KerML::PartUsage or @KerML::PartDefinition wrongly match SysML elements. Accept KerML:: only for the kernel metaclasses in KernelMetaclassLineage (Documentation, Comment, AnnotatingElement, Element, Package, Namespace). Also update the summary above this method and the @KerML::… wording in docs/user_guide/introduction.md, which must match.

Medium severity Remove unsupported rendering inheritance claim from ViewDefinitionName

src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​SysmlNode.cs:388

ViewDefinitionName says the usage inherits the definition's rendering, but view routing never follows its Typing edge. DiagramTypeRouter checks only the usage's name, render target, and SupertypeNames, and a view usage does not populate SupertypeNames. So view V : InterconnectionView { ... } still routes to the general view. Correct the wording to cover view conditions only; the same claim appears in ReferenceResolver.cs:912-913 and the design doc for SysmlNode.

Review effort: Lite

…nnotation limit

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 12, 2026 02:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because the review identified multiple moderate inconsistencies in documented exposure and view-condition behavior, plus a code path that can suppress filter-related warnings.

No open issues 🎉

3 resolved since last review

Review effort: Lite

@Malcolmnixon
Malcolmnixon merged commit d84795c into main Nov 12, 2026
10 checks passed
@Malcolmnixon
Malcolmnixon deleted the doc-annotation-rendering branch November 12, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants