Documentation ¶
Overview ¶
Package doc extracts source code documentation from a Go AST.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var IllegalPrefixes = []string{
"copyright",
"all rights",
"author",
}
Functions ¶
func Synopsis ¶
Synopsis returns a cleaned version of the first sentence in s. That sentence ends after the first period followed by space and not preceded by exactly one uppercase letter. The result string has no \n, \r, or \t characters and uses only single spaces between words. If s starts with any of the IllegalPrefixes, the result is the empty string.
func ToHTML ¶
ToHTML converts comment text to formatted HTML. The comment was prepared by DocReader, so it is known not to have leading, trailing blank lines nor to have trailing spaces at the end of lines. The comment markers have already been removed.
Turn each run of multiple \n into </p><p>. Turn each run of indented lines into a <pre> block without indent. Enclose headings with header tags.
URLs in the comment text are converted into links; if the URL also appears in the words map, the link is taken from the map (if the corresponding map value is the empty string, the URL is not converted into a link).
Go identifiers that appear in the words map are italicized; if the corresponding map value is not the empty string, it is considered a URL and the word is converted into a link.
Types ¶
type Example ¶
type Func ¶
type Func struct { Doc string Name string Decl *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 }
Func is the documentation for a func declaration.
type Package ¶
type Package struct { Doc string Name string ImportPath string Imports []string Filenames []string Bugs []string // declarations Consts []*Value Types []*Type Vars []*Value Funcs []*Func }
Package is the documentation for an entire package.
type Type ¶
type Type struct { Doc string Name string Decl *ast.GenDecl // associated declarations Consts []*Value // sorted list of constants of (mostly) this type Vars []*Value // sorted list of variables of (mostly) this type Funcs []*Func // sorted list of functions returning this type Methods []*Func // sorted list of methods (including embedded ones) of this type }
Type is the documentation for a type declaration.