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
5 changed files with 14 additions and 34 deletions
Showing only changes of commit df63d0f562 - Show all commits
+3 -2
View File
@@ -711,8 +711,9 @@ row:
Renders e.g. `🇳🇴 Norway: capital Oslo, calling code +47`. Everything under a name is drawn
once, so `{n}` and `{n.path}` agree, a [transform](#transforms) of `n.path` reads the same
value, and a field `n` renders twice prints the same text twice. A name is a pick of its own:
`{t.name}` and `{/misc.territory.name}` beside it are two draws, as are two names bound to one
category.
`{t.name}` and `{/misc.territory.name}` beside it are two draws. A reference path read under a
name draws in the draw group of the read of the name, so give the reads of two names bound to
one category a [draw group](#draw-group) each to draw what it references apart.
A name is drawn on its first read, and lives in the category binding it: any field of the
category reads it, and a record's columns read one pick. Each render of the category picks
+2 -1
View File
@@ -904,4 +904,5 @@ whichever binds it. A read entering a category keeps the frame of each scope it
own memo, and the category's root renders that frame when the read lands on the root, so
`{n}` and `{n.path}` read one pick: per render and group for a reference path, per pick for a
path through a name, and per render for `Fake("cat.field")`. A reference read under a pick
draws in the pick's own draw groups, so two names bound to one category are two picks of it.
draws in the draw group of the read of the name, the group the draw fences survey it in; a pick
with draw groups of its own would draw where no fence looks.
+6 -11
View File
@@ -51,10 +51,9 @@ type renderScope struct {
entry *drawMemo
base int
// pick is the named pick what renders is part of, at pickKey, its path from the name; nil
// outside one. refs is the draw groups of the last pick entered, nil before one.
// outside one.
pick *namedPick
pickKey string
refs *renderDraws
}
type renderedRow struct {
@@ -91,20 +90,16 @@ func (sc renderScope) rowOf(t *table) int {
}
func (sc renderScope) groupDraws() *groupDraws {
draws := sc.draws
if sc.refs != nil {
draws = sc.refs
}
if sc.group == "" {
return &draws.unnamed
return &sc.draws.unnamed
}
d, drew := draws.named[sc.group]
d, drew := sc.draws.named[sc.group]
if !drew {
if draws.named == nil {
draws.named = map[string]*groupDraws{}
if sc.draws.named == nil {
sc.draws.named = map[string]*groupDraws{}
}
d = &groupDraws{}
draws.named[strings.Clone(sc.group)] = d
sc.draws.named[strings.Clone(sc.group)] = d
}
return d
}
+3 -4
View File
@@ -219,12 +219,12 @@ func linkName(t *template, a *arm) error {
}
// namedPick is one draw of a name: the variant drawn at each level under it, the value each
// path through it read, keyed by the path from the name, and the table rows they pinned; and the
// draw groups of the references read under it, so two names on one category are two picks of it.
// path through it read, keyed by the path from the name, and the table rows they pinned. A
// reference read under it draws in the draw group of the read of the name, which the draw
// fences survey it in.
type namedPick struct {
memo drawMemo
pins pinSet
refs renderDraws
}
// pickFrame is one render of a name scope: a pick per binding, each drawn on its first read.
@@ -316,7 +316,6 @@ func (sc renderScope) entryMemo() *drawMemo {
func readName(s *generatorState, sc renderScope, a arm) readValue {
p := sc.pickOf(a.bind)
sc.refs, sc.group = &p.refs, ""
return readPicked(s, p, a.bind.head, a.steps, a.levels, a.path, sc.entering(&p.memo))
}
-16
View File
@@ -337,19 +337,3 @@ func TestOneRenderReadsOneNameAcrossDrawGroups(t *testing.T) {
}
}
}
func TestTwoNamesOnOneCategoryAreTwoPicks(t *testing.T) {
dir := writeData(t, map[string]string{
"given": `{"format":"{first}","first":["Ada","Bo","Cy","Di","Ed","Flo","Gus","Hal"]}`,
"person": `"{/given.first}"`,
"card": `"{/person as p}{/person as q}{p}|{q}"`,
})
f := newGenerator(t, dir, WithSeed(53))
for i := 0; i < 50; i++ {
got := strings.Split(fake(t, f, "card"), "|")
if got[0] != got[1] {
return
}
}
t.Fatal("card printed one person for p and q in 50 renders, want two picks")
}