Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 215a3ac

Browse files
bpmctmatifali
authored andcommittedAug 12, 2024
modify to look for Command Line nested in manifest
1 parent 1efad16 commit 215a3ac

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed
 

‎scripts/clidocgen/main.go

+23-16
Original file line numberDiff line numberDiff line change
@@ -146,27 +146,33 @@ func main() {
146146
var found bool
147147
for i := range manifest.Routes {
148148
rt := &manifest.Routes[i]
149-
if rt.Title != "Command Line" {
149+
if rt.Title != "Reference" {
150150
continue
151151
}
152-
rt.Children = nil
153-
found = true
154-
for path, cmd := range wroteMap {
155-
relPath, err := filepath.Rel(docsDir, path)
156-
if err != nil {
157-
flog.Fatalf("getting relative path: %v", err)
152+
for j := range rt.Children {
153+
child := &rt.Children[j]
154+
if child.Title != "Command Line" {
155+
continue
156+
}
157+
child.Children = nil
158+
found = true
159+
for path, cmd := range wroteMap {
160+
relPath, err := filepath.Rel(docsDir, path)
161+
if err != nil {
162+
flog.Fatalf("getting relative path: %v", err)
163+
}
164+
child.Children = append(child.Children, route{
165+
Title: fullName(cmd),
166+
Description: cmd.Short,
167+
Path: relPath,
168+
})
158169
}
159-
rt.Children = append(rt.Children, route{
160-
Title: fullName(cmd),
161-
Description: cmd.Short,
162-
Path: relPath,
170+
// Sort children by title because wroteMap iteration is
171+
// non-deterministic.
172+
sort.Slice(child.Children, func(i, j int) bool {
173+
return child.Children[i].Title < child.Children[j].Title
163174
})
164175
}
165-
// Sort children by title because wroteMap iteration is
166-
// non-deterministic.
167-
sort.Slice(rt.Children, func(i, j int) bool {
168-
return rt.Children[i].Title < rt.Children[j].Title
169-
})
170176
}
171177

172178
if !found {
@@ -183,3 +189,4 @@ func main() {
183189
flog.Fatalf("writing manifest: %v", err)
184190
}
185191
}
192+

0 commit comments

Comments
 (0)
Failed to load comments.