blob: 870e0f93186686301c3a44fe6983b4559232c036 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package main
import (
"fmt"
"github.com/otiai10/copy"
"os"
"path/filepath"
)
func main() {
// show usage if config file is missing
if len(os.Args) < 2 {
fmt.Println("Usage: godocs <config>")
os.Exit(1)
}
// read config file specified in the command line
cfg := readConfig(os.Args[1])
// create temporary target directory
tmp := createTempDir("godocs")
// gather all sites in docsRoot
sites := getSites(cfg)
for _, site := range sites {
// collect all entries
entries := findEntries(site.sourcePath)
// render all entries
createPageMap(&site, entries)
// create navigation item slice
createNavSlice(&site, cfg)
// output the site
generateSite(site, cfg, tmp)
}
// copy CSS file to generation directory
err := copy.Copy(cfg.CssFile, filepath.Join(tmp, "style.css"))
if err != nil {
panic(err)
}
}
|