golazy.dev
–
golazy.dev
/
lazydoc
Index
|
Files
package lazydoc ¶
import "golazy.dev/lazydoc"
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"`
Source *Source `json:"source,omitempty"`
Examples []Example `json:"examples,omitempty"`
}
type Index ¶
type Index struct {
Versions []Version `json:"versions"`
}
func LoadDir ¶
func LoadDir(dir, version string) (*Index, error)
func LoadJSON ¶
func LoadJSON(root fs.FS, file string) (*Index, error)
func LoadJSONBytes ¶
func LoadJSONBytes(data []byte) (*Index, error)
func (i *Index) Latest ¶
func (i *Index) Latest() (*Version, bool)
func (i *Index) Search ¶
func (i *Index) Search(version, query string) []SearchResult
func (i *Index) Version ¶
func (i *Index) Version(value string) (*Version, bool)
type Package ¶
type Package struct {
ImportPath string `json:"import_path"`
Name string `json:"name"`
Synopsis string `json:"synopsis"`
Doc string `json:"doc"`
Source *Source `json:"source,omitempty"`
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 SearchResult ¶
type SearchResult struct {
Version string
PackagePath string
PackageName string
Kind string
Name string
URL string
Summary string
}
type Source ¶
type Source struct {
File string `json:"file"`
Line int `json:"line"`
}
type Type ¶
type Type struct {
Name string `json:"name"`
Doc string `json:"doc"`
Decl string `json:"decl"`
Source *Source `json:"source,omitempty"`
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"`
Source *Source `json:"source,omitempty"`
}
type Version ¶
type Version struct {
Version string `json:"version"`
Module string `json:"module"`
Packages []Package `json:"packages"`
}
func (v *Version) Package ¶
func (v *Version) Package(pathValue string) (*Package, bool)
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.