`func \(unexportedType\)`,
},
},
+ // Package dump -short
+ {
+ "full package with -short",
+ []string{`-short`, p},
+ []string{
+ `const ExportedConstant = 1`, // Simple constant.
+ `func ReturnUnexported\(\) unexportedType`, // Function with unexported return type.
+ },
+ []string{
+ `MultiLine(String|Method|Field)`, // No data from multi line portions.
+ },
+ },
// Package dump -u
{
"full package with u",
showAll bool // -all flag
showCmd bool // -cmd flag
showSrc bool // -src flag
+ short bool // -short flag
)
// usage is a replacement usage function for the flags package.
flagSet.BoolVar(&showAll, "all", false, "show all documentation for package")
flagSet.BoolVar(&showCmd, "cmd", false, "show symbols with package docs even if package is a command")
flagSet.BoolVar(&showSrc, "src", false, "show source code for symbol")
+ flagSet.BoolVar(&short, "short", false, "one-line representation for each symbol")
flagSet.Parse(args)
var paths []string
var symbol, method string
func (pkg *Package) packageDoc() {
defer pkg.flush()
- doc.ToText(&pkg.buf, pkg.doc.Doc, "", indent, indentedWidth)
- pkg.newlines(1)
+ if !short {
+ doc.ToText(&pkg.buf, pkg.doc.Doc, "", indent, indentedWidth)
+ pkg.newlines(1)
+ }
if pkg.pkg.Name == "main" && !showCmd {
// Show only package docs for commands.
return
}
- pkg.newlines(2) // Guarantee blank line before the components.
+ if !short {
+ pkg.newlines(2) // Guarantee blank line before the components.
+ }
+
pkg.valueSummary(pkg.doc.Consts, false)
pkg.valueSummary(pkg.doc.Vars, false)
pkg.funcSummary(pkg.doc.Funcs, false)
pkg.typeSummary()
- pkg.bugs()
+ if !short {
+ pkg.bugs()
+ }
}
// packageClause prints the package clause.
func (pkg *Package) packageClause() {
+ if short {
+ return
+ }
importPath := pkg.build.ImportComment
if importPath == "" {
importPath = pkg.build.ImportPath
// Treat a command (package main) like a regular package.
// Otherwise package main's exported symbols are hidden
// when showing the package's top-level documentation.
+// -short
+// One-line representation for each symbol.
// -src
// Show the full source code for the symbol. This will
// display the full Go source of its declaration and
Treat a command (package main) like a regular package.
Otherwise package main's exported symbols are hidden
when showing the package's top-level documentation.
+ -short
+ One-line representation for each symbol.
-src
Show the full source code for the symbol. This will
display the full Go source of its declaration and