Documentation ¶
Overview ¶
Package docgen generates the Chi routes documentation in JSON or Markdown.
Index ¶
- func BaseTemplate() string
- func BassCSS() string
- func Div(text string) string
- func FaviconIcoData() string
- func Head(level int, text string) string
- func JSONRoutesDoc(r chi.Routes) string
- func ListItem(text string) string
- func MarkdownRoutesDoc(r chi.Router, opts MarkdownOpts) string
- func MarkupRoutesDoc(r chi.Router, opts MarkupOpts) string
- func MilligramMinCSS() string
- func OrderedList(listItems string) string
- func P(text string) string
- func PrintRoutes(r chi.Routes)
- func UnorderedList(listItems string) string
- type Doc
- type DocHandler
- type DocHandlers
- type DocMiddleware
- type DocRoute
- type DocRouter
- type DocRoutes
- type FuncInfo
- type MarkdownDoc
- type MarkdownOpts
- type MarkupDoc
- type MarkupOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BaseTemplate ¶ added in v1.2.2
func BaseTemplate() string
BaseTemplate is a basic html page with placeholders for: {title}, {css}, {intro}, and {routes}.
func FaviconIcoData ¶ added in v1.2.2
func FaviconIcoData() string
FaviconIcoData contains image data converted with https://www.motobit.com/util/base64/image-to-base64/
func JSONRoutesDoc ¶
func JSONRoutesDoc(r chi.Routes) string
func MarkdownRoutesDoc ¶
func MarkdownRoutesDoc(r chi.Router, opts MarkdownOpts) string
func MarkupRoutesDoc ¶ added in v1.2.2
func MarkupRoutesDoc(r chi.Router, opts MarkupOpts) string
MarkupRoutesDoc builds a document based on routes in a given router with given option set.
func MilligramMinCSS ¶ added in v1.2.2
func MilligramMinCSS() string
MilligramMinCSS is a tiny CSS kit, minimized and stringified here.
func OrderedList ¶ added in v1.2.2
OrderedList is a numbered list.
func PrintRoutes ¶
func PrintRoutes(r chi.Routes)
func UnorderedList ¶ added in v1.2.2
UnorderedList is a list using bullet points instead of numbers.
Types ¶
type DocHandler ¶
type DocHandler struct { Middlewares []DocMiddleware `json:"middlewares"` Method string `json:"method"` FuncInfo }
type DocHandlers ¶
type DocHandlers map[string]DocHandler // Method : DocHandler
type DocMiddleware ¶
type DocMiddleware struct {
FuncInfo
}
type DocRoute ¶
type DocRoute struct { Pattern string `json:"-"` Handlers DocHandlers `json:"handlers,omitempty"` Router *DocRouter `json:"router,omitempty"` }
type DocRouter ¶
type DocRouter struct { Middlewares []DocMiddleware `json:"middlewares"` Routes DocRoutes `json:"routes"` }
type FuncInfo ¶
type FuncInfo struct { Pkg string `json:"pkg"` Func string `json:"func"` Comment string `json:"comment"` File string `json:"file,omitempty"` Line int `json:"line,omitempty"` Anonymous bool `json:"anonymous,omitempty"` Unresolvable bool `json:"unresolvable,omitempty"` }
FuncInfo describes a function's metadata.
func GetFuncInfo ¶ added in v1.0.1
func GetFuncInfo(i interface{}) FuncInfo
GetFuncInfo returns a FuncInfo object for a given interface.
type MarkdownDoc ¶
type MarkdownDoc struct { Opts MarkdownOpts Router chi.Router Doc Doc Routes map[string]DocRouter // Pattern : DocRouter // contains filtered or unexported fields }
func (*MarkdownDoc) Generate ¶
func (md *MarkdownDoc) Generate() error
func (*MarkdownDoc) String ¶
func (md *MarkdownDoc) String() string
func (*MarkdownDoc) WriteIntro ¶
func (md *MarkdownDoc) WriteIntro()
func (*MarkdownDoc) WriteRoutes ¶
func (md *MarkdownDoc) WriteRoutes()
type MarkdownOpts ¶
type MarkdownOpts struct { // ProjectPath is the base Go import path of the project ProjectPath string // Intro text included at the top of the generated markdown file. Intro string // ForceRelativeLinks to be relative even if they're not on github ForceRelativeLinks bool // URLMap allows specifying a map of package import paths to their link sources // Used for mapping vendored dependencies to their upstream sources // For example: // map[string]string{"github.com/my/package/vendor/go-chi/chi/": "https://github.com/go-chi/chi/blob/master/"} URLMap map[string]string }
type MarkupDoc ¶ added in v1.2.2
type MarkupDoc struct { Opts MarkupOpts Router chi.Router Doc Doc Routes map[string]DocRouter // Pattern : DocRouter FormattedHTML string RouteHTML string }
MarkupDoc describes a document to be generated.
type MarkupOpts ¶ added in v1.2.2
type MarkupOpts struct { // ProjectPath is the base Go import path of the project ProjectPath string // Intro text included at the top of the generated markdown file. Intro string // RouteText contains HTML generated from Route metadata RouteText string // ForceRelativeLinks to be relative even if they're not on github ForceRelativeLinks bool // URLMap allows specifying a map of package import paths to their link sources // Used for mapping vendored dependencies to their upstream sources // For example: // map[string]string{"github.com/my/package/vendor/go-chi/chi/": "https://github.com/go-chi/chi/blob/master/"} URLMap map[string]string }
MarkupOpts describes the options for a MarkupDoc.