URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [go/] [doc/] [doc.go] - Rev 747
Compare with Previous | Blame | View Log
// Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.// Package doc extracts source code documentation from a Go AST.package docimport ("go/ast""go/token")// Package is the documentation for an entire package.type Package struct {Doc stringName stringImportPath stringImports []stringFilenames []stringBugs []string// declarationsConsts []*ValueTypes []*TypeVars []*ValueFuncs []*Func}// Value is the documentation for a (possibly grouped) var or const declaration.type Value struct {Doc stringNames []string // var or const names in declaration orderDecl *ast.GenDeclorder int}// Type is the documentation for a type declaration.type Type struct {Doc stringName stringDecl *ast.GenDecl// associated declarationsConsts []*Value // sorted list of constants of (mostly) this typeVars []*Value // sorted list of variables of (mostly) this typeFuncs []*Func // sorted list of functions returning this typeMethods []*Func // sorted list of methods (including embedded ones) of this type}// Func is the documentation for a func declaration.type Func struct {Doc stringName stringDecl *ast.FuncDecl// methods// (for functions, these fields have the respective zero value)Recv string // actual receiver "T" or "*T"Orig string // original receiver "T" or "*T"Level int // embedding level; 0 means not embedded}// Mode values control the operation of New.type Mode intconst (// extract documentation for all package-level declarations,// not just exported onesAllDecls Mode = 1 << iota// show all embedded methods, not just the ones of// invisible (unexported) anonymous fieldsAllMethods)// New computes the package documentation for the given package AST.// New takes ownership of the AST pkg and may edit or overwrite it.//func New(pkg *ast.Package, importPath string, mode Mode) *Package {var r readerr.readPackage(pkg, mode)r.computeMethodSets()r.cleanupTypes()return &Package{Doc: r.doc,Name: pkg.Name,ImportPath: importPath,Imports: sortedKeys(r.imports),Filenames: r.filenames,Bugs: r.bugs,Consts: sortedValues(r.values, token.CONST),Types: sortedTypes(r.types, mode&AllMethods != 0),Vars: sortedValues(r.values, token.VAR),Funcs: sortedFuncs(r.funcs, true),}}
