38 lines
717 B
Go
Raw Normal View History

2017-07-01 12:03:10 +00:00
package apiview
import (
2018-04-12 21:05:24 +00:00
"path"
2017-07-01 12:03:10 +00:00
"sort"
"github.com/aerogo/aero"
2019-04-23 05:52:55 +00:00
"github.com/akyoto/color"
2017-07-01 12:03:10 +00:00
"github.com/animenotifier/arn"
2018-04-12 21:05:24 +00:00
"github.com/animenotifier/arn/autodocs"
2017-07-01 12:03:10 +00:00
"github.com/animenotifier/notify.moe/components"
)
// Get api page.
func Get(ctx *aero.Context) string {
2018-04-12 21:05:24 +00:00
types := []*autodocs.Type{}
2017-07-01 12:03:10 +00:00
for typeName := range arn.DB.Types() {
2018-04-12 21:05:24 +00:00
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
}
2017-07-01 12:03:10 +00:00
}
2018-04-12 21:05:24 +00:00
sort.Slice(types, func(i, j int) bool {
return types[i].Name < types[j].Name
})
2017-07-01 12:03:10 +00:00
return ctx.HTML(components.API(types))
}