docview

package
v0.0.0-...-b76ad68 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2015 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Overview

Package doc extracts source code documentation from a Go AST.

Index

Constants

This section is empty.

Variables

View Source
var Command = &command.Command{
	Run:       runDocView,
	UsageLine: "docview [-mode] [-list|-find]",
	Short:     "golang docview util",
	Long:      `golang docview util`,
}

Functions

func FindDir

func FindDir(dir *Directory, pkgname string) (maxHeight int, best *DirEntry, list []DirEntry)

func ReadFile

func ReadFile(fs FileSystem, path string) ([]byte, error)

ReadFile reads the file named by path from fs and returns the contents.

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 DirList

type DirList struct {
	MaxHeight int // directory tree height, > 0
	List      []DirEntry
}

type Directory

type Directory struct {
	Depth int
	Path  string // includes Name
	Name  string
	Text  string       // package documentation, if any
	Dirs  []*Directory // subdirectories
}

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 Filter

type Filter func(string) bool

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

func NewSourceDir(goroot string) *GodocDir

func (*GodocDir) FindInfo

func (dir *GodocDir) FindInfo(name string) *Info

type Info

type Info struct {
	Find string
	Best *DirEntry
	Dirs *DirList
}

func FindPkgInfo

func FindPkgInfo(root string, pkgname string) *Info

func NewListInfo

func NewListInfo(root string) *Info

func (*Info) GetPkgList

func (info *Info) GetPkgList(name, templateData string) []byte

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.

type ValueDoc

type ValueDoc struct {
	Doc  string
	Decl *ast.GenDecl
	// contains filtered or unexported fields
}

ValueDoc is the documentation for a group of declared values, either vars or consts.

Notes

Bugs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL