Documentation
¶
Overview ¶
Package doc extracts source code documentation from a Go AST.
Index ¶
- Variables
- func FindDir(dir *Directory, pkgname string) (maxHeight int, best *DirEntry, list []DirEntry)
- func ReadFile(fs FileSystem, path string) ([]byte, error)
- type DirEntry
- type DirList
- type Directory
- type FileSystem
- type Filter
- type FuncDoc
- type GodocDir
- type Info
- type PackageDoc
- type TypeDoc
- type ValueDoc
- Bugs
Constants ¶
This section is empty.
Variables ¶
var Command = &command.Command{
Run: runDocView,
UsageLine: "docview [-mode] [-list|-find]",
Short: "golang docview util",
Long: `golang docview util`,
}
Functions ¶
Types ¶
type DirEntry ¶
type DirEntry struct {
Depth int // >= 0
Height int // = DirList.MaxHeight - Depth, > 0
Path string // includes Name, relative to DirList root
Name string
Synopsis string
}
DirEntry describes a directory entry. The Depth and Height values are useful for presenting an entry in an indented fashion.
type FileSystem ¶
type FileSystem interface {
Open(path string) (io.ReadCloser, error)
Lstat(path string) (os.FileInfo, error)
Stat(path string) (os.FileInfo, error)
ReadDir(path string) ([]os.FileInfo, error)
}
The FileSystem interface specifies the methods godoc is using to access the file system for which it serves documentation.
var OS FileSystem = osFS{}
type FuncDoc ¶
type FuncDoc struct {
Doc string
Recv ast.Expr // TODO(rsc): Would like string here
Name string
Decl *ast.FuncDecl
}
FuncDoc is the documentation for a func declaration, either a top-level function or a method function.
type GodocDir ¶
type GodocDir struct {
// contains filtered or unexported fields
}
func NewSourceDir ¶
type PackageDoc ¶
type PackageDoc struct {
PackageName string
ImportPath string
Imports []string
Filenames []string
Doc string
Consts []*ValueDoc
Types []*TypeDoc
Vars []*ValueDoc
Funcs []*FuncDoc
Bugs []string
}
PackageDoc is the documentation for an entire package.
func NewFileDoc ¶
func NewFileDoc(file *ast.File, showAll bool) *PackageDoc
func NewPackageDoc ¶
func NewPackageDoc(pkg *ast.Package, importpath string, showAll bool) *PackageDoc
func (*PackageDoc) Filter ¶
func (p *PackageDoc) Filter(f Filter)
Filter eliminates documentation for names that don't pass through the filter f. TODO: Recognize "Type.Method" as a name.
type TypeDoc ¶
type TypeDoc struct {
Doc string
Type *ast.TypeSpec
Consts []*ValueDoc
Vars []*ValueDoc
Funcs []*FuncDoc
Methods []*FuncDoc
Decl *ast.GenDecl
// contains filtered or unexported fields
}
TypeDoc is the documentation for a declared type. Consts and Vars are sorted lists of constants and variables of (mostly) that type. Factories is a sorted list of factory functions that return that type. Methods is a sorted list of method functions on that type.