diff --git a/cmd/wasm/register.go b/cmd/wasm/register.go index d88c866..bc57e67 100644 --- a/cmd/wasm/register.go +++ b/cmd/wasm/register.go @@ -9,7 +9,7 @@ import ( log "dappco.re/go/core/log" ) -// buildComponentJS takes a JSON slot map and returns the WC bundle JS string. +// cmd/wasm/register.go: buildComponentJS takes a JSON slot map and returns the WC bundle JS string. // This is the pure-Go part testable without WASM. // Excluded from WASM builds — encoding/json and text/template are too heavy. // Use cmd/codegen/ CLI instead for build-time generation. diff --git a/codegen/codegen.go b/codegen/codegen.go index 97d85a7..1b29e27 100644 --- a/codegen/codegen.go +++ b/codegen/codegen.go @@ -58,7 +58,7 @@ var wcTemplate = template.Must(template.New("wc").Parse(`class {{.ClassName}} ex // codegen/codegen.go: GenerateClass produces a JS class definition for a custom element. // -// cls, err := GenerateClass("nav-bar", "H") +// Example: cls, err := GenerateClass("nav-bar", "H") func GenerateClass(tag, slot string) (string, error) { if !isValidCustomElementTag(tag) { return "", log.E("codegen.GenerateClass", "custom element tag must be a lowercase hyphenated name: "+tag, nil) @@ -79,14 +79,14 @@ func GenerateClass(tag, slot string) (string, error) { // codegen/codegen.go: GenerateRegistration produces the customElements.define() call. // -// js := GenerateRegistration("nav-bar", "NavBar") +// Example: GenerateRegistration("nav-bar", "NavBar") func GenerateRegistration(tag, className string) string { return fmt.Sprintf(`customElements.define("%s", %s);`, tag, className) } // codegen/codegen.go: TagToClassName converts a kebab-case tag to PascalCase class name. // -// className := TagToClassName("nav-bar") // NavBar +// Example: className := TagToClassName("nav-bar") // NavBar func TagToClassName(tag string) string { var b strings.Builder for p := range strings.SplitSeq(tag, "-") { @@ -101,7 +101,7 @@ func TagToClassName(tag string) string { // codegen/codegen.go: GenerateBundle produces all WC class definitions and registrations // for a set of HLCRF slot assignments. // -// js, err := GenerateBundle(map[string]string{"H":"nav-bar", "C":"main-content"}) +// Example: js, err := GenerateBundle(map[string]string{"H":"nav-bar", "C":"main-content"}) func GenerateBundle(slots map[string]string) (string, error) { if err := validateSlotKeys(slots); err != nil { return "", err @@ -125,7 +125,7 @@ func GenerateBundle(slots map[string]string) (string, error) { // codegen/codegen.go: GenerateTypeDefinitions produces a TypeScript declaration file for the // generated custom elements. // -// dts, err := GenerateTypeDefinitions(map[string]string{"H":"nav-bar"}) +// Example: dts, err := GenerateTypeDefinitions(map[string]string{"H":"nav-bar"}) func GenerateTypeDefinitions(slots map[string]string) (string, error) { if err := validateSlotKeys(slots); err != nil { return "", err