Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-DIAG-009

Diagrams are drawn once per source and theme and late results are dropped

When the page needs a Mermaid diagram, a PlantUML diagram drawn by the built-in engine or a chart, the extension SHALL draw only the diagrams whose source or theme colours changed or that were never drawn, show an earlier drawing of the same source and theme colours without running the engine again, run the Mermaid and PlantUML draw passes one at a time (so a later Mermaid theme is drawn only after the running pass ends), and, for a PlantUML diagram or a chart, drop a result that arrives for a key the node no longer has. When the JAR pipeline renders a diagram text that an earlier successful render already drew, the extension SHALL reuse that SVG without starting a process.

Another outcome at step 3 of path 1 in StRS-MDOKFSTUDIO-DIAG-001, in the state “The diagram is drawn as a picture”.

Scenarios 7

The situations the tests check; open one to read it.

nominalUnchanged diagram after a node replacement
Givena Mermaid diagram already drawn, then a content update that replaces its node with the same source under the same theme
Whenthe page draws the new node
Thenthe earlier picture is shown and Mermaid is not run; the page keeps the 64 most recent Mermaid drawings, by source and theme colours
boundaryChanged source or theme
Givena drawn diagram whose source or theme colours changed
Whenthe page draws it
ThenMermaid runs again; a theme attribute change that leaves the colours as they were draws nothing
nominalA content patch draws only new diagrams
PatchOutcome
Adds a Mermaid diagram while another is already drawnThe page applies the patch and signals the replaced content; the new diagram is drawn and the earlier one is not rebuilt
The keyed morph keeps a drawn diagram through the patchThe diagram keeps its render state and its picture
Adds a PlantUML diagram next to a drawn one (built-in engine)Only the new diagram, which has no render state, is drawn; the others are left untouched
Replaces a PlantUML node with the same source and variantThe kept result is shown and the engine is not run

The page draws the diagrams that have no render state and leaves the diagrams that have one untouched.

boundaryDraw passes run one at a time
SituationOutcome
A content patch and a theme change are requested while a pass is runningThe next pass starts only when the running pass finishes, in the order requested
A pass is requested before the Mermaid module has loadedThe pass starts after the load and not before
refusalA late picture for a replaced key is not shown
SituationOutcome
A Mermaid diagram is being drawn for the dark theme and the theme changes to creamThe cream pass starts only after the dark pass ends (passes run one at a time, so no Mermaid result arrives for a replaced key); the dark drawing is stored in the cache and shown, then the cream drawing replaces it
A Mermaid drawing finishes while its key is still the node's keyIt is shown
A PlantUML diagram is drawn, a theme switch starts a second render of the element, and the first finishes after the secondOnly the second render's picture is shown; the first result is dropped and the element is unchanged
A chart is drawn, a newer theme replaces it while it runsThe result is cached and not shown
refusalA late error for a replaced key is not shown
SituationOutcome
A PlantUML drawing fails after a newer render took the elementNo error message is shown for the replaced key
A Mermaid drawing fails for the node's current keyThe error message is shown and the state is error
nominalThe JAR pipeline reuses an earlier render
InputOutcome
the same diagram text rendered twice under one JAR, with the same command, arguments, workspace root, security profile and JAR size and modification timeone process starts; the second render returns the same SVG
another diagram text, a replaced JAR, or an earlier failurea process starts (a failed render is never kept)
a diagram text with an include, import, theme, pragma or environment-reading directiveit is never reused: a process starts each time

Implemented in 3

Tested by 5

Known limits (4)

Replaces

SwRS-MDOKFSTUDIO-DIAG-011A content patch draws only Mermaid diagrams not yet drawn superseded superseded by SwRS-MDOKFSTUDIO-DIAG-009 Markdown file
SwRS-MDOKFSTUDIO-DIAG-012Mermaid draw passes run one at a time superseded superseded by SwRS-MDOKFSTUDIO-DIAG-009 Markdown file
SwRS-MDOKFSTUDIO-DIAG-014A late Mermaid result for a replaced theme is not shown superseded superseded by SwRS-MDOKFSTUDIO-DIAG-009 Markdown file
SwRS-MDOKFSTUDIO-DIAG-116A late Mermaid error for a replaced key is not shown superseded superseded by SwRS-MDOKFSTUDIO-DIAG-009 Markdown file