Skip to content

Commit 0881dce

Browse files
committed
Move helper type to the only file that uses it now
1 parent 618c6a7 commit 0881dce

File tree

2 files changed

+42
-48
lines changed

2 files changed

+42
-48
lines changed

code-gen/code_helpers.go

-48
This file was deleted.

code-gen/html_elements_generator.go

+42
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,48 @@ import (
66
"io"
77
)
88

9+
func WriteHeader(b *builder) {
10+
b.Printf("package scripting\n\n")
11+
b.Printf("// This file is generated. Do not edit.\n\n")
12+
}
13+
14+
type builder struct {
15+
io.Writer
16+
indentLvl int
17+
}
18+
19+
func newBuilder(w io.Writer) *builder {
20+
return &builder{w, 0}
21+
}
22+
23+
func (b builder) Printf(format string, args ...interface{}) {
24+
for i := 0; i < b.indentLvl; i++ {
25+
fmt.Fprint(b.Writer, "\t")
26+
}
27+
fmt.Fprintf(b.Writer, format, args...)
28+
}
29+
30+
func (b *builder) indent() {
31+
b.indentLvl++
32+
}
33+
34+
func (b *builder) indentF(format string, args ...interface{}) {
35+
b.indent()
36+
b.Printf(format, args...)
37+
}
38+
39+
func (b *builder) unIndent() {
40+
b.indentLvl--
41+
if b.indentLvl < 0 {
42+
panic("More unindentation than indentation")
43+
}
44+
}
45+
46+
func (b *builder) unIndentF(format string, args ...interface{}) {
47+
b.unIndent()
48+
b.Printf(format, args...)
49+
}
50+
951
func generateHtmlElements(writer io.Writer) error {
1052
file := newBuilder(writer)
1153
output := ElementsJSON{}

0 commit comments

Comments
 (0)