style: make structs unexported

docs-refactor
TorchedSammy 2022-12-02 16:00:55 -04:00
parent 1b24e91597
commit 65e35dbab9
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 12 additions and 12 deletions

View File

@ -19,18 +19,18 @@ layout: apidoc
` `
type EmmyPiece struct { type emmyPiece struct {
FuncName string FuncName string
Docs []string Docs []string
Params []string // we only need to know param name to put in function Params []string // we only need to know param name to put in function
} }
type Module struct { type module struct {
Docs []DocPiece Docs []docPiece
ShortDescription string ShortDescription string
Description string Description string
} }
type DocPiece struct { type docPiece struct {
Doc []string Doc []string
FuncSig string FuncSig string
FuncName string FuncName string
@ -72,12 +72,12 @@ func main() {
"bait": "b", "bait": "b",
"terminal": "term", "terminal": "term",
} }
docs := make(map[string]Module) docs := make(map[string]module)
emmyDocs := make(map[string][]EmmyPiece) emmyDocs := make(map[string][]emmyPiece)
for l, f := range pkgs { for l, f := range pkgs {
p := doc.New(f, "./", doc.AllDecls) p := doc.New(f, "./", doc.AllDecls)
pieces := []DocPiece{} pieces := []docPiece{}
for _, t := range p.Funcs { for _, t := range p.Funcs {
mod := l mod := l
if strings.HasPrefix(t.Name, "hl") { mod = "hilbish" } if strings.HasPrefix(t.Name, "hl") { mod = "hilbish" }
@ -86,7 +86,7 @@ func main() {
funcsig := parts[0] funcsig := parts[0]
doc := parts[1:] doc := parts[1:]
funcdoc := []string{} funcdoc := []string{}
em := EmmyPiece{FuncName: strings.TrimPrefix(t.Name, prefix[mod])} em := emmyPiece{FuncName: strings.TrimPrefix(t.Name, prefix[mod])}
for _, d := range doc { for _, d := range doc {
if strings.HasPrefix(d, "---") { if strings.HasPrefix(d, "---") {
emmyLine := strings.TrimSpace(strings.TrimPrefix(d, "---")) emmyLine := strings.TrimSpace(strings.TrimPrefix(d, "---"))
@ -104,7 +104,7 @@ func main() {
} }
} }
dps := DocPiece{ dps := docPiece{
Doc: funcdoc, Doc: funcdoc,
FuncSig: funcsig, FuncSig: funcsig,
FuncName: strings.TrimPrefix(t.Name, prefix[mod]), FuncName: strings.TrimPrefix(t.Name, prefix[mod]),
@ -120,7 +120,7 @@ func main() {
funcsig := parts[0] funcsig := parts[0]
doc := parts[1:] doc := parts[1:]
funcdoc := []string{} funcdoc := []string{}
em := EmmyPiece{FuncName: strings.TrimPrefix(m.Name, prefix[l])} em := emmyPiece{FuncName: strings.TrimPrefix(m.Name, prefix[l])}
for _, d := range doc { for _, d := range doc {
if strings.HasPrefix(d, "---") { if strings.HasPrefix(d, "---") {
emmyLine := strings.TrimSpace(strings.TrimPrefix(d, "---")) emmyLine := strings.TrimSpace(strings.TrimPrefix(d, "---"))
@ -137,7 +137,7 @@ func main() {
funcdoc = append(funcdoc, d) funcdoc = append(funcdoc, d)
} }
} }
dps := DocPiece{ dps := docPiece{
Doc: funcdoc, Doc: funcdoc,
FuncSig: funcsig, FuncSig: funcsig,
FuncName: strings.TrimPrefix(m.Name, prefix[l]), FuncName: strings.TrimPrefix(m.Name, prefix[l]),
@ -151,7 +151,7 @@ func main() {
descParts := strings.Split(strings.TrimSpace(p.Doc), "\n") descParts := strings.Split(strings.TrimSpace(p.Doc), "\n")
shortDesc := descParts[0] shortDesc := descParts[0]
desc := descParts[1:] desc := descParts[1:]
docs[l] = Module{ docs[l] = module{
Docs: pieces, Docs: pieces,
ShortDescription: shortDesc, ShortDescription: shortDesc,
Description: strings.Join(desc, "\n"), Description: strings.Join(desc, "\n"),