-
Notifications
You must be signed in to change notification settings - Fork 27
/
docs.go
58 lines (48 loc) · 1.18 KB
/
docs.go
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
46
47
48
49
50
51
52
53
54
55
56
57
58
//go:generate go build -v github.com/lmorg/murex/utils/docgen
//go:generate ./docgen -warning -panic -config gen/docgen.yaml
//go:generate go fmt builtins/docs/summaries.go
package main
import (
"embed"
"fmt"
"strings"
"github.com/lmorg/murex/app"
"github.com/lmorg/murex/builtins/docs"
"github.com/lmorg/murex/debug"
)
//go:embed docs/apis/*.md
//go:embed docs/changelog/*.md
//go:embed docs/commands/*.md
//go:embed docs/events/*.md
//go:embed docs/mkarray/*.md
//go:embed docs/optional/*.md
//go:embed docs/parser/*.md
//go:embed docs/types/*.md
//go:embed docs/user-guide/*.md
//go:embed docs/variables/*.md
//go:embed docs/integrations/*.md
var docsEmbeded embed.FS
func init() {
docs.Definition = docsImport
}
func docsImport(path string) []byte {
if !strings.Contains(path, "/") {
path = "commands/" + path
}
path = fmt.Sprintf("docs/%s.md", path)
if debug.Enabled {
// in debug mode lets output the actual error
b, err := docsEmbeded.ReadFile(path)
if err != nil {
return append([]byte("error: "), []byte(err.Error())...)
}
return b
}
b, _ := docsEmbeded.ReadFile(path)
return b
}
//go:embed LICENSE
var license string
func init() {
app.SetLicenseFull(license)
}