blob: db367458745f0894f2b796610ad4f9ebd4f850fa (
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
|
package main
import (
"github.com/BurntSushi/toml"
"io/ioutil"
"os"
"strings"
)
type config struct {
DocsRoot string
TemplateFile string
TargetDir string
CssFile string
BaseUrl string
}
func readConfig(file string) (cfg config) {
_, err := toml.DecodeFile(file, &cfg)
if err != nil {
panic(err)
}
cfg.BaseUrl = strings.TrimSuffix(cfg.BaseUrl, "/")
return
}
func nameify(raw string) (clean string) {
clean = strings.ReplaceAll(raw, "-", " ")
clean = strings.TrimSpace(clean)
clean = strings.Title(clean)
return
}
func createTempDir(name string) (path string) {
path, err := ioutil.TempDir("", "godocs")
if err != nil {
panic(err)
}
defer os.RemoveAll(path)
return
}
|