56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
|
package lib
|
|||
|
|
|||
|
import (
|
|||
|
"strings"
|
|||
|
"text/template"
|
|||
|
|
|||
|
"git.ymnuktech.ru/ymnuk/yt-gen-app/lib/templ"
|
|||
|
"github.com/yuzutech/kroki-go"
|
|||
|
)
|
|||
|
|
|||
|
func docRoles() {
|
|||
|
var err error
|
|||
|
var tmpl *template.Template
|
|||
|
var out []byte
|
|||
|
// Сгенерируем граф с ролями
|
|||
|
if tmpl, err = templ.ReadTmplFile("tmpl/docs/backend/roles-graph.tmpl"); err != nil {
|
|||
|
panic(err)
|
|||
|
}
|
|||
|
if out, err = templ.ExecuteTmplFile(tmpl, Project); err != nil {
|
|||
|
panic(err)
|
|||
|
}
|
|||
|
client := NewKrokiClient()
|
|||
|
if result, err := client.FromString(string(out), kroki.GraphViz, kroki.SVG); err != nil {
|
|||
|
panic(err)
|
|||
|
} else {
|
|||
|
templ.WriteFile(AppConfig.OutdirDoc+"/roles.svg", []byte(result))
|
|||
|
}
|
|||
|
//templ.WriteFile(AppConfig.OutdirDoc+"/roles.txt", out)
|
|||
|
if !AppConfig.IsSingleDoc {
|
|||
|
if tmpl, err = templ.ReadTmplFile("tmpl/docs/backend/roles.tmpl"); err != nil {
|
|||
|
panic(err)
|
|||
|
}
|
|||
|
if out, err = templ.ExecuteTmplFile(tmpl, Project); err != nil {
|
|||
|
panic(err)
|
|||
|
}
|
|||
|
if AppConfig.IsMarkdown {
|
|||
|
if err = templ.WriteFile(AppConfig.OutdirDoc+"/roles.md", out); err != nil {
|
|||
|
panic(err)
|
|||
|
}
|
|||
|
}
|
|||
|
if AppConfig.IsHtml {
|
|||
|
var buff []byte
|
|||
|
if buff, err = templ.Content.ReadFile("tmpl/docs/styles.tmpl"); err != nil {
|
|||
|
panic(err)
|
|||
|
}
|
|||
|
//{{ includeTemplPart "tmpl/docs/styles.tmpl" nil }}
|
|||
|
out = append(buff, out...)
|
|||
|
out = []byte(strings.ReplaceAll(string(out), ".md", ".html"))
|
|||
|
out = mdToHTML(out)
|
|||
|
if err = templ.WriteFile(AppConfig.OutdirDoc+"/roles.html", out); err != nil {
|
|||
|
panic(err)
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|