pub fn write_document(
path: &Path,
doc: &Document,
docs: &BTreeMap<PathBuf, Document>,
dir: &Path,
) -> Result<()>Expand description
Write one Document under dir — the real, typed write boundary
(P7.6, #1309, Decision C: one place derives the sibling-path relationship
instead of two independently-maintained ones). Shared by write_output
and bynk-driver::test_runner’s own output loop (bynkc test), so every
disk-writing path emits maps uniformly (slice 2 — bynkc test --inspect
runs the emitted .ts directly and needs the maps on disk).
A Ts document is printed through the one printer that owns a character
(R7.3); its own Printed::source_map is discarded, not written — the
real map, when one exists, is already present in docs as its own
SourceMap entry at this path’s .map sibling (sibling_path), split
out at construction (bynk-emit::project::build_output‘s own tail).
That sibling’s presence, not Printed::source_map, is what decides
whether the .ts/.js file gets a //# sourceMappingURL= trailer — the
trailer lives only on the on-disk artefact, not on docs’ own in-memory
text, so golden comparisons are unaffected.