mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
docs: move api and cli docs routes to reference/ (#14241)
This commit is contained in:
@@ -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>
|
||||
`
|
||||
)
|
||||
|
||||
@@ -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 . }}
|
||||
|
||||
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user