astview

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: BSD-3-Clause Imports: 15 Imported by: 3

Documentation

Overview

Package doc extracts source code documentation from a Go AST.

Index

Constants

This section is empty.

Variables

View Source
var AllFiles []string
View Source
var Command = &command.Command{
	Run:       runAstView,
	UsageLine: "astview [-stdin] files...",
	Short:     "print go files astview",
	Long:      `print go files astview`,
}

Functions

func ParseFiles

func ParseFiles(fset *token.FileSet, filenames []string, mode parser.Mode) (pkgs map[string]*ast.Package, pkgsfiles []string, first error)

func PrintFileOutline added in v1.5.0

func PrintFileOutline(filename string, w io.Writer, sep string, showexpr bool) error

level,tag,pos@info

func PrintFilesTree

func PrintFilesTree(filenames []string, w io.Writer, expr bool) error

Types

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 PackageDoc

type PackageDoc struct {
	PackageName string
	ImportPath  string
	Imports     []string
	Filenames   []string
	Doc         string
	Consts      []*ValueDoc
	Types       []*TypeDoc
	Vars        []*ValueDoc
	Funcs       []*FuncDoc
	Factorys    []*FuncDoc
	Todos       []*TodoDoc
	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 PackageView

type PackageView struct {
	// contains filtered or unexported fields
}

func NewFilePackage

func NewFilePackage(filename string) (*PackageView, error)

func NewFilePackageSource

func NewFilePackageSource(filename string, f io.Reader, expr bool) (*PackageView, error)

func NewPackageView

func NewPackageView(pkg *ast.Package, fset *token.FileSet, expr bool) (*PackageView, error)

func (*PackageView) PrintFuncs

func (p *PackageView) PrintFuncs(w io.Writer, level int, tag_folder string)

func (*PackageView) PrintHeader

func (p *PackageView) PrintHeader(w io.Writer, level int)

func (*PackageView) PrintImports

func (p *PackageView) PrintImports(w io.Writer, level int, tag, tag_folder string)

func (*PackageView) PrintPackage

func (p *PackageView) PrintPackage(w io.Writer, level int)

func (*PackageView) PrintTodos

func (p *PackageView) PrintTodos(w io.Writer, level int, tag, tag_folder string)

func (*PackageView) PrintTree

func (p *PackageView) PrintTree(w io.Writer)

level,tag,pos@info

func (*PackageView) PrintTypeFields

func (p *PackageView) PrintTypeFields(w io.Writer, decl *ast.GenDecl, level int)

func (*PackageView) PrintTypes

func (p *PackageView) PrintTypes(w io.Writer, types []*TypeDoc, level int)

func (*PackageView) PrintVars

func (p *PackageView) PrintVars(w io.Writer, vars []*ValueDoc, level int, tag string, tag_folder string)

type TodoDoc

type TodoDoc struct {
	Tag      string
	Text     string
	Comments *ast.CommentGroup
}

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