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 11 additions and 8 deletions
Showing only changes of commit cde9e354c5 - Show all commits
+1 -1
View File
@@ -431,7 +431,7 @@ error on every later call; a `datatype` in a tag other than the one its Go type
refused, naming that type. refused, naming that type.
A `*Generator` is safe for concurrent use; a sequence is reproducible only A `*Generator` is safe for concurrent use; a sequence is reproducible only
when drawn from one goroutine. Changing how a value is composed shifts the seeded when drawn from one goroutine. Changing how a value is composed shifts the
stream for that value and everything drawn after it. stream for that value and everything drawn after it.
### Your own CLI ### Your own CLI
+8 -5
View File
@@ -6,7 +6,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io"
"io/fs" "io/fs"
"os" "os"
"path/filepath" "path/filepath"
@@ -129,10 +128,14 @@ func TestRunDotPath(t *testing.T) {
} }
func TestRunWithoutASeedTakesTheSystemSeed(t *testing.T) { func TestRunWithoutASeedTakesTheSystemSeed(t *testing.T) {
var drawn, seeded bytes.Buffer var drawn, seeded, errb bytes.Buffer
run("fejkdata", shipped, nil, 42, strings.NewReader("{uuid()}"), &drawn, io.Discard) if code := run("fejkdata", shipped, nil, 42, strings.NewReader("{uuid()}"), &drawn, &errb); code != 0 {
run("fejkdata", shipped, []string{"--seed", "42"}, 7, strings.NewReader("{uuid()}"), &seeded, io.Discard) t.Fatalf("run with system seed 42 = %d, stderr=%q", code, errb.String())
if drawn.String() == "" || drawn.String() != seeded.String() { }
if code := run("fejkdata", shipped, []string{"--seed", "42"}, 7, strings.NewReader("{uuid()}"), &seeded, &errb); code != 0 {
t.Fatalf("run --seed 42 = %d, stderr=%q", code, errb.String())
}
if drawn.String() != seeded.String() {
t.Fatalf("run with system seed 42 = %q, run --seed 42 = %q; want the same draw", drawn.String(), seeded.String()) t.Fatalf("run with system seed 42 = %q, run --seed 42 = %q; want the same draw", drawn.String(), seeded.String())
} }
} }
+2 -2
View File
@@ -96,8 +96,8 @@ func (loadError) Is(target error) bool { return target == ErrLoad }
// It errors on a missing directory, invalid JSON or invalid data. Given only // It errors on a missing directory, invalid JSON or invalid data. Given only
// WithDataFS() with no modules, New loads no data, and the generator renders templates // WithDataFS() with no modules, New loads no data, and the generator renders templates
// that read none. A source whose .fejkdata.json carries an index, as each shipped // that read none. A source whose .fejkdata.json carries an index, as each shipped
// module's does, loads each category on the first call reaching it. Data failing to load, in New or on that first call, gives an error matching // module's does, loads each category on the first call reaching it. Data failing to
// [ErrLoad]. // load, in New or on that first call, gives an error matching [ErrLoad].
func New(opts ...Option) (*Generator, error) { func New(opts ...Option) (*Generator, error) {
var c config var c config
for _, opt := range opts { for _, opt := range opts {