Make great documentation goal 1.2, and plan the README's reorganisation and the nested-template gaps #33
@@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/larvit/fejkdata/internal/invariant"
|
"github.com/larvit/fejkdata/internal/invariant"
|
||||||
)
|
)
|
||||||
|
|
||||||
// checkCalcFields checks each calc operand a field holds; an operand no field holds is a name,
|
// checkCalcFields runs checkOperands over each calc operand naming a field; an operand naming no
|
||||||
// which checkCalcNames checks once names resolve.
|
// field is a name, which checkCalcNames checks once names resolve.
|
||||||
func checkCalcFields(args []string, fields map[string]node) error {
|
func checkCalcFields(args []string, fields map[string]node) error {
|
||||||
return checkOperands(args[0], builtinfunc.ParsedCalc(args[0]), func(name string) []node {
|
return checkOperands(args[0], builtinfunc.ParsedCalc(args[0]), func(name string) []node {
|
||||||
if n, ok := fields[name]; ok {
|
if n, ok := fields[name]; ok {
|
||||||
|
|||||||
@@ -135,8 +135,9 @@ class Nearest:
|
|||||||
|
|
||||||
|
|
||||||
def street_delivery(name, codes):
|
def street_delivery(name, codes):
|
||||||
"""The codes delivered to a street: the digit after the postort's own prefix is 0 or 1 for boxes and 8 for reply mail
|
"""The codes delivered to a street. Outside ONE_POSITION's cities, the digit after the postort's own prefix is 0 or 1
|
||||||
outside ONE_POSITION's cities, per docs/research/research-geo-se.md, Postal codes → Structure."""
|
for boxes and 8 for reply mail; inside them, a second digit 0 marks boxes.
|
||||||
|
Per docs/research/research-geo-se.md, Postal codes → Structure."""
|
||||||
if name in ONE_POSITION:
|
if name in ONE_POSITION:
|
||||||
return [c for c in codes if c[1] != "0"]
|
return [c for c in codes if c[1] != "0"]
|
||||||
largest = collections.Counter(c[:3] for c in codes).most_common(1)[0][1]
|
largest = collections.Counter(c[:3] for c in codes).most_common(1)[0][1]
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ type Template struct {
|
|||||||
n node
|
n node
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fake renders the template once, each {…} drawn afresh.
|
// Fake renders the template once; each call draws anew.
|
||||||
func (t *Template) Fake() string {
|
func (t *Template) Fake() string {
|
||||||
t.g.mu.Lock()
|
t.g.mu.Lock()
|
||||||
defer t.g.mu.Unlock()
|
defer t.g.mu.Unlock()
|
||||||
|
|||||||
+6
-5
@@ -65,7 +65,8 @@ func rendersInside(nodes []node, t *template) bool {
|
|||||||
// refuseSingleRead refuses b when its one read sits in b's own scope, not in a repeat nested inside
|
// refuseSingleRead refuses b when its one read sits in b's own scope, not in a repeat nested inside
|
||||||
// it, at a spot where the bound spelling could stand. That spelling draws the same without the
|
// it, at a spot where the bound spelling could stand. That spelling draws the same without the
|
||||||
// name: write {/word} for {/word as w}{w}. A bound field can stand in only where the reading
|
// name: write {/word} for {/word as w}{w}. A bound field can stand in only where the reading
|
||||||
// template reaches the binder through fields. A calc operand cannot read a reference or a path.
|
// template reaches the binder through fields. A single read as a calc operand stands where a calc
|
||||||
|
// could not read the spelling, a reference or a path.
|
||||||
// Where the spelling would be a whole CLI argument or a whole struct tag, that entry point refuses
|
// Where the spelling would be a whole CLI argument or a whole struct tag, that entry point refuses
|
||||||
// it and names the bare path.
|
// it and names the bare path.
|
||||||
func (b *nameBinding) refuseSingleRead(uses []nameUse) error {
|
func (b *nameBinding) refuseSingleRead(uses []nameUse) error {
|
||||||
@@ -121,10 +122,10 @@ func calcReads(spelling string) bool {
|
|||||||
return err == nil && isVar && v.Name == spelling
|
return err == nil && isVar && v.Name == spelling
|
||||||
}
|
}
|
||||||
|
|
||||||
// refuseTwiceDrawn refuses read, a read of a name landing on n at key under the name's pick, where n
|
// refuseTwiceDrawn refuses read, a read of a name that lands on n, where n renders a field twice and
|
||||||
// renders a field twice and another read of the name addresses that field: the pick keeps one draw
|
// another read of the name addresses that field. The pick keeps one draw of the field: where n binds
|
||||||
// of the field, so beside {n} for a category {w}-{w}, {n.w} cannot say which draw it reads.
|
// a category whose format is {w}-{w}, a {n.w} beside {n} cannot say which draw it reads. key is n's
|
||||||
// addressed maps each level a read of the name addresses to that read.
|
// level under the pick; addressed maps each level a read of the name addresses to that read.
|
||||||
func refuseTwiceDrawn(addressed map[pickKey]string, read string, n node, key pickKey) error {
|
func refuseTwiceDrawn(addressed map[pickKey]string, read string, n node, key pickKey) error {
|
||||||
switch n := n.(type) {
|
switch n := n.(type) {
|
||||||
case *choice:
|
case *choice:
|
||||||
|
|||||||
+3
-3
@@ -7,14 +7,14 @@ import (
|
|||||||
"github.com/larvit/fejkdata/internal/grammar"
|
"github.com/larvit/fejkdata/internal/grammar"
|
||||||
)
|
)
|
||||||
|
|
||||||
// resolvedRef is what a reference resolves to: the head its category is held under, a "/"
|
// resolvedRef is what a reference resolves to. head is "/" and the category's path from the root,
|
||||||
// and then the category's path from the root, and the tail read into it.
|
// the key the category is held under; tail is the path read into the category.
|
||||||
type resolvedRef struct {
|
type resolvedRef struct {
|
||||||
head string
|
head string
|
||||||
tail []string
|
tail []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// categoryOf is the category path a resolvedRef's head names: the head without its "/".
|
// categoryOf is the category path a resolvedRef's head names.
|
||||||
func categoryOf(head string) string { return strings.TrimPrefix(head, "/") }
|
func categoryOf(head string) string { return strings.TrimPrefix(head, "/") }
|
||||||
|
|
||||||
// refSegments resolves a reference written in folder to a path from the root.
|
// refSegments resolves a reference written in folder to a path from the root.
|
||||||
|
|||||||
Reference in New Issue
Block a user