The manual in the binary: llmgw docs, and Help in the console
Every document and a page for every command, built from their help, read like info: topics, contents, find. ? opens the console's own page, which is new and covers every screen. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
44425193bd
commit
dac7ff0e99
7 files changed
+1129
-3
No files matched your search
@@ -319,3 +319,74 @@ func TestAModelIsFoundOnTheRegistryAndServedFromTheConsole(t *testing.T) {
|
||||
t.Fatalf("would run %q %q", act.kind, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTheManualHasEveryPageAndFindsInThem(t *testing.T) {
|
||||
v := newDocViewer()
|
||||
for _, k := range []string{"console", "install", "reference", "commands", "changes"} {
|
||||
if findTopic(v.topics, k) < 0 {
|
||||
t.Errorf("no %s page", k)
|
||||
}
|
||||
}
|
||||
cmds := commandsManual()
|
||||
for _, c := range []string{"llmgw ctl model update", "llmgw users approve", "llmgw docs"} {
|
||||
if !strings.Contains(cmds, "# "+c) {
|
||||
t.Errorf("the commands page lacks %s", c)
|
||||
}
|
||||
}
|
||||
// Every line fits the width it was laid out for.
|
||||
for _, tp := range v.topics {
|
||||
for _, l := range renderMarkdown(tp.src(), 80) {
|
||||
if !strings.HasPrefix(l.plain, " ") && len([]rune(l.plain)) > 80 {
|
||||
t.Errorf("%s: a line of %d: %q", tp.key, len([]rune(l.plain)), l.plain)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
v.show(findTopic(v.topics, "console"))
|
||||
v.query = "drain"
|
||||
v.find(80, 0, 1)
|
||||
if l := v.lines(80)[v.scroll+2]; !strings.Contains(strings.ToLower(l.plain), "drain") {
|
||||
t.Errorf("found at %q", l.plain)
|
||||
}
|
||||
v.openTOC(80)
|
||||
if v.toc == nil || len(v.toc.items) < 5 {
|
||||
t.Fatal("no contents")
|
||||
}
|
||||
}
|
||||
|
||||
func TestQuestionMarkOpensTheConsolesPage(t *testing.T) {
|
||||
m, _ := consoleWith(t, cNodes)
|
||||
tm := press(m, "?")
|
||||
cm := tm.(consoleModel)
|
||||
if cm.menu != cManual || !cm.detail || cm.docs.topics[cm.docs.open].key != "console" {
|
||||
t.Fatalf("menu %d detail %v", cm.menu, cm.detail)
|
||||
}
|
||||
if !strings.Contains(tm.View(), "The console") {
|
||||
t.Error("the page is not shown")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNextFindsTheNextMatchAndComesRound(t *testing.T) {
|
||||
v := newDocViewer()
|
||||
v.show(findTopic(v.topics, "console"))
|
||||
v.query = "revok"
|
||||
lines := v.lines(80)
|
||||
var hits []int
|
||||
for i, l := range lines {
|
||||
if strings.Contains(strings.ToLower(l.plain), "revok") {
|
||||
hits = append(hits, i)
|
||||
}
|
||||
}
|
||||
if len(hits) < 2 {
|
||||
t.Fatalf("hits %v", hits)
|
||||
}
|
||||
v.find(80, 0, 1)
|
||||
seen := []int{v.scroll + 2}
|
||||
for range hits {
|
||||
v.key(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("n")}, 80, 30)
|
||||
seen = append(seen, v.scroll+2)
|
||||
}
|
||||
if seen[0] != hits[0] || seen[1] != hits[1] || seen[len(hits)] != hits[0] {
|
||||
t.Errorf("hits %v, went %v", hits, seen)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user