Make great documentation goal 1.2, and plan the README's reorganisation and the nested-template gaps #33

Open
lilleman wants to merge 966 commits from worktree-todo-relative-dates-exact-counts into main
2 changed files with 27 additions and 19 deletions
Showing only changes of commit 5ce0ce147e - Show all commits
+27 -17
View File
@@ -25,12 +25,13 @@ type readValue struct {
// readField renders one arm of a token. A name the expansion holds — a level some // readField renders one arm of a token. A name the expansion holds — a level some
// token addresses by dotted path, or a field an operand reads — is drawn once and // token addresses by dotted path, or a field an operand reads — is drawn once and
// kept, so {place.postal-code} and {place.locality} read one row, either read twice // kept in held, so {place.postal-code} and {place.locality} read one row, either read
// gives one value, and a shown operand is the operand computed. Every other name is // twice gives one value, and a shown operand is the operand computed. Every other name
// drawn afresh, so {word} {word} still draws twice. A reference path is kept in the // is drawn afresh, so {word} {word} still draws twice.
// render's hold for its group, so its draw spans the render; every other held name in
// held, the expansion's.
func readField(s *session, t *template, held *hold, sc renderScope, a arm) readValue { func readField(s *session, t *template, held *hold, sc renderScope, a arm) readValue {
if isRef(a.key) && len(a.tail) > 0 {
return readReference(s, t, sc, a)
}
if sc.set.trace != nil { if sc.set.trace != nil {
traceRead(sc.set.trace, t, sc, a) traceRead(sc.set.trace, t, sc, a)
} }
@@ -40,23 +41,32 @@ func readField(s *session, t *template, held *hold, sc renderScope, a arm) readV
} }
return readValue{text: render(s, t.head(a.key), sc)} return readValue{text: render(s, t.head(a.key), sc)}
} }
w := pathDraw{s: s, held: held, a: &a} return readHeld(s, t, held, nil, sc, a)
if isRef(a.key) && len(a.tail) > 0 { }
group := sc.groupHold()
w.held, w.pins = &group.hold, &group.pins // readReference reads a reference path, kept in the render's hold for its group, so its draw
// spans the render.
func readReference(s *session, t *template, sc renderScope, a arm) readValue {
if sc.set.trace != nil {
traceRead(sc.set.trace, t, sc, a)
} }
if r, done := w.held.value[a.path]; done { group := sc.groupHold()
return readHeld(s, t, &group.hold, &group.pins, sc, a)
}
func readHeld(s *session, t *template, held *hold, pins *pinSet, sc renderScope, a arm) readValue {
if r, done := held.value[a.path]; done {
return r return r
} }
leaf := drawPath(t.head(a.key), a.tail, a.key, &w) leaf := drawPath(t.head(a.key), a.tail, a.key, &pathDraw{s: s, held: held, pins: pins, a: &a})
if w.pins != nil { if pins != nil {
sc = sc.at(leaf, w.pins) sc = sc.at(leaf, pins)
} }
r := renderLeaf(s, leaf, sc) r := renderLeaf(s, leaf, sc)
if w.held.value == nil { if held.value == nil {
w.held.value = map[string]readValue{} held.value = map[string]readValue{}
} }
w.held.value[a.path] = r held.value[a.path] = r
return r return r
} }
@@ -84,7 +94,7 @@ func renderLeaf(s *session, n node, sc renderScope) readValue {
return readValue{null: true} return readValue{null: true}
case *template: case *template:
if leaf.link.readsColumn != nil { if leaf.link.readsColumn != nil {
return readField(s, leaf, nil, sc.in(leaf), leaf.link.readsColumn.a) return readReference(s, leaf, sc.in(leaf), leaf.link.readsColumn.a)
} }
} }
return readValue{text: render(s, n, sc)} return readValue{text: render(s, n, sc)}
-2
View File
@@ -26,8 +26,6 @@ least modify.
This round, in order: This round, in order:
- Stop `readField` dereferencing a nil `held`: `renderLeaf` passes nil, safe only
because a `readsColumn` arm is a reference path with a tail, which nothing there says.
- Test that `disagreements` holds every key `disagreement` can build, and panic through - Test that `disagreements` holds every key `disagreement` can build, and panic through
`internalError` on a miss: a missing key is a nil func call today. `internalError` on a miss: a missing key is a nil func call today.
- Name `printedNumber`'s `dp` cases, and say on `builtin` what `prints` and - Name `printedNumber`'s `dp` cases, and say on `builtin` what `prints` and