Make great documentation goal 1.2, and plan the README's reorganisation and the nested-template gaps #33
@@ -68,7 +68,7 @@ type cellSite struct {
|
||||
row int
|
||||
}
|
||||
|
||||
// templateLink is what a template's references resolve to in the assembled tree.
|
||||
// templateLink is what a template resolves to in the assembled tree.
|
||||
type templateLink struct {
|
||||
refs map[string]refBinding // each reference the format reads -> what it resolves to
|
||||
refHeads map[string]node // each refBinding.key -> the category it names
|
||||
@@ -172,7 +172,11 @@ func compileAt(v any, pos position) (node, error) {
|
||||
func compileItem(v any, pos position) (node, error) {
|
||||
switch v := v.(type) {
|
||||
case string:
|
||||
return compileString(v)
|
||||
t, err := compileString(v, cellSite{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return t, nil
|
||||
case []any:
|
||||
return compileChoice(v, pos)
|
||||
case map[string]any:
|
||||
@@ -199,12 +203,12 @@ func jsonKind(v any) string {
|
||||
return fmt.Sprintf("%T", v)
|
||||
}
|
||||
|
||||
func compileString(s string) (node, error) {
|
||||
func compileString(s string, cell cellSite) (*template, error) {
|
||||
toks, err := parseChecked(s, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &template{format: s, tokens: toks, repeat: 1, fromString: true}, nil
|
||||
return &template{format: s, tokens: toks, repeat: 1, fromString: true, cell: cell}, nil
|
||||
}
|
||||
|
||||
// fixedText is one render's output when the format holds no token; repeat is the caller's.
|
||||
|
||||
@@ -308,14 +308,14 @@ func (t *table) checkCells() error {
|
||||
if strings.IndexByte(cell, '{') < 0 && strings.IndexByte(cell, '}') < 0 {
|
||||
continue
|
||||
}
|
||||
toks, err := parseChecked(cell, nil)
|
||||
n, err := compileString(cell, cellSite{t, row})
|
||||
if err != nil {
|
||||
return fmt.Errorf("line %d, %s: %w", row+2, t.header[col], err)
|
||||
}
|
||||
if t.cellTemplates == nil {
|
||||
t.cellTemplates = map[int]*template{}
|
||||
}
|
||||
t.cellTemplates[i] = &template{format: cell, tokens: toks, repeat: 1, fromString: true, cell: cellSite{t, row}}
|
||||
t.cellTemplates[i] = n
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -23,9 +23,6 @@ Shape 5.8, Self-sufficiency 5.7), every seat capped by Locality, all nine naming
|
||||
|
||||
This round, in order:
|
||||
|
||||
- Return each phase's output from compile, link and format compile, not fill
|
||||
`template`'s 25 fields in place from four files: five seats had to know which phase a
|
||||
function runs in to know which fields are valid yet.
|
||||
- Make `renderEdges` panic on a node it does not handle, as `render` does: its
|
||||
`default: return nil` silently exempts a new node kind from every fence, and nothing
|
||||
at `expand` says `renderEdges` mirrors it.
|
||||
|
||||
Reference in New Issue
Block a user