38 lines
731 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"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/arn/autodocs"
2017-07-01 12:03:10 +00:00
"github.com/animenotifier/notify.moe/components"
)
// Get api page.
2019-06-01 04:55:49 +00:00
func Get(ctx aero.Context) error {
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
}
2019-06-03 09:32:43 +00:00
typ, err := autodocs.GetTypeDocumentation(typeName, path.Join(arn.Root, "arn", typeName+".go"))
2018-04-12 21:05:24 +00:00
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))
}