feat(view): add source links to rendered diagrams - #867
Merged
Merged
Conversation
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Rendered diagrams can now link every node and edge back to its declaration. A link template with
{file},{line},{col},{qname}and{id}is set onview.Options.Linksand written by every graph form:URL=andtooltip=(qualified name, elsefile:line:col) on nodes and edges. A composite node puts them on its cluster, so the SVG links the visible box.[[url]]on node declarations (after stereotypes, before palette colours) and on edges. Ports, pseudostates (<<start>>,<<fork>>,<<join>>,<<end>>,<<choice>>,<<history>>,<<history*>>) and initial arrows stay unlinked, because the pinned jar drops those links from the SVG. Inside a linked composite state, the jar gives an unlinked pseudostate the composite's link.click <id> href "<url>"on flowchart nodes and simple states,link <id>: Source @ <url>on sequence participants. Edges, subgraphs and composite states have no Mermaid link syntax. Mermaid drops the URL fragment (#L26) from sequence participant links in SVG.Surfaces: CLI
-render-link '<template>'(with-render,-render-alland document rendering), REPL%render … link=<template>, LSPopensysml/renderlinkTemplate, document backends (Markdown/HTML/PDF diagrams), and the VS Code export, which sends<uriScheme>://file/{file}:{line}:{col}.Decisions:
{file}is the source path as loaded (slash-normalised), not rewritten against a root; absolute input paths are recommended forvscode:///file://templates.{id}is the element's effective id fromidentity.Of(declaredelementIdor the derived one, perelement-identity-annotations.md)./and:; template literals keep URL delimiters (#,?,&,%) and escape grammar-unsafe bytes (space,",], braces, non-ASCII).securityLevelis left at its default (strict). Measured with the pinned mermaid-cli 11.16.0: strict mode strips non-HTTP(S) schemes (vscode://,file:///), andloosekeeps them. This is documented, not changed.Specification basis
Diagram rendering is tool-defined (SysML v2 §8.2.2.2). The "hyperlinks are not written" limitation is removed from
docs/project/view-rendering-forms.md, and a source-links row is added to the rendering table indocs/project/spec-compliance.md.How it was verified
go build ./...,go vet ./...,make lint,go test ./..., plusgo test -raceoninternal/frontend/lspandinternal/workspace/model;make man-check,make docs-counts.internal/ir/view/links_test.go: linked goldens for DOT, PlantUML and Mermaid (tree, interconnection, state, action, sequence), escaping (spaces,], quotes,#, non-ASCII), zero origins, anonymous elements, invalid templates, no-template byte identity. Surface tests for CLI, REPL, LSP, workspace and document rendering.dot -Tsvgwrites<a xlink:href>/xlink:title; the pinned PlantUML jar (1.2026.8,-tsvg) writes node and edge<a>, and every link the writer emits has its own href in the SVG; mermaid-cli 11.16.0 writes<a>for flowchart, state and sequence links (HTTP(S) only under strict mode). The tests run all three when the tools are present.-render-all, the REPL, and the HTML backend, where clicking a linked state opens its source at#L59. In VS Code, a diagram-panel export gave an SVG whose link opened the file at Ln 43, Col 9. A path with spaces,]andéopened from the Graphviz SVG. With no template, all 17 outputs were byte-identical todevelop.Graphviz SVG in Chrome, hovering
tank : Tank(tooltip shows the qualified name, the status bar shows the source URL), and VS Code opened from the exported SVG's link:Checklist
make testandmake lintpass locallychanges/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (compliance rows need nothing: the census is counted at docs build)F4,K5) in the body, docs, or changelogLink to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/c9d4fd36122441dabea9dd6883c66b06
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/c9d4fd36122441dabea9dd6883c66b06?variant=devin
Requested by: @HuiJun