@@ -14,7 +14,17 @@ import (
14
14
"golang.org/x/xerrors"
15
15
)
16
16
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
+ )
18
28
19
29
var (
20
30
docsDirectory string
@@ -91,14 +101,20 @@ func prepareDocsDirectory() error {
91
101
func writeDocs (sections [][]byte ) error {
92
102
log .Println ("Write docs to destination" )
93
103
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
+
94
110
for _ , section := range sections {
95
111
sectionName , err := extractSectionName (section )
96
112
if err != nil {
97
113
return xerrors .Errorf ("can't extract section name: %w" , err )
98
114
}
99
115
log .Printf ("Write section: %s" , sectionName )
100
116
101
- docPath := path .Join (docsDirectory , apiSubdir , sectionName )
117
+ docPath := path .Join (apiDir , sectionName )
102
118
err = os .WriteFile (docPath , section , 0644 ) // #nosec
103
119
if err != nil {
104
120
return xerrors .Errorf (`can't write doc file "%s": %w` , docPath , err )
0 commit comments