You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(truapi-codegen): use writedoc!/formatdoc! in host_callbacks emitter
The new TS HostCallbacks emitter from #18 hand-chained 15 writeln! calls
to build the output. CLAUDE.md (this commit also) now requires codegen
modules to prefer indoc::writedoc! / formatdoc! over writeln! chains so
the emitted shape stays visible in source.
Switched host_callbacks.rs to:
- writedoc! for the header + import block (two multi-line writes)
- formatdoc! returning strings for trait interfaces, methods, and the
super-interface; the parent function joins them
- render_jsdoc returns a String instead of writing through a sink
writeln! count: 15 → 2 (both inside writedoc! invocations themselves).
Golden test rebuilt clean; workspace tests all pass.
Copy file name to clipboardExpand all lines: CLAUDE.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,6 +55,7 @@ scripts/codegen.sh regenerate the TS client from the Rust crate
55
55
- In Rust format strings, prefer inlined variables: `"log value: {value:?}"` over `"log value: {:?}", value`.
56
56
- Don't introduce typealias chains that just rename a public type from another crate (e.g. `pub type StorageError = crate::v01::HostLocalStorageReadError`). Use the canonical name directly. A typealias is only worth its indirection when it captures a real abstraction.
57
57
- After any code change, update `README.md` (and CLAUDE.md if the layout changed) so the top-level docs reflect what the repo actually contains. Stale docs are a regression.
58
+
- In codegen emitters, prefer `indoc::writedoc!` / `formatdoc!` over chains of `writeln!`. A single `writedoc!` with a multi-line raw string keeps the emitted shape visible in source instead of fragmenting it across one-line `writeln!` calls. Reserve `writeln!` for the genuinely-one-line case (a single import, a single statement inside a loop).
0 commit comments