Skip to content

Commit 14a659e

Browse files
committed
Generic api.md page
1 parent c69c157 commit 14a659e

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

docs/api/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Get started with Coder API:
2+
3+
<children>
4+
This page is rendered on https://coder.com/docs/coder-oss/api. Refer to the other documents in the `api/` directory.
5+
</children>

scripts/apidocgen/postprocess/main.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ import (
1414
"golang.org/x/xerrors"
1515
)
1616

17-
const apiSubdir = "api"
17+
const (
18+
apiSubdir = "api"
19+
20+
apiIndexFile = "index.md"
21+
apiIndexContent = `Get started with Coder API:
22+
23+
<children>
24+
This page is rendered on https://coder.com/docs/coder-oss/api. Refer to the other documents in the ` + "`" + `api/` + "`" + ` directory.
25+
</children>
26+
`
27+
)
1828

1929
var (
2030
docsDirectory string
@@ -91,14 +101,20 @@ func prepareDocsDirectory() error {
91101
func writeDocs(sections [][]byte) error {
92102
log.Println("Write docs to destination")
93103

104+
apiDir := path.Join(docsDirectory, apiSubdir)
105+
err := os.WriteFile(path.Join(apiDir, apiIndexFile), []byte(apiIndexContent), 0644) // #nosec
106+
if err != nil {
107+
return xerrors.Errorf(`can't write the index file: %w`, err)
108+
}
109+
94110
for _, section := range sections {
95111
sectionName, err := extractSectionName(section)
96112
if err != nil {
97113
return xerrors.Errorf("can't extract section name: %w", err)
98114
}
99115
log.Printf("Write section: %s", sectionName)
100116

101-
docPath := path.Join(docsDirectory, apiSubdir, sectionName)
117+
docPath := path.Join(apiDir, sectionName)
102118
err = os.WriteFile(docPath, section, 0644) // #nosec
103119
if err != nil {
104120
return xerrors.Errorf(`can't write doc file "%s": %w`, docPath, err)

0 commit comments

Comments
 (0)