Make great documentation goal 1.2, and plan the README's reorganisation and the nested-template gaps #33
@@ -870,7 +870,7 @@ render.go Fake and the recursive renderer (choices, format strings, expans
|
|||||||
record.go records: Record, the JSON/CSV/SQL serializers, and their entry points
|
record.go records: Record, the JSON/CSV/SQL serializers, and their entry points
|
||||||
struct.go structs: FakeStruct, fake tags, and a field's Go type as its column's datatype
|
struct.go structs: FakeStruct, fake tags, and a field's Go type as its column's datatype
|
||||||
inline.go inline templates: Template, NewTemplate, FakeTemplate, IsTemplate, and their compile and link
|
inline.go inline templates: Template, NewTemplate, FakeTemplate, IsTemplate, and their compile and link
|
||||||
template.go the {token} grammar: scanning, tokens, operands, validation, compiling a format
|
format.go the {token} grammar: scanning, tokens, operands, validation, compiling a format
|
||||||
hold.go the hold: one draw per held name, and reading a field through it
|
hold.go the hold: one draw per held name, and reading a field through it
|
||||||
holdfence.go the load fences over the hold: the routes and spellings that read one held name two ways
|
holdfence.go the load fences over the hold: the routes and spellings that read one held name two ways
|
||||||
holdset.go one reference draw per render and group: the hold set a render reads its paths through
|
holdset.go one reference draw per render and group: the hold set a render reads its paths through
|
||||||
|
|||||||
+7
-7
@@ -193,7 +193,7 @@ type drawWalk struct {
|
|||||||
type drawAt struct {
|
type drawAt struct {
|
||||||
group string
|
group string
|
||||||
route drawRoute
|
route drawRoute
|
||||||
alt pinSet
|
pinned pinSet
|
||||||
drawn *table // left out of the visit keys: only this table's own cells compare against it, which the own-family fence keeps true
|
drawn *table // left out of the visit keys: only this table's own cells compare against it, which the own-family fence keeps true
|
||||||
whole pinSet
|
whole pinSet
|
||||||
}
|
}
|
||||||
@@ -211,13 +211,13 @@ type pathRead struct {
|
|||||||
type nodeVisit struct {
|
type nodeVisit struct {
|
||||||
n node
|
n node
|
||||||
group string
|
group string
|
||||||
alt string
|
rows string
|
||||||
}
|
}
|
||||||
|
|
||||||
type readKey struct {
|
type readKey struct {
|
||||||
group string
|
group string
|
||||||
path string
|
path string
|
||||||
alt string
|
rows string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDrawWalk() *drawWalk {
|
func newDrawWalk() *drawWalk {
|
||||||
@@ -251,16 +251,16 @@ func (w *drawWalk) walk(n node, at drawAt) {
|
|||||||
in.whole = at.whole.clone()
|
in.whole = at.whole.clone()
|
||||||
in.whole.add(cell.cellOf, cell.cellRow)
|
in.whole.add(cell.cellOf, cell.cellRow)
|
||||||
w.edge(n, e, in)
|
w.edge(n, e, in)
|
||||||
case at.alt.clash(cell.cellOf, cell.cellRow) == nil:
|
case at.pinned.clash(cell.cellOf, cell.cellRow) == nil:
|
||||||
in := at
|
in := at
|
||||||
in.alt = at.alt.entered(cell.cellOf, cell.cellRow)
|
in.pinned = at.pinned.entered(cell.cellOf, cell.cellRow)
|
||||||
w.edge(n, e, in)
|
w.edge(n, e, in)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rowsKey spells the rows the walk stands in, pinned and whole, for a map.
|
// rowsKey spells the rows the walk stands in, pinned and whole, for a map.
|
||||||
func (at drawAt) rowsKey() string { return at.alt.key() + "|" + at.whole.key() }
|
func (at drawAt) rowsKey() string { return at.pinned.key() + "|" + at.whole.key() }
|
||||||
|
|
||||||
// edge records the reference an edge reads, then walks on with every row the read
|
// edge records the reference an edge reads, then walks on with every row the read
|
||||||
// pins entered, so a selected row renders only its own cells.
|
// pins entered, so a selected row renders only its own cells.
|
||||||
@@ -272,7 +272,7 @@ func (w *drawWalk) edge(from node, e renderEdge, at drawAt) {
|
|||||||
w.reads = append(w.reads, pathRead{at, a, tr})
|
w.reads = append(w.reads, pathRead{at, a, tr})
|
||||||
}
|
}
|
||||||
if tr != nil {
|
if tr != nil {
|
||||||
tr.pins.each(func(t *table, r int) { at.alt = at.alt.entered(t, r) })
|
tr.pins.each(func(t *table, r int) { at.pinned = at.pinned.entered(t, r) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.walk(e.to, at)
|
w.walk(e.to, at)
|
||||||
|
|||||||
@@ -219,4 +219,4 @@ func checkOwnFamily(t *template) error {
|
|||||||
// alternatives reports whether two reads sit in different rows of one table: rows the walks pinned,
|
// alternatives reports whether two reads sit in different rows of one table: rows the walks pinned,
|
||||||
// or rows of one whole draw.
|
// or rows of one whole draw.
|
||||||
// docs/decisions.md#the-rows-of-a-table-are-alternatives
|
// docs/decisions.md#the-rows-of-a-table-are-alternatives
|
||||||
func alternatives(a, b drawAt) bool { return a.alt.differs(&b.alt) || a.whole.differs(&b.whole) }
|
func alternatives(a, b drawAt) bool { return a.pinned.differs(&b.pinned) || a.whole.differs(&b.whole) }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
// ftoken is one unit of a scanned format string: a literal rune or the body of a
|
// ftoken is one unit of a scanned format string: a literal rune or the body of a
|
||||||
// {…} token.
|
// {…} token.
|
||||||
type ftoken struct {
|
type ftoken struct {
|
||||||
kind byte // 'l' literal rune, 'b' brace body
|
kind byte // 'l' literal rune, 't' token body
|
||||||
r rune
|
r rune
|
||||||
body string
|
body string
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ func eachToken(format string, fn func(ftoken) error) error {
|
|||||||
if end >= len(rs) {
|
if end >= len(rs) {
|
||||||
return fmt.Errorf("unterminated '{' in %q", format)
|
return fmt.Errorf("unterminated '{' in %q", format)
|
||||||
}
|
}
|
||||||
t.kind, t.body = 'b', string(rs[i+1:end])
|
t.kind, t.body = 't', string(rs[i+1:end])
|
||||||
i = end
|
i = end
|
||||||
case '}':
|
case '}':
|
||||||
if i+1 < len(rs) && rs[i+1] == '}' {
|
if i+1 < len(rs) && rs[i+1] == '}' {
|
||||||
@@ -63,7 +63,7 @@ func contained(n node) []namedNode {
|
|||||||
case *table:
|
case *table:
|
||||||
return append([]namedNode{{node: n.format}}, named(n.fields)...)
|
return append([]namedNode{{node: n.format}}, named(n.fields)...)
|
||||||
case *column:
|
case *column:
|
||||||
if len(n.t.tokens) == 0 {
|
if len(n.t.cellTemplates) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var out []namedNode
|
var out []namedNode
|
||||||
|
|||||||
+1
-1
@@ -97,7 +97,7 @@ func readsFact(n node) string {
|
|||||||
}
|
}
|
||||||
case *table:
|
case *table:
|
||||||
collect(n.format)
|
collect(n.format)
|
||||||
for _, cell := range n.tokens {
|
for _, cell := range n.cellTemplates {
|
||||||
collect(cell)
|
collect(cell)
|
||||||
}
|
}
|
||||||
case *template:
|
case *template:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ type table struct {
|
|||||||
fields map[string]node // column nodes, the format's fields
|
fields map[string]node // column nodes, the format's fields
|
||||||
whole *row // the pinned row rendered by the format
|
whole *row // the pinned row rendered by the format
|
||||||
cells []string // rows × columns, flat
|
cells []string // rows × columns, flat
|
||||||
tokens map[int]*template
|
cellTemplates map[int]*template
|
||||||
key int // key, name, weight and parent are column indexes, or -1
|
key int // key, name, weight and parent are column indexes, or -1
|
||||||
name int
|
name int
|
||||||
weight int
|
weight int
|
||||||
@@ -64,7 +64,7 @@ func (t *table) cell(row, col int) string { return t.cells[row*len(t.columns)+co
|
|||||||
|
|
||||||
// cellNode is what a cell renders: its compiled template where it carries tokens,
|
// cellNode is what a cell renders: its compiled template where it carries tokens,
|
||||||
// else nil for its text.
|
// else nil for its text.
|
||||||
func (t *table) cellNode(row, col int) *template { return t.tokens[row*len(t.columns)+col] }
|
func (t *table) cellNode(row, col int) *template { return t.cellTemplates[row*len(t.columns)+col] }
|
||||||
|
|
||||||
// tableOptions are the keys a table object takes; every other key is refused.
|
// tableOptions are the keys a table object takes; every other key is refused.
|
||||||
var tableOptions = []string{"format", "key", "name", "parent", "rows", "weight"}
|
var tableOptions = []string{"format", "key", "name", "parent", "rows", "weight"}
|
||||||
@@ -312,11 +312,11 @@ func (t *table) checkCells() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("line %d, %s: %w", row+2, t.columns[col], err)
|
return fmt.Errorf("line %d, %s: %w", row+2, t.columns[col], err)
|
||||||
}
|
}
|
||||||
if t.tokens == nil {
|
if t.cellTemplates == nil {
|
||||||
t.tokens = map[int]*template{}
|
t.cellTemplates = map[int]*template{}
|
||||||
}
|
}
|
||||||
t.tokens[i] = n.(*template)
|
t.cellTemplates[i] = n.(*template)
|
||||||
t.tokens[i].cellOf, t.tokens[i].cellRow = t, row
|
t.cellTemplates[i].cellOf, t.cellTemplates[i].cellRow = t, row
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -996,8 +996,8 @@ func TestEnteredRowsAgreeWithPinning(t *testing.T) {
|
|||||||
for cr := 0; cr < cand.rows(); cr++ {
|
for cr := 0; cr < cand.rows(); cr++ {
|
||||||
beside := s.clone()
|
beside := s.clone()
|
||||||
refused := beside.pinRow(cand, cr) != nil
|
refused := beside.pinRow(cand, cr) != nil
|
||||||
pinned := drawAt{alt: none.entered(cand, cr)}
|
pinned := drawAt{pinned: none.entered(cand, cr)}
|
||||||
if got := alternatives(drawAt{alt: s}, pinned); got != refused {
|
if got := alternatives(drawAt{pinned: s}, pinned); got != refused {
|
||||||
t.Errorf("alternatives(%s, %s) = %v, but pinning both refuses = %v", entered.selectorSpelling(row), cand.selectorSpelling(cr), got, refused)
|
t.Errorf("alternatives(%s, %s) = %v, but pinning both refuses = %v", entered.selectorSpelling(row), cand.selectorSpelling(cr), got, refused)
|
||||||
}
|
}
|
||||||
if alternatives(whole, pinned) || alternatives(pinned, whole) {
|
if alternatives(whole, pinned) || alternatives(pinned, whole) {
|
||||||
|
|||||||
@@ -19,11 +19,6 @@ Self-sufficiency 5.6), every seat capped by Locality or Self-sufficiency.
|
|||||||
|
|
||||||
This round, in order:
|
This round, in order:
|
||||||
|
|
||||||
- Rename what names two things: `template.go` holds the token grammar while `template`
|
|
||||||
is `node.go`'s type and `Template` `inline.go`'s; `kind` `'b'` is a brace body in
|
|
||||||
`ftoken` and a builtin in `formatToken` and `op`; `tokens` is a template's parsed format
|
|
||||||
and a table's cell templates; `drawAt.alt` holds the rows
|
|
||||||
a walk entered.
|
|
||||||
- Run the nine-seat panel again and file what it names here.
|
- Run the nine-seat panel again and file what it names here.
|
||||||
|
|
||||||
### Data
|
### Data
|
||||||
|
|||||||
Reference in New Issue
Block a user