Show embeds in type documentation

This commit is contained in:
2019-11-18 14:55:12 +09:00
parent cafb43aa17
commit ab81556651
9 changed files with 36 additions and 24 deletions

37
pages/api/api.go Normal file
View File

@ -0,0 +1,37 @@
package api
import (
"path"
"sort"
"github.com/aerogo/aero"
"github.com/akyoto/color"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/arn/autodocs"
"github.com/animenotifier/notify.moe/components"
)
// Get api page.
func Get(ctx aero.Context) error {
types := []*autodocs.Type{}
for typeName := range arn.DB.Types() {
if typeName == "Session" {
continue
}
typ, err := autodocs.GetTypeDocumentation(typeName, path.Join(arn.Root, "arn", typeName+".go"))
types = append(types, typ)
if err != nil {
color.Red(err.Error())
continue
}
}
sort.Slice(types, func(i, j int) bool {
return types[i].Name < types[j].Name
})
return ctx.HTML(components.API(types))
}