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
3 changed files with 9 additions and 5 deletions
Showing only changes of commit 69703dec91 - Show all commits
+2 -2
View File
@@ -62,8 +62,8 @@ type linkedNames struct {
} }
// linkTemplates links ts in steps, each over every template before the next starts, each // linkTemplates links ts in steps, each over every template before the next starts, each
// returning what it builds and taking what an earlier step built as an argument: the references, // returning what it builds: the references and the compiled formats, kept on each template, the
// the names' targets, the compiled formats, the keys and reads of each name, and the column each // names' targets, keys and reads, passed to the steps after as arguments, and the column each
// format reads. The bindings take their targets and keys once every check has passed. // format reads. The bindings take their targets and keys once every check has passed.
func linkTemplates(ts []linkSite, root map[string]node) error { func linkTemplates(ts []linkSite, root map[string]node) error {
for _, s := range ts { for _, s := range ts {
+3 -3
View File
@@ -96,11 +96,11 @@ func bindNames(root node) error {
if err != nil { if err != nil {
return err return err
} }
return checkRead(scopes, read) return checkEveryNameRead(scopes, read)
} }
// checkRead refuses a binding of scopes that read does not hold. // checkEveryNameRead refuses a binding of scopes that nothing reads.
func checkRead(scopes []*nameScope, read map[*nameBinding]bool) error { func checkEveryNameRead(scopes []*nameScope, read map[*nameBinding]bool) error {
for _, sc := range scopes { for _, sc := range scopes {
for _, b := range sc.order { for _, b := range sc.order {
if !read[b] { if !read[b] {
+4
View File
@@ -6,6 +6,7 @@ import (
"strings" "strings"
"github.com/larvit/fejkdata/internal/grammar" "github.com/larvit/fejkdata/internal/grammar"
"github.com/larvit/fejkdata/internal/invariant"
) )
// checkNameReads refuses each binding of t that checkUses refuses, a read of a name inside the // checkNameReads refuses each binding of t that checkUses refuses, a read of a name inside the
@@ -67,6 +68,9 @@ func rendersInside(nodes []node, t *template) bool {
// template reaches the binder through fields. Where the spelling would be a CLI argument or tag // template reaches the binder through fields. Where the spelling would be a CLI argument or tag
// of one reference alone, that entry point's own refusal then names the bare path. // of one reference alone, that entry point's own refusal then names the bare path.
func (b *nameBinding) checkUses(uses []nameUse) error { func (b *nameBinding) checkUses(uses []nameUse) error {
if len(uses) == 0 {
panic(invariant.Broken("name %q has no read at link, though its compile found one", b.name))
}
r := uses[0] r := uses[0]
if len(uses) > 1 || r.nested { if len(uses) > 1 || r.nested {
return nil return nil