Expand description
The LikeC4 emitter: a Model to the text of one .c4 file.
This is the only place LikeC4 syntax is produced. The facts it relies
on were verified against the LikeC4 release the CLI pins, and the CLI’s likec4_ tests
run every emitted shape through the real parser. Output is a pure
function of the normalized model: same model, same bytes, on every
platform.
Structs§
- Emit
Options - How the file relates to the repo it describes.
Constants§
- HEADER
- The first line of every generated file. No version in it: a version would turn every asbuilt release into drift in every consumer.
Functions§
- emit
- The
.c4text formodel. The model is normalized on a copy first, so the caller’s element order does not matter. - link_
encode - A path as a LikeC4 link target, which is an unquoted URI: every byte
outside the unreserved set and
/is percent-encoded, so a space or a quote in a directory name cannot break the parse. - theme_
color_ name - The name of a themed kind’s color in the specification.
- view_id
- The base view id for an element: its sanitized id with
_for.. Two elements can share one (a.b_canda_b.c);view_idsis where the later one gets its suffix. - view_
ids - The generated view of every element with children, keyed by element
id: the view name as the emitter declares it and as
asbuilt rendernames the SVG. Where two ids collapse to one base name, the second and later take a numeric suffix in element order, so the names are stable for a normalized model (emitnormalizes first; call this on the same model to get the same names).