cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

Generators, tests and code name the new doc paths

Dami committed c0adea8
functions.md is generated into docs/reference/ with its front matter,
config.md's reference into docs/reference/config.md. The docs tests walk
every folder of docs/, and the macro, file format and keys tests read
their pages' new paths. Usage text, option descriptions, recorded
macro comments and code comments name the pages where they are now.
commit
c0adea8b20fb40eb2c2dd9f80851daa960575264
parent
dc684acbcc695f109dce887c1b745d0c10bf2639
author
Dami <dami.etoile@gmail.com>
32 files changed, +82 -62
Mcmd/012/configcmd.go2+-
Mcmd/012/main.go2+-
Mdocs/reference/config.md4++--
Minternal/chart/stress_test.go2+-
Minternal/config/config_test.go6++--
Minternal/config/docs.go2+-
Minternal/config/docs_test.go11+++++++--
Minternal/config/output.go2+-
Minternal/config/registry.go10++++----
Minternal/fileio/stress_test.go2+-
Minternal/functions/doc_test.go10++++----
Minternal/keyring/keyring.go2+-
Minternal/macro/builtins.go2+-
Minternal/serve/open.go2+-
Minternal/serve/options.go2+-
Minternal/serve/stress_test.go2+-
Minternal/sheet/file_doc_test.go8+++---
Minternal/sheet/historysize.go2+-
Minternal/sheet/pivot_test.go2+-
Minternal/sheet/store.go2+-
Minternal/sheet/stress_test.go2+-
Minternal/stress/benchrec/main.go2+-
Minternal/stress/gen.go2+-
Minternal/telemetry/telemetry.go2+-
Minternal/ui/docs_test.go37++++++++++++++++++++----------
Minternal/ui/macro.go2+-
Minternal/ui/macro_doc_test.go8+++---
Minternal/ui/macrohostnav.go2+-
Minternal/ui/macromanage.go2+-
Minternal/ui/macrorec.go4++--
Minternal/ui/recovery.go2+-
Minternal/ui/stress_test.go2+-
M cmd/012/configcmd.go +1 -1
M cmd/012/main.go +1 -1
M docs/reference/config.md +2 -2
M internal/chart/stress_test.go +1 -1
M internal/config/config_test.go +3 -3
M internal/config/docs.go +1 -1
M internal/config/docs_test.go +9 -2
M internal/config/output.go +1 -1
M internal/config/registry.go +5 -5
@@ -2,7 +2,7 @@
22 // "key = value" lines in <user config dir>/012/config, with # comments and33 // config-file includes. One registry (Options) says what every option is44 // called, its type, default, environment variable, flag and meaning; the5-// parser, `012 config`, docs/config.md and the in-app Settings all come5+// parser, `012 config`, docs/reference/config.md and the in-app Settings all come66 // from it.77 //88 // Settings are process-wide. Settings that belong to a workbook (decimal
@@ -43,7 +43,7 @@ func (k Kind) String() string {
4343 type Option struct {4444 Name string4545 Kind Kind46- Group string // heading in docs/config.md and `012 config`46+ Group string // heading in docs/reference/config.md and `012 config`4747 Default string // as it would be written in the file4848 Values []string // for Enum4949 Env []string // environment variables that set it, first set wins
@@ -73,7 +73,7 @@ const (
7373 var Groups = []string{GroupAppearance, GroupData, GroupJEV, GroupTelemetry, GroupServe, GroupFiles}7474 7575 // Options is every setting. Add an option here and read it with76-// Config.String, Bool or List; parsing, `012 config`, docs/config.md76+// Config.String, Bool or List; parsing, `012 config`, docs/reference/config.md7777 // (go test ./internal/config -update-docs) and Settings follow.7878 var Options = []Option{7979 {Name: "theme", Group: GroupAppearance, Default: "terminal", Env: []string{"O12_THEME"}, Flag: "--theme", Live: true,
@@ -113,7 +113,7 @@ var Options = []Option{
113113 Desc: "The JEV model to ask; the service's default when empty."},114114 115115 {Name: "log-file", Kind: Path, Group: GroupTelemetry, Env: []string{"O12_LOG"}, Flag: "--log",116- Desc: "Append telemetry events to this JSON log file. See docs/observability.md."},116+ Desc: "Append telemetry events to this JSON log file. See docs/contributing/observability.md."},117117 {Name: "log-level", Kind: Enum, Group: GroupTelemetry, Default: "info", Values: []string{"debug", "info", "warn", "error"},118118 Env: []string{"O12_LOG_LEVEL"},119119 Desc: "The least severe telemetry event recorded; debug adds every frame and command."},
@@ -124,7 +124,7 @@ var Options = []Option{
124124 125125 {Name: "serve-listen", Kind: Address, Group: GroupServe, Default: "127.0.0.1:2312",126126 Desc: "The address 012 serve listens on. Anything but the loopback address lets other machines " +127- "reach it (with an authorized key). See docs/ssh.md."},127+ "reach it (with an authorized key). See docs/terminal/ssh.md."},128128 {Name: "serve-authorized-keys", Kind: Path, Group: GroupServe, Default: "~/.ssh/authorized_keys",129129 Desc: "The public keys allowed to log in to 012 serve, in OpenSSH's authorized_keys format."},130130 {Name: "serve-host-key", Kind: Path, Group: GroupServe,
M internal/fileio/stress_test.go +1 -1
M internal/functions/doc_test.go +5 -5
@@ -14,10 +14,10 @@ import (
1414 "testing"1515 )1616 17-var updateDocs = flag.Bool("update-docs", false, "rewrite docs/functions.md from the function table")17+var updateDocs = flag.Bool("update-docs", false, "rewrite docs/reference/functions.md from the function table")1818 1919 // docsPath is the generated function reference.20-const docsPath = "../../docs/functions.md"20+const docsPath = "../../docs/reference/functions.md"2121 2222 // categories names the group of the functions each file defines, in the2323 // order the reference lists them.
@@ -37,7 +37,7 @@ var categories = []struct{ file, title string }{
3737 {"jev.go", "JEV (hosted model)"},3838 }3939 40-// TestFunctionsDoc keeps docs/functions.md in step with the function40+// TestFunctionsDoc keeps docs/reference/functions.md in step with the function4141 // table, as help is: run `go test ./internal/functions -run FunctionsDoc4242 // -update-docs` after adding a function.4343 func TestFunctionsDoc(t *testing.T) {
@@ -54,7 +54,7 @@ func TestFunctionsDoc(t *testing.T) {
5454 }5555 want, err := os.ReadFile(docsPath)5656 if err != nil || string(want) != got {57- t.Errorf("docs/functions.md is stale; run go test ./internal/functions -run FunctionsDoc -update-docs")57+ t.Errorf("docs/reference/functions.md is stale; run go test ./internal/functions -run FunctionsDoc -update-docs")5858 }5959 }6060
@@ -95,7 +95,7 @@ func definingFiles() (map[string]string, error) {
9595 9696 func functionsDoc(byFile map[string]string) string {9797 var b strings.Builder98- b.WriteString("# Functions\n\n")98+ b.WriteString("---\ntitle: \"Functions\"\nsidebar_position: 3\n---\n\n# Functions\n\n")9999 b.WriteString("<!-- Generated from the engine's function table by TestFunctionsDoc; do not edit. -->\n\n")100100 fmt.Fprintf(&b, "012 has %d functions. They follow Google Sheets' names, arguments and\n", len(Funcs()))101101 b.WriteString("semantics; `[brackets]` mark optional arguments. Function names are\n")
M internal/keyring/keyring.go +1 -1
M internal/macro/builtins.go +1 -1
M internal/serve/open.go +1 -1
M internal/serve/options.go +1 -1
M internal/serve/stress_test.go +1 -1
M internal/sheet/file_doc_test.go +4 -4
M internal/sheet/historysize.go +1 -1
M internal/sheet/pivot_test.go +1 -1
M internal/sheet/store.go +1 -1
M internal/sheet/stress_test.go +1 -1
M internal/stress/benchrec/main.go +1 -1
M internal/stress/gen.go +1 -1
M internal/telemetry/telemetry.go +1 -1
M internal/ui/docs_test.go +25 -12
@@ -1,6 +1,7 @@
11 package ui22 33 import (4+ "io/fs"45 "os"56 "path/filepath"67 "regexp"
@@ -14,17 +15,29 @@ import (
1415 // The docs name menus, commands and keys; these tests keep what they name1516 // true of the registry. scripts/doccheck checks links, the index and media.1617 17-// userDocs reads README.md and docs/*.md with fenced code blocks and18+// docPages lists the Markdown pages under docs/, in every folder.19+func docPages(t *testing.T) []string {20+ t.Helper()21+ var paths []string22+ err := filepath.WalkDir("../../docs", func(p string, d fs.DirEntry, err error) error {23+ if err == nil && !d.IsDir() && filepath.Ext(p) == ".md" {24+ paths = append(paths, p)25+ }26+ return err27+ })28+ if err != nil {29+ t.Fatal(err)30+ }31+ return paths32+}33+34+// userDocs reads README.md and the docs with fenced code blocks and1835 // inline code removed and each paragraph on one line, so a menu path1936 // wrapped across lines reads whole. The generated function reference is2037 // left out: it names no menus.2138 func userDocs(t *testing.T) map[string]string {2239 t.Helper()23- paths, err := filepath.Glob("../../docs/*.md")24- if err != nil {25- t.Fatal(err)26- }27- paths = append(paths, "../../README.md")40+ paths := append(docPages(t), "../../README.md")2841 out := map[string]string{}2942 for _, p := range paths {3043 if filepath.Base(p) == "functions.md" {
@@ -154,7 +167,7 @@ var (
154167 // command line (`:settings.vim`) or in scripts (run("format.bold")),155168 // are registered.156169 func TestDocsCommandIDs(t *testing.T) {157- for _, p := range []string{"../../docs/keys.md", "../../docs/macros.md"} {170+ for _, p := range []string{"../../docs/reference/keys.md", "../../docs/reference/macro-api.md"} {158171 data, err := os.ReadFile(p)159172 if err != nil {160173 t.Fatal(err)
@@ -169,10 +182,10 @@ func TestDocsCommandIDs(t *testing.T) {
169182 }170183 }171184 172-// TestKeysDocCoversKeymap checks docs/keys.md lists every key bound to a185+// TestKeysDocCoversKeymap checks docs/reference/keys.md lists every key bound to a173186 // command, written as the menus and help show it.174187 func TestKeysDocCoversKeymap(t *testing.T) {175- data, err := os.ReadFile("../../docs/keys.md")188+ data, err := os.ReadFile("../../docs/reference/keys.md")176189 if err != nil {177190 t.Fatal(err)178191 }
@@ -184,7 +197,7 @@ func TestKeysDocCoversKeymap(t *testing.T) {
184197 label := keyLabel(k)185198 re := regexp.MustCompile(`(^|[\s,|(/])` + regexp.QuoteMeta(label) + `($|[\s,|)/.;:])`)186199 if !re.MatchString(doc) {187- t.Errorf("docs/keys.md doesn't list %s (%s, %s)", label, id, commands[id].title)200+ t.Errorf("docs/reference/keys.md doesn't list %s (%s, %s)", label, id, commands[id].title)188201 }189202 }190203 var vimKeys []string
@@ -201,10 +214,10 @@ func TestKeysDocCoversKeymap(t *testing.T) {
201214 for _, k := range vimKeys {202215 if strings.Contains(k, "+") || len(k) > 2 {203216 if !strings.Contains(doc, keyLabel(k)) && !strings.Contains(doc, theme.KeyLabel(k)) {204- t.Errorf("docs/keys.md doesn't list the vim key %s", k)217+ t.Errorf("docs/reference/keys.md doesn't list the vim key %s", k)205218 }206219 } else if !strings.Contains(doc, "`"+k+"`") {207- t.Errorf("docs/keys.md doesn't list the vim key `%s`", k)220+ t.Errorf("docs/reference/keys.md doesn't list the vim key `%s`", k)208221 }209222 }210223 }
M internal/ui/macro.go +1 -1
M internal/ui/macro_doc_test.go +4 -4
M internal/ui/macrohostnav.go +1 -1
M internal/ui/macromanage.go +1 -1
M internal/ui/macrorec.go +2 -2
M internal/ui/recovery.go +1 -1
M internal/ui/stress_test.go +1 -1