const punchedCardWidth … const indent … type Package … func (pkg *Package) ToText(w io.Writer, text, prefix, codePrefix string) { … } type pkgBuffer … func (pb *pkgBuffer) Write(p []byte) (int, error) { … } func (pb *pkgBuffer) packageClause() { … } type PackageError … func (p PackageError) Error() string { … } // prettyPath returns a version of the package path that is suitable for an // error message. It obeys the import comment if present. Also, since // pkg.build.ImportPath is sometimes the unhelpful "" or ".", it looks for a // directory name in GOROOT or GOPATH if that happens. func (pkg *Package) prettyPath() string { … } // trim trims the directory prefix from the path, paying attention // to the path separator. If they are the same string or the prefix // is not present the original is returned. The boolean reports whether // the prefix is present. That path and prefix have slashes for separators. func trim(path, prefix string) (string, bool) { … } // pkg.Fatalf is like log.Fatalf, but panics so it can be recovered in the // main do function, so it doesn't cause an exit. Allows testing to work // without running a subprocess. The log prefix will be added when // logged in main; it is not added here. func (pkg *Package) Fatalf(format string, args ...any) { … } // parsePackage turns the build package we found into a parsed package // we can then use to generate documentation. func parsePackage(writer io.Writer, pkg *build.Package, userPath string) *Package { … } func (pkg *Package) Printf(format string, args ...any) { … } func (pkg *Package) flush() { … } var newlineBytes … // newlines guarantees there are n newlines at the end of the buffer. func (pkg *Package) newlines(n int) { … } // emit prints the node. If showSrc is true, it ignores the provided comment, // assuming the comment is in the node itself. Otherwise, the go/doc package // clears the stuff we don't want to print anyway. It's a bit of a magic trick. func (pkg *Package) emit(comment string, node ast.Node) { … } // oneLineNode returns a one-line summary of the given input node. func (pkg *Package) oneLineNode(node ast.Node) string { … } // oneLineNodeDepth returns a one-line summary of the given input node. // The depth specifies the maximum depth when traversing the AST. func (pkg *Package) oneLineNodeDepth(node ast.Node, depth int) string { … } func (pkg *Package) formatTypeParams(list *ast.FieldList, depth int) string { … } // oneLineField returns a one-line summary of the field. func (pkg *Package) oneLineField(field *ast.Field, depth int) string { … } // joinStrings formats the input as a comma-separated list, // but truncates the list at some reasonable length if necessary. func joinStrings(ss []string) string { … } // printHeader prints a header for the section named s, adding a blank line on each side. func (pkg *Package) printHeader(s string) { … } // constsDoc prints all const documentation, if any, including a header. // The one argument is the valueDoc registry. func (pkg *Package) constsDoc(printed map[*ast.GenDecl]bool) { … } // varsDoc prints all var documentation, if any, including a header. // Printed is the valueDoc registry. func (pkg *Package) varsDoc(printed map[*ast.GenDecl]bool) { … } // funcsDoc prints all func documentation, if any, including a header. func (pkg *Package) funcsDoc() { … } // funcsDoc prints all type documentation, if any, including a header. func (pkg *Package) typesDoc() { … } // packageDoc prints the docs for the package. func (pkg *Package) packageDoc() { … } // packageClause prints the package clause. func (pkg *Package) packageClause() { … } // valueSummary prints a one-line summary for each set of values and constants. // If all the types in a constant or variable declaration belong to the same // type they can be printed by typeSummary, and so can be suppressed here. func (pkg *Package) valueSummary(values []*doc.Value, showGrouped bool) { … } // funcSummary prints a one-line summary for each function. Constructors // are printed by typeSummary, below, and so can be suppressed here. func (pkg *Package) funcSummary(funcs []*doc.Func, showConstructors bool) { … } // typeSummary prints a one-line summary for each type, followed by its constructors. func (pkg *Package) typeSummary() { … } // bugs prints the BUGS information for the package. // TODO: Provide access to TODOs and NOTEs as well (very noisy so off by default)? func (pkg *Package) bugs() { … } // findValues finds the doc.Values that describe the symbol. func (pkg *Package) findValues(symbol string, docValues []*doc.Value) (values []*doc.Value) { … } // findFuncs finds the doc.Funcs that describes the symbol. func (pkg *Package) findFuncs(symbol string) (funcs []*doc.Func) { … } // findTypes finds the doc.Types that describes the symbol. // If symbol is empty, it finds all exported types. func (pkg *Package) findTypes(symbol string) (types []*doc.Type) { … } // findTypeSpec returns the ast.TypeSpec within the declaration that defines the symbol. // The name must match exactly. func (pkg *Package) findTypeSpec(decl *ast.GenDecl, symbol string) *ast.TypeSpec { … } // symbolDoc prints the docs for symbol. There may be multiple matches. // If symbol matches a type, output includes its methods factories and associated constants. // If there is no top-level symbol, symbolDoc looks for methods that match. func (pkg *Package) symbolDoc(symbol string) bool { … } // valueDoc prints the docs for a constant or variable. The printed map records // which values have been printed already to avoid duplication. Otherwise, a // declaration like: // // const ( c = 1; C = 2 ) // // … could be printed twice if the -u flag is set, as it matches twice. func (pkg *Package) valueDoc(value *doc.Value, printed map[*ast.GenDecl]bool) { … } // typeDoc prints the docs for a type, including constructors and other items // related to it. func (pkg *Package) typeDoc(typ *doc.Type) { … } // trimUnexportedElems modifies spec in place to elide unexported fields from // structs and methods from interfaces (unless the unexported flag is set or we // are asked to show the original source). func trimUnexportedElems(spec *ast.TypeSpec) { … } // trimUnexportedFields returns the field list trimmed of unexported fields. func trimUnexportedFields(fields *ast.FieldList, isInterface bool) *ast.FieldList { … } // printMethodDoc prints the docs for matches of symbol.method. // If symbol is empty, it prints all methods for any concrete type // that match the name. It reports whether it found any methods. func (pkg *Package) printMethodDoc(symbol, method string) bool { … } // printFieldDoc prints the docs for matches of symbol.fieldName. // It reports whether it found any field. // Both symbol and fieldName must be non-empty or it returns false. func (pkg *Package) printFieldDoc(symbol, fieldName string) bool { … } // match reports whether the user's symbol matches the program's. // A lower-case character in the user's string matches either case in the program's. // The program string must be exported. func match(user, program string) bool { … } // simpleFold returns the minimum rune equivalent to r // under Unicode-defined simple case folding. func simpleFold(r rune) rune { … }