golazy.dev golazy.dev / lazydoc Index | Files

package lazydoc

import "golazy.dev/lazydoc"

Package lazydoc extracts, stores, loads, and searches Go package documentation for the GoLazy website and documentation tools.

It reads source directories with the standard go/doc and go/parser packages and converts package comments, declarations, methods, values, and examples into JSON-friendly models. The website can then load the generated index and present package pages without parsing source code at request time.

Applications normally do not need lazydoc. Use it when building documentation surfaces for GoLazy packages or for another module that wants the same lightweight package index model.

Types

type Example

type Example struct {
	Name	string	`json:"name"`
	Suffix	string	`json:"suffix,omitempty"`
	Doc	string	`json:"doc,omitempty"`
	Code	string	`json:"code"`
	Output	string	`json:"output,omitempty"`
}

type Func

type Func struct {
	Name		string		`json:"name"`
	Doc		string		`json:"doc"`
	Decl		string		`json:"decl"`
	Examples	[]Example	`json:"examples,omitempty"`
}

type Package

type Package struct {
	ImportPath	string		`json:"import_path"`
	Name		string		`json:"name"`
	Synopsis	string		`json:"synopsis"`
	Doc		string		`json:"doc"`
	Constants	[]Value		`json:"constants,omitempty"`
	Variables	[]Value		`json:"variables,omitempty"`
	Functions	[]Func		`json:"functions,omitempty"`
	Types		[]Type		`json:"types,omitempty"`
	Examples	[]Example	`json:"examples,omitempty"`
}
func LoadPackagesFromDir
func LoadPackagesFromDir(dir, modulePath string) ([]Package, error)
func (p Package) Slug
func (p Package) Slug() string
func (p Package) Symbol
func (p Package) Symbol(name string) (kind string, title string, doc string, decl string, ok bool)

type Type

type Type struct {
	Name		string		`json:"name"`
	Doc		string		`json:"doc"`
	Decl		string		`json:"decl"`
	Constants	[]Value		`json:"constants,omitempty"`
	Variables	[]Value		`json:"variables,omitempty"`
	Funcs		[]Func		`json:"functions,omitempty"`
	Methods		[]Func		`json:"methods,omitempty"`
	Examples	[]Example	`json:"examples,omitempty"`
}

type Value

type Value struct {
	Names	[]string	`json:"names"`
	Doc	string		`json:"doc"`
	Decl	string		`json:"decl"`
}