docs: add meaningful code comments to build_templates.zig

- Added comprehensive module-level documentation explaining architecture
- Added doc comments to all public and key internal functions
- Improved inline comments focusing on 'why' not 'what'
- Updated CLAUDE.md with code comments rule
- Bump version to 0.2.0
This commit is contained in:
2026-01-23 12:34:30 +05:30
parent 53f147f5c4
commit 0d4aa9ff90
5 changed files with 151 additions and 117 deletions

View File

@@ -102,7 +102,7 @@ pub fn simple_1(a: Allocator, d: anytype) Allocator.Error![]u8 {
try o.appendSlice(a, "!<strong>You have ");
try esc(&o, a, strVal(@field(d, "messageCount")));
try o.appendSlice(a, " messages!</strong></span>");
if (truthy(@field(d, "colors"))) {
if (@hasField(@TypeOf(d), "colors") and truthy(@field(d, "colors"))) {
try o.appendSlice(a, "<ul>");
for (@field(d, "colors")) |color| {
try o.appendSlice(a, "<li class=\"color\">");
@@ -114,7 +114,7 @@ pub fn simple_1(a: Allocator, d: anytype) Allocator.Error![]u8 {
try o.appendSlice(a, "<div>No colors!</div>");
}
try o.appendSlice(a, "</div>");
if (truthy(@field(d, "primary"))) {
if (@hasField(@TypeOf(d), "primary") and truthy(@field(d, "primary"))) {
try o.appendSlice(a, "<button class=\"primary\" type=\"button\">Click me!</button>");
} else {
try o.appendSlice(a, "<button class=\"secondary\" type=\"button\">Click me!</button>");