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 16 additions and 16 deletions
Showing only changes of commit ecc7833e04 - Show all commits
+14 -14
View File
@@ -51,14 +51,14 @@ type hasReadMemo struct {
// checkDrawGroup refuses a draw group that splits nothing: one whose render reads every reference
// path inside a repeat or a nested draw group, which draw apart from it whatever it names.
func (c *drawFence) checkDrawGroup(path string, n node) error {
if t, ok := n.(*template); ok && t.drawGroup != "" && !c.splitsDraws(t) {
func (f *drawFence) checkDrawGroup(path string, n node) error {
if t, ok := n.(*template); ok && t.drawGroup != "" && !f.splitsDraws(t) {
return fmt.Errorf("%s: drawGroup %q splits nothing, since nothing it renders reads a reference path outside a repeat or a nested drawGroup; drop it", path, t.drawGroup)
}
return nil
}
func (c *drawFence) checkDraws(path string, n node) error {
func (f *drawFence) checkDraws(path string, n node) error {
t, ok := n.(*template)
if !ok {
return nil
@@ -66,7 +66,7 @@ func (c *drawFence) checkDraws(path string, n node) error {
if err := checkOwnFamily(t); err != nil {
return fmt.Errorf("%s: %w", path, err)
}
if !c.readsPath(t) {
if !f.readsPath(t) {
return nil
}
if err := surveyRender(t).check(); err != nil {
@@ -116,7 +116,7 @@ func checkOwnFamily(t *template) error {
// checkRecordDraws fences the columns of a record — a template compiled at the top without a
// repeat — so a load proves the record view of it as well as the string view.
// docs/decisions.md#a-category-never-references-itself-and-a-records-fences-run-at-load
func (c *drawFence) checkRecordDraws(path string, n node) error {
func (f *drawFence) checkRecordDraws(path string, n node) error {
t, ok := n.(*template)
if !ok || !t.isRecord {
return nil
@@ -125,7 +125,7 @@ func (c *drawFence) checkRecordDraws(path string, n node) error {
columns := sortedNames(t.fields)
reads := false
for _, name := range columns {
reads = reads || c.readsPath(t.fields[name])
reads = reads || f.readsPath(t.fields[name])
}
if !reads {
return nil
@@ -138,30 +138,30 @@ func (c *drawFence) checkRecordDraws(path string, n node) error {
// readsPath reports whether rendering n reads a reference path, short of a repeat, which renders
// over draws of its own.
func (c *drawFence) readsPath(n node) bool { return c.hasRead(n, false) }
func (f *drawFence) readsPath(n node) bool { return f.hasRead(n, false) }
// splitsDraws reports whether rendering n reads a reference path that n's own draw group answers
// for: one outside a repeat and outside a nested draw group, which hold their own draws.
func (c *drawFence) splitsDraws(n node) bool { return c.hasRead(n, true) }
func (f *drawFence) splitsDraws(n node) bool { return f.hasRead(n, true) }
// hasRead walks what rendering n renders for a reference path, stopping at a repeat — and at a nested
// draw group when stopAtGroup — since each holds draws of its own.
func (c *drawFence) hasRead(n node, stopAtGroup bool) bool {
func (f *drawFence) hasRead(n node, stopAtGroup bool) bool {
k := hasReadMemo{n, stopAtGroup}
if r, done := c.memo[k]; done {
if r, done := f.memo[k]; done {
return r
}
r := false
for _, e := range renderEdges(n) {
if readsOnEdge(n, e) || (walksInto(e.to, stopAtGroup) && c.hasRead(e.to, stopAtGroup)) {
if readsOnEdge(n, e) || (walksInto(e.to, stopAtGroup) && f.hasRead(e.to, stopAtGroup)) {
r = true
break
}
}
if c.memo == nil {
c.memo = map[hasReadMemo]bool{}
if f.memo == nil {
f.memo = map[hasReadMemo]bool{}
}
c.memo[k] = r
f.memo[k] = r
return r
}
+2 -2
View File
@@ -24,7 +24,7 @@ type surveyAt struct {
wholePins pinSet
}
// surveyRoute is how a render reaches a draw: as its author spells it, and the root edge's label.
// surveyRoute is how a render reaches a read: as its author spells it, and the root edge's label.
type surveyRoute struct{ spelling, label string }
// pathRead is one reference a render reads: a path, or a bare reference with no tail.
@@ -153,7 +153,7 @@ func (s *readSurvey) edge(from node, e renderEdge, at surveyAt) {
s.walk(e.to, at)
}
// spelled names the route, and the reference it reaches a draw by where its root edge is not that
// spelled names the route, and the reference it reaches a read by where its root edge is not that
// reference.
func (r surveyRoute) spelled(ref string) string {
if ref == "" || ref == r.label {