mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
cmd/godoc: cleanup documentation for CLI mode
- Removed all documentation which referred to godoc's CLI capabilities. - Added some missing flags which were not documented. - Removed some redundant mentions of "web server" because now it is just a web server. - Converted some links to https Change-Id: I7ddcf417d2bc3df13183adcfd0f82af9a37a1b91 Reviewed-on: https://go-review.googlesource.com/c/143077 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
06f26fdaaa
commit
def2677374
@ -6,50 +6,19 @@
|
|||||||
|
|
||||||
Godoc extracts and generates documentation for Go programs.
|
Godoc extracts and generates documentation for Go programs.
|
||||||
|
|
||||||
It has two modes.
|
It runs as a web server and presents the documentation as a
|
||||||
|
|
||||||
Without the -http flag, it runs in command-line mode and prints plain text
|
|
||||||
documentation to standard output and exits. If both a library package and
|
|
||||||
a command with the same name exists, using the prefix cmd/ will force
|
|
||||||
documentation on the command rather than the library package. If the -src
|
|
||||||
flag is specified, godoc prints the exported interface of a package in Go
|
|
||||||
source form, or the implementation of a specific exported language entity:
|
|
||||||
|
|
||||||
godoc fmt # documentation for package fmt
|
|
||||||
godoc fmt Printf # documentation for fmt.Printf
|
|
||||||
godoc cmd/go # force documentation for the go command
|
|
||||||
godoc -src fmt # fmt package interface in Go source form
|
|
||||||
godoc -src fmt Printf # implementation of fmt.Printf
|
|
||||||
|
|
||||||
In command-line mode, the -q flag enables search queries against a godoc running
|
|
||||||
as a webserver. If no explicit server address is specified with the -server flag,
|
|
||||||
godoc first tries localhost:6060 and then http://golang.org.
|
|
||||||
|
|
||||||
godoc -q Reader
|
|
||||||
godoc -q math.Sin
|
|
||||||
godoc -server=:6060 -q sin
|
|
||||||
|
|
||||||
With the -http flag, it runs as a web server and presents the documentation as a
|
|
||||||
web page.
|
web page.
|
||||||
|
|
||||||
godoc -http=:6060
|
godoc -http=:6060
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
godoc [flag] package [name ...]
|
godoc [flag]
|
||||||
|
|
||||||
The flags are:
|
The flags are:
|
||||||
|
|
||||||
-v
|
-v
|
||||||
verbose mode
|
verbose mode
|
||||||
-q
|
|
||||||
arguments are considered search queries: a legal query is a
|
|
||||||
single identifier (such as ToLower) or a qualified identifier
|
|
||||||
(such as math.Sin)
|
|
||||||
-src
|
|
||||||
print (exported) source in command-line mode
|
|
||||||
-tabwidth=4
|
|
||||||
width of tabs in units of spaces
|
|
||||||
-timestamps=true
|
-timestamps=true
|
||||||
show timestamps with directory listings
|
show timestamps with directory listings
|
||||||
-index
|
-index
|
||||||
@ -63,7 +32,12 @@ The flags are:
|
|||||||
to the indexer (the indexer will never finish), a value of 1.0
|
to the indexer (the indexer will never finish), a value of 1.0
|
||||||
means that index creation is running at full throttle (other
|
means that index creation is running at full throttle (other
|
||||||
goroutines may get no time while the index is built)
|
goroutines may get no time while the index is built)
|
||||||
-links=true:
|
-index_interval=0
|
||||||
|
interval of indexing; a value of 0 sets it to 5 minutes, a
|
||||||
|
negative value indexes only once at startup
|
||||||
|
-play=false
|
||||||
|
enable playground
|
||||||
|
-links=true
|
||||||
link identifiers to their declarations
|
link identifiers to their declarations
|
||||||
-write_index=false
|
-write_index=false
|
||||||
write index to a file; the file name must be specified with
|
write index to a file; the file name must be specified with
|
||||||
@ -74,21 +48,17 @@ The flags are:
|
|||||||
-notes="BUG"
|
-notes="BUG"
|
||||||
regular expression matching note markers to show
|
regular expression matching note markers to show
|
||||||
(e.g., "BUG|TODO", ".*")
|
(e.g., "BUG|TODO", ".*")
|
||||||
-html
|
|
||||||
print HTML in command-line mode
|
|
||||||
-goroot=$GOROOT
|
-goroot=$GOROOT
|
||||||
Go root directory
|
Go root directory
|
||||||
-http=addr
|
-http=addr
|
||||||
HTTP service address (e.g., '127.0.0.1:6060' or just ':6060')
|
HTTP service address (e.g., '127.0.0.1:6060' or just ':6060')
|
||||||
-server=addr
|
|
||||||
webserver address for command line searches
|
|
||||||
-analysis=type,pointer
|
-analysis=type,pointer
|
||||||
comma-separated list of analyses to perform
|
comma-separated list of analyses to perform
|
||||||
"type": display identifier resolution, type info, method sets,
|
"type": display identifier resolution, type info, method sets,
|
||||||
'implements', and static callees
|
'implements', and static callees
|
||||||
"pointer": display channel peers, callers and dynamic callees
|
"pointer": display channel peers, callers and dynamic callees
|
||||||
(significantly slower)
|
(significantly slower)
|
||||||
See http://golang.org/lib/godoc/analysis/help.html for details.
|
See https://golang.org/lib/godoc/analysis/help.html for details.
|
||||||
-templates=""
|
-templates=""
|
||||||
directory containing alternate template files; if set,
|
directory containing alternate template files; if set,
|
||||||
the directory may provide alternative template files
|
the directory may provide alternative template files
|
||||||
@ -103,7 +73,7 @@ By default, godoc looks at the packages it finds via $GOROOT and $GOPATH (if set
|
|||||||
This behavior can be altered by providing an alternative $GOROOT with the -goroot
|
This behavior can be altered by providing an alternative $GOROOT with the -goroot
|
||||||
flag.
|
flag.
|
||||||
|
|
||||||
When godoc runs as a web server and -index is set, a search index is maintained.
|
When the -index flag is set, a search index is maintained.
|
||||||
The index is created at startup.
|
The index is created at startup.
|
||||||
|
|
||||||
The index contains both identifier and full text search information (searchable
|
The index contains both identifier and full text search information (searchable
|
||||||
@ -111,10 +81,8 @@ via regular expressions). The maximum number of full text search results shown
|
|||||||
can be set with the -maxresults flag; if set to 0, no full text results are
|
can be set with the -maxresults flag; if set to 0, no full text results are
|
||||||
shown, and only an identifier index but no full text search index is created.
|
shown, and only an identifier index but no full text search index is created.
|
||||||
|
|
||||||
By default, godoc uses the system's GOOS/GOARCH; in command-line mode you can
|
By default, godoc uses the system's GOOS/GOARCH. You can provide the URL parameters
|
||||||
set the GOOS/GOARCH environment variables to get output for the system specified.
|
"GOOS" and "GOARCH" to set the output on the web page for the target system.
|
||||||
If -http was specified you can provide the URL parameters "GOOS" and "GOARCH"
|
|
||||||
to set the output on the web page.
|
|
||||||
|
|
||||||
The presentation mode of web pages served by godoc can be controlled with the
|
The presentation mode of web pages served by godoc can be controlled with the
|
||||||
"m" URL parameter; it accepts a comma-separated list of flag names as value:
|
"m" URL parameter; it accepts a comma-separated list of flag names as value:
|
||||||
@ -122,12 +90,9 @@ The presentation mode of web pages served by godoc can be controlled with the
|
|||||||
all show documentation for all declarations, not just the exported ones
|
all show documentation for all declarations, not just the exported ones
|
||||||
methods show all embedded methods, not just those of unexported anonymous fields
|
methods show all embedded methods, not just those of unexported anonymous fields
|
||||||
src show the original source code rather then the extracted documentation
|
src show the original source code rather then the extracted documentation
|
||||||
text present the page in textual (command-line) form rather than HTML
|
|
||||||
flat present flat (not indented) directory listings using full paths
|
|
||||||
|
|
||||||
For instance, http://golang.org/pkg/math/big/?m=all,text shows the documentation
|
For instance, https://golang.org/pkg/math/big/?m=all shows the documentation
|
||||||
for all (not just the exported) declarations of package big, in textual form (as
|
for all (not just the exported) declarations of package big.
|
||||||
it would appear when using godoc from the command line: "godoc -src math/big .*").
|
|
||||||
|
|
||||||
By default, godoc serves files from the file system of the underlying OS.
|
By default, godoc serves files from the file system of the underlying OS.
|
||||||
Instead, a .zip file may be provided via the -zip flag, which contains
|
Instead, a .zip file may be provided via the -zip flag, which contains
|
||||||
@ -143,11 +108,11 @@ one may run godoc as follows:
|
|||||||
godoc -http=:6060 -zip=go.zip -goroot=$HOME/go
|
godoc -http=:6060 -zip=go.zip -goroot=$HOME/go
|
||||||
|
|
||||||
Godoc documentation is converted to HTML or to text using the go/doc package;
|
Godoc documentation is converted to HTML or to text using the go/doc package;
|
||||||
see http://golang.org/pkg/go/doc/#ToHTML for the exact rules.
|
see https://golang.org/pkg/go/doc/#ToHTML for the exact rules.
|
||||||
Godoc also shows example code that is runnable by the testing package;
|
Godoc also shows example code that is runnable by the testing package;
|
||||||
see http://golang.org/pkg/testing/#hdr-Examples for the conventions.
|
see https://golang.org/pkg/testing/#hdr-Examples for the conventions.
|
||||||
See "Godoc: documenting Go code" for how to write good comments for godoc:
|
See "Godoc: documenting Go code" for how to write good comments for godoc:
|
||||||
http://golang.org/doc/articles/godoc_documenting_go_code.html
|
https://golang.org/doc/articles/godoc_documenting_go_code.html
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package main // import "golang.org/x/tools/cmd/godoc"
|
package main // import "golang.org/x/tools/cmd/godoc"
|
||||||
|
@ -14,14 +14,6 @@
|
|||||||
// (idea is if you say import "compress/zlib", you go to
|
// (idea is if you say import "compress/zlib", you go to
|
||||||
// http://godoc/pkg/compress/zlib)
|
// http://godoc/pkg/compress/zlib)
|
||||||
//
|
//
|
||||||
// Command-line interface:
|
|
||||||
//
|
|
||||||
// godoc packagepath [name ...]
|
|
||||||
//
|
|
||||||
// godoc compress/zlib
|
|
||||||
// - prints doc for package compress/zlib
|
|
||||||
// godoc crypto/block Cipher NewCMAC
|
|
||||||
// - prints doc for Cipher and NewCMAC in package crypto/block
|
|
||||||
|
|
||||||
// +build !golangorg
|
// +build !golangorg
|
||||||
|
|
||||||
@ -80,7 +72,7 @@ var (
|
|||||||
// layout control
|
// layout control
|
||||||
showTimestamps = flag.Bool("timestamps", false, "show timestamps with directory listings")
|
showTimestamps = flag.Bool("timestamps", false, "show timestamps with directory listings")
|
||||||
templateDir = flag.String("templates", "", "load templates/JS/CSS from disk in this directory")
|
templateDir = flag.String("templates", "", "load templates/JS/CSS from disk in this directory")
|
||||||
showPlayground = flag.Bool("play", false, "enable playground in web interface")
|
showPlayground = flag.Bool("play", false, "enable playground")
|
||||||
declLinks = flag.Bool("links", true, "link identifiers to their declarations")
|
declLinks = flag.Bool("links", true, "link identifiers to their declarations")
|
||||||
|
|
||||||
// search index
|
// search index
|
||||||
|
@ -208,6 +208,7 @@ func (h *handlerServer) GetPageInfo(abspath, relpath string, mode PageInfoMode,
|
|||||||
timestamp = ts
|
timestamp = ts
|
||||||
}
|
}
|
||||||
if dir == nil {
|
if dir == nil {
|
||||||
|
// TODO(agnivade): handle this case better, now since there is no CLI mode.
|
||||||
// no directory tree present (happens in command-line mode);
|
// no directory tree present (happens in command-line mode);
|
||||||
// compute 2 levels for this page. The second level is to
|
// compute 2 levels for this page. The second level is to
|
||||||
// get the synopses of sub-directories.
|
// get the synopses of sub-directories.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user