aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/doc/pkg.go
AgeCommit message (Collapse)Author
2015-07-10cmd/doc: submit to the punched card tyrannyRob Pike
People use 80-column terminals because their grandparents used punched cards. When I last used a punched card, in 1978, it seemed antiquated even then. But today, people still set their terminal widths to 80 to honor the struggles their fallen ancestors made to endure this painful technology. We must all stand and salute the 80 column flag, or risk the opprobium of our peers. For Pete's sake, I don't even use a fixed-width font. I don't even believe in columns. Fixes #11639 with extreme reluctance. P.S. To avoid the horror of an automatically folded line of text, this commit message has been formatted to fit on an 80-column line, except for this postscript. Change-Id: Ia2eb2dcf293dabe804c22ee5abb4bbb703f45c33 Reviewed-on: https://go-review.googlesource.com/12011 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-09cmd/doc: suppress symbols for commands when showing package docsRob Pike
Change the default behavior when showing the package docs for a command to elide the symbols. This makes go doc somecommand show the top-level package docs only and hide the symbols, which are probably irrelevant to the user. This has no effect on explicit requests for internals, such as go doc somecommand.sometype The new -cmd flag restores the old behavior. Fixes #10733. Change-Id: I4d363081fe7dabf76ec8e5315770ac3609592f80 Reviewed-on: https://go-review.googlesource.com/11953 Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-19cmd/doc: add testRob Pike
Refactor main a bit to make it possible to run tests without an exec every time. (Makes a huge difference in run time.) Add a silver test. Not quite golden, since it looks for pieces rather than the full output, and also includes tests for what should not appear. Fixes #10920. Change-Id: I6a4951cc14e61763379754a10b0cc3484d30c267 Reviewed-on: https://go-review.googlesource.com/11272 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Rob Pike <r@golang.org>
2015-06-04cmd/doc: do not show unexported constantsRob Pike
The go/doc package doesn't remove unexported entries from const and var blocks, so we must trim them ourselves. Fixes #11008 Change-Id: Ibd60d87e09333964e2588340a2ca2b8804bbaa28 Reviewed-on: https://go-review.googlesource.com/10643 Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-18cmd/doc: put blank lines around comment for types, etc.Rob Pike
Better layout. Fixes #10859. The issue suggests rearranging so the comment comes out after the methods. I tried this and it looks good but it is less useful, since the stuff you're probably looking for - the methods - are scrolled away by the comment. The most important information should be last because that leaves it on your screen after the print if the output is long. Change-Id: I560f992601ccbe2293c347fa1b1018a3f5346c82 Reviewed-on: https://go-review.googlesource.com/10160 Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-15cmd/doc: fix buildMikio Hara
Change-Id: Ic8437a1d2aeb424d6d5ce9e608c1293bba4c7bbc Reviewed-on: https://go-review.googlesource.com/10093 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-05-14cmd/doc: trim unexported methods from interfacesRob Pike
Fixes #10856. Change-Id: I5de65b8dd94eec3451ee0ba9c75698cdd88f5fea Reviewed-on: https://go-review.googlesource.com/10088 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-05-13cmd/doc: print BUGs after package docsRob Pike
Was otherwise absent unless bound to an exported symbol, as in the BUG with strings.Title. Fixes #10781. Change-Id: I1543137073a9dee9e546bc9d648ca54fc9632dde Reviewed-on: https://go-review.googlesource.com/9899 Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-06cmd/doc: add type-bound vars to global vars listRob Pike
Already done for constants and funcs, but I didn't realize that some global vars were also not in the global list. This fixes go doc build.Default Change-Id: I768bde13a400259df3e46dddc9f58c8f0e993c72 Reviewed-on: https://go-review.googlesource.com/9764 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-05-06cmd/doc: if no top-level symbols match, look for methodsRob Pike
Improving the usability further. Before: $ go doc bytes.Read doc: symbol Read not present in package bytes installed in "bytes" $ After: $ go doc bytes.Read func (b *Buffer) Read(p []byte) (n int, err error) Read reads the next len(p) bytes from the buffer or until the buffer is drained. The return value n is the number of bytes read. If the buffer has no data to return, err is io.EOF (unless len(p) is zero); otherwise it is nil. func (r *Reader) Read(b []byte) (n int, err error) $ Change-Id: I646511fada138bd09e9b39820da01a5ccef4a90f Reviewed-on: https://go-review.googlesource.com/9656 Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-29cmd/go: better UI for go docRob Pike
Print it out much like godoc so there isn't a single block of text. Print the symbol before its comment and indent the comment so individual symbols separate visually. Buffer the output. Add a -c option to force case-sensitive matching. Allow two arguments, like godoc, to help disambiguate cases where path and symbol may be confused. Improve the documentation printed by go help doc. Change-Id: If687aad04bbacdf7dbe4bf7636de9fe96f756fd0 Reviewed-on: https://go-review.googlesource.com/9471 Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-28cmd/doc: print documentation for all matches in a package, not just the firstRob Pike
Change-Id: Id0d4ac7169f741dfeec7b1e67bdc21e49ae37b9e Reviewed-on: https://go-review.googlesource.com/9430 Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-27cmd/go,cmd/doc: add "go doc"Rob Pike
Add the new go doc command to the go command, installed in the tool directory. (Still to do: tests) Fix cmd/dist to remove old "package documentation" code that was stopping it from including cmd/go/doc.go in the build. Implement the doc command. Here is the help info from "go help doc": === usage: go doc [-u] [package|[package.]symbol[.method]] Doc accepts at most one argument, indicating either a package, a symbol within a package, or a method of a symbol. go doc go doc <pkg> go doc <sym>[.<method>] go doc [<pkg>].<sym>[.<method>] Doc interprets the argument to see what it represents, determined by its syntax and which packages and symbols are present in the source directories of GOROOT and GOPATH. The first item in this list that succeeds is the one whose documentation is printed. For packages, the order of scanning is determined by the file system, however the GOROOT tree is always scanned before GOPATH. If there is no package specified or matched, the package in the current directory is selected, so "go doc" shows the documentation for the current package and "go doc Foo" shows the documentation for symbol Foo in the current package. Doc prints the documentation comments associated with the top-level item the argument identifies (package, type, method) followed by a one-line summary of each of the first-level items "under" that item (package-level declarations for a package, methods for a type, etc.) The package paths must be either a qualified path or a proper suffix of a path (see examples below). The go tool's usual package mechanism does not apply: package path elements like . and ... are not implemented by go doc. When matching symbols, lower-case letters match either case but upper-case letters match exactly. Examples: go doc Show documentation for current package. go doc Foo Show documentation for Foo in the current package. (Foo starts with a capital letter so it cannot match a package path.) go doc json Show documentation for the encoding/json package. go doc json Shorthand for encoding/json assuming only one json package is present in the tree. go doc json.Number (or go doc json.number) Show documentation and method summary for json.Number. go doc json.Number.Int64 (or go doc json.number.int64) Show documentation for the Int64 method of json.Number. Flags: -u Show documentation for unexported as well as exported symbols and methods. === Still to do: Tests. Disambiguation when there is both foo and Foo. Flag for case-sensitive matching. Change-Id: I83d409a68688a5445f54297a7e7c745f749b9e66 Reviewed-on: https://go-review.googlesource.com/9227 Reviewed-by: Russ Cox <rsc@golang.org>