Make great documentation goal 1.2, and plan the README's reorganisation and the nested-template gaps #33
@@ -61,7 +61,7 @@ func contained(n node) []namedNode {
|
|||||||
case *template:
|
case *template:
|
||||||
return namedNodes(n.fields)
|
return namedNodes(n.fields)
|
||||||
case *table:
|
case *table:
|
||||||
return append([]namedNode{{node: n.formatTemplate}}, namedNodes(n.fields)...)
|
return append([]namedNode{{node: n.formatTemplate}}, namedNodes(n.formatTemplate.fields)...)
|
||||||
case *tableColumn:
|
case *tableColumn:
|
||||||
if len(n.t.cellTemplates) == 0 {
|
if len(n.t.cellTemplates) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -438,8 +438,8 @@ func (t *table) step(tail []string) (column node, child *table, err error) {
|
|||||||
if len(tail) == 0 {
|
if len(tail) == 0 {
|
||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
if i, ok := t.col[tail[0]]; ok {
|
if column, ok := t.formatTemplate.fields[tail[0]]; ok {
|
||||||
return t.fields[t.header[i]], nil, nil
|
return column, nil, nil
|
||||||
}
|
}
|
||||||
if child = t.descendant(tail[0]); child == nil {
|
if child = t.descendant(tail[0]); child == nil {
|
||||||
return nil, nil, fmt.Errorf("no column or linked table %q in %s", tail[0], t.segment)
|
return nil, nil, fmt.Errorf("no column or linked table %q in %s", tail[0], t.segment)
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ type table struct {
|
|||||||
formatTemplate *template // fields are the column nodes
|
formatTemplate *template // fields are the column nodes
|
||||||
header []string
|
header []string
|
||||||
col map[string]int
|
col map[string]int
|
||||||
fields map[string]node // column nodes, the format's fields
|
|
||||||
rowNode *tableRow
|
rowNode *tableRow
|
||||||
cells []string // rows × columns, flat
|
cells []string // rows × columns, flat
|
||||||
cellTemplates map[int]*template
|
cellTemplates map[int]*template
|
||||||
@@ -157,7 +156,6 @@ func (t *table) parseRows(data string) error {
|
|||||||
}
|
}
|
||||||
t.header = strings.Split(header, "\t")
|
t.header = strings.Split(header, "\t")
|
||||||
t.col = make(map[string]int, len(t.header))
|
t.col = make(map[string]int, len(t.header))
|
||||||
t.fields = make(map[string]node, len(t.header))
|
|
||||||
for i, name := range t.header {
|
for i, name := range t.header {
|
||||||
if err := checkName(name); err != nil {
|
if err := checkName(name); err != nil {
|
||||||
return fmt.Errorf("column %w", err)
|
return fmt.Errorf("column %w", err)
|
||||||
@@ -166,7 +164,6 @@ func (t *table) parseRows(data string) error {
|
|||||||
return fmt.Errorf("column %q is named twice", name)
|
return fmt.Errorf("column %q is named twice", name)
|
||||||
}
|
}
|
||||||
t.col[name] = i
|
t.col[name] = i
|
||||||
t.fields[name] = &tableColumn{t, i}
|
|
||||||
}
|
}
|
||||||
if header == data {
|
if header == data {
|
||||||
return fmt.Errorf("has no rows below its header; a table is at least two rows")
|
return fmt.Errorf("has no rows below its header; a table is at least two rows")
|
||||||
@@ -338,10 +335,14 @@ func (t *table) compileRowFormat(format string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := checkTokens(toks, t.fields); err != nil {
|
fields := make(map[string]node, len(t.header))
|
||||||
|
for i, name := range t.header {
|
||||||
|
fields[name] = &tableColumn{t, i}
|
||||||
|
}
|
||||||
|
if err := checkTokens(toks, fields); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
t.formatTemplate = &template{format: format, tokens: toks, fields: t.fields, repeat: 1, isRecord: true, site: tableSite{t, formatRow}}
|
t.formatTemplate = &template{format: format, tokens: toks, fields: fields, repeat: 1, isRecord: true, site: tableSite{t, formatRow}}
|
||||||
t.rowNode = &tableRow{t}
|
t.rowNode = &tableRow{t}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ ranking `readSurvey.walk` hardest and all seven the unit they would least modify
|
|||||||
|
|
||||||
This round, in order:
|
This round, in order:
|
||||||
|
|
||||||
- Drop `table.fields` for `formatTemplate.fields`: one map held in two fields.
|
|
||||||
- Rename `arm.key` to `head`, as `template.head` reads it, leaving `key` the table's key
|
- Rename `arm.key` to `head`, as `template.head` reads it, leaving `key` the table's key
|
||||||
column; give `renderScope.row` a type that is not `tablePin`, since it pins nothing;
|
column; give `renderScope.row` a type that is not `tablePin`, since it pins nothing;
|
||||||
and name `value.go` by the `valueProof` it holds.
|
and name `value.go` by the `valueProof` it holds.
|
||||||
|
|||||||
Reference in New Issue
Block a user