38 lines
727 B
Go
Raw Normal View History

2019-11-18 14:55:12 +09:00
package api
2017-07-01 14:03:10 +02:00
import (
2018-04-12 23:05:24 +02:00
"path"
2017-07-01 14:03:10 +02:00
"sort"
"github.com/aerogo/aero"
2019-04-23 14:52:55 +09:00
"github.com/akyoto/color"
2019-06-03 18:32:43 +09:00
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/arn/autodocs"
2017-07-01 14:03:10 +02:00
"github.com/animenotifier/notify.moe/components"
)
// Get api page.
2019-06-01 13:55:49 +09:00
func Get(ctx aero.Context) error {
2018-04-12 23:05:24 +02:00
types := []*autodocs.Type{}
2017-07-01 14:03:10 +02:00
for typeName := range arn.DB.Types() {
2018-04-12 23:05:24 +02:00
if typeName == "Session" {
continue
}
2019-06-03 18:32:43 +09:00
typ, err := autodocs.GetTypeDocumentation(typeName, path.Join(arn.Root, "arn", typeName+".go"))
2018-04-12 23:05:24 +02:00
types = append(types, typ)
if err != nil {
color.Red(err.Error())
continue
}
2017-07-01 14:03:10 +02:00
}
2018-04-12 23:05:24 +02:00
sort.Slice(types, func(i, j int) bool {
return types[i].Name < types[j].Name
})
2017-07-01 14:03:10 +02:00
return ctx.HTML(components.API(types))
}