Expand description
Writing a document tree: a distribution becomes a list of logical paths and their text.
Mirrors IR/src/layout/write-tree.ts in ecosystem/morphir-typescript; see
.dev/docs/superpowers/maps/2026-09-17-reference-tree-layout-map.md section 5. Nothing here
touches a filesystem: the profile is the only thing that decides what the text looks like, and
the result is an ordered list a caller writes, streams or compares as it likes.
The canonical layout is the manifest style: one definition per file, the module manifest
listing names rather than inlining them, and fileNames present only for the names the path
budget had to cut. The order is the order the specification gives — the distribution manifest,
then each module’s own manifest followed by its types and then its values, the own package
before the dependencies — and modules keep the order the model carries them in, never sorted:
a reader sorts on the way in, so a round trip is stable without the writer reordering anything.
The budget is the reason writing a tree can fail at all. A path is measured physically, extension included, from the distribution root; when a stem cannot be cut small enough, or when the module directory alone is already over, there is no tree to write. The budget’s floor is a reader’s rule, not a writer’s: a small budget earns a refusal here only by producing a path that does not fit.
The per-module writers are public and take one module each, so a caller streaming a distribution can emit a module’s files without holding the whole tree.
What a file says is the version’s business: the layout here — the budget, the stems, the order
— hands a [TreeModel] the pieces to encode, and the profile renders what the model returns.
Structs§
- Manifest
Header - Everything the distribution manifest says, held apart from the distribution it describes.
- Tree
Policy - How a distribution is laid out: which profile spells it, and how long a path may be.
Functions§
- write_
definition_ module - Lays one module definition out as its manifest and one file per type and value.
- write_
manifest - The distribution manifest of a whole distribution.
- write_
manifest_ header - The distribution manifest a header spells: the tree’s root file, and the only one that names the whole.
- write_
specification_ module - Lays one module specification out the same way, with
specbodies. - write_
tree - Lays a whole distribution out as a document tree under
policy.