docs: move api and cli docs routes to reference/ (#14241)

This commit is contained in:
Muhammad Atif Ali
2024-08-13 18:39:46 +03:00
committed by GitHub
parent 6f9b1a39f4
commit 48f29a1995
145 changed files with 4121 additions and 3448 deletions
+4 -4
View File
@@ -16,8 +16,8 @@ import (
)
const (
apiSubdir = "api"
apiIndexFile = "index.md"
apiSubdir = "reference/api"
apiIndexFile = "README.md"
apiIndexContent = `Get started with the Coder API:
## Quickstart
@@ -38,12 +38,12 @@ curl https://coder.example.com/api/v2/workspaces?q=owner:me \
## Use cases
See some common [use cases](../admin/automation.md#use-cases) for the REST API.
See some common [use cases](../../admin/automation.md#use-cases) for the REST API.
## Sections
<children>
This page is rendered on https://coder.com/docs/coder-oss/api. Refer to the other documents in the ` + "`api/`" + ` directory.
This page is rendered on https://coder.com/docs/reference/api. Refer to the other documents in the ` + "`api/`" + ` directory.
</children>
`
)
+1 -1
View File
@@ -33,7 +33,7 @@ Aliases:
| Name | Purpose |
| ---- | ----- |
{{- end }}
| [{{ $cmd.Name | wrapCode }}](./{{if atRoot $}}cli/{{end}}{{commandURI $cmd}}) | {{ $cmd.Short }} |
| [{{ $cmd.Name | wrapCode }}](./{{commandURI $cmd}}) | {{ $cmd.Short }} |
{{- end}}
{{ "" }}
{{- range $index, $opt := visibleOptions . }}
+1 -1
View File
@@ -77,7 +77,7 @@ func fullName(cmd *serpent.Command) string {
func fmtDocFilename(cmd *serpent.Command) string {
if cmd.FullName() == "coder" {
// Special case for index.
return "../cli.md"
return "./README.md"
}
name := strings.ReplaceAll(fullName(cmd), " ", "_")
return fmt.Sprintf("%s.md", name)
+23 -17
View File
@@ -87,7 +87,7 @@ func main() {
var (
docsDir = filepath.Join(workdir, "docs")
cliMarkdownDir = filepath.Join(docsDir, "cli")
cliMarkdownDir = filepath.Join(docsDir, "reference/cli")
)
cmd, err := root.Command(root.EnterpriseSubcommands())
@@ -146,27 +146,33 @@ func main() {
var found bool
for i := range manifest.Routes {
rt := &manifest.Routes[i]
if rt.Title != "Command Line" {
if rt.Title != "Reference" {
continue
}
rt.Children = nil
found = true
for path, cmd := range wroteMap {
relPath, err := filepath.Rel(docsDir, path)
if err != nil {
flog.Fatalf("getting relative path: %v", err)
for j := range rt.Children {
child := &rt.Children[j]
if child.Title != "Command Line" {
continue
}
rt.Children = append(rt.Children, route{
Title: fullName(cmd),
Description: cmd.Short,
Path: relPath,
child.Children = nil
found = true
for path, cmd := range wroteMap {
relPath, err := filepath.Rel(docsDir, path)
if err != nil {
flog.Fatalf("getting relative path: %v", err)
}
child.Children = append(child.Children, route{
Title: fullName(cmd),
Description: cmd.Short,
Path: relPath,
})
}
// Sort children by title because wroteMap iteration is
// non-deterministic.
sort.Slice(child.Children, func(i, j int) bool {
return child.Children[i].Title < child.Children[j].Title
})
}
// Sort children by title because wroteMap iteration is
// non-deterministic.
sort.Slice(rt.Children, func(i, j int) bool {
return rt.Children[i].Title < rt.Children[j].Title
})
}
if !found {