docgen – github.com/go-chi/docgen Index | Files | Directories

package docgen

import "github.com/go-chi/docgen"

Index

Functions

func JSONRoutesDoc

func JSONRoutesDoc(r chi.Routes) string

func MarkdownRoutesDoc

func MarkdownRoutesDoc(r chi.Router, opts MarkdownOpts) string

func PrintRoutes

func PrintRoutes(r chi.Routes)

Types

type Doc

type Doc struct {
	Router DocRouter `json:"router"`
}

func BuildDoc

func BuildDoc(r chi.Routes) (Doc, error)

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 DocRoutes

type DocRoutes map[string]DocRoute // Pattern : DocRoute

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"`
}

func GetFuncInfo

func GetFuncInfo(i interface{}) FuncInfo

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
}

Source Files

builder.go docgen.go funcinfo.go markdown.go util.go

Directories

PathSynopsis
raml
Version
v1.3.0 (latest)
Published
Nov 20, 2022
Platform
js/wasm
Imports
15 packages
Last checked
6 days ago

Tools for package owners.