Behaviour SwRS-MDOKFSTUDIO-CODE-014
A code directive shows its file name or caption above the code
When a MyST code directive sets `:filename:` or `:caption:`, the extension SHALL show the file name above the code in smaller muted text, and render a caption with a `:label:` as a figure whose id is the label, joined to the block's top as a left-aligned monospace title bar.
Part of StRS-MDOKFSTUDIO-CODE-001, outside the paths drawn on its map.
Scenarios 6
The situations the tests check; open one to read it.
nominalA file name is shown above the code
Givena `{code-block}` with `:filename: example.py`
Whenthe preview renders it
Then`example.py` appears above the code in smaller muted text
refusalNo file name option, no file name line
Givena code directive without `:filename:`
Whenthe preview renders it
Thenno file name line is present
nominalA captioned directive is a figure with a reference target
Givena `{code-block}` with `:caption: Demo` and `:label: code:numbered`
Whenthe preview renders it
Thena figure with id `code:numbered` shows the caption `Demo`, usable as a `{ref}` target
boundaryA caption without a label has no reference id
Givena code directive with a caption but no label
Whenthe preview renders it
Thena captioned figure appears without a reference id
nominalThe caption is a title bar joined to the block
Givena `{code-block}` with `:caption:`, line numbers and an emphasized line
Whenthe preview renders it
Thenthe code stays left-aligned, the caption is a left-aligned monospace title bar joined to the block's top with the same width and border and a square joint, and the numbers and emphasis are intact
boundaryThe title bar matches the block in every theme
Giventhe light, dark and cream themes
Whenthe same block is shown in each
Thenthe title bar matches the block's border and width in each theme
Implemented in 3
Tested by 2
Replaces
SwRS-MDOKFSTUDIO-CODE-015Render a captioned code directive as a figure with a reference target superseded superseded by SwRS-MDOKFSTUDIO-CODE-014 Markdown file
SwRS-MDOKFSTUDIO-CODE-028Join a code caption to its block as a title bar superseded superseded by SwRS-MDOKFSTUDIO-CODE-014 Markdown file