2013-07-16 22:02:35 -06:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Godoc extracts and generates documentation for Go programs.
|
|
|
|
|
2018-10-18 01:21:06 -06:00
|
|
|
It runs as a web server and presents the documentation as a
|
2013-07-16 22:02:35 -06:00
|
|
|
web page.
|
|
|
|
|
|
|
|
godoc -http=:6060
|
|
|
|
|
|
|
|
Usage:
|
2017-03-01 19:58:49 -07:00
|
|
|
|
2018-10-18 01:21:06 -06:00
|
|
|
godoc [flag]
|
2013-07-16 22:02:35 -06:00
|
|
|
|
|
|
|
The flags are:
|
2017-03-01 19:58:49 -07:00
|
|
|
|
2013-07-16 22:02:35 -06:00
|
|
|
-v
|
|
|
|
verbose mode
|
|
|
|
-timestamps=true
|
|
|
|
show timestamps with directory listings
|
|
|
|
-index
|
|
|
|
enable identifier and full text search index
|
|
|
|
(no search box is shown if -index is not set)
|
|
|
|
-index_files=""
|
|
|
|
glob pattern specifying index files; if not empty,
|
|
|
|
the index is read from these files in sorted order
|
|
|
|
-index_throttle=0.75
|
|
|
|
index throttle value; a value of 0 means no time is allocated
|
|
|
|
to the indexer (the indexer will never finish), a value of 1.0
|
|
|
|
means that index creation is running at full throttle (other
|
|
|
|
goroutines may get no time while the index is built)
|
2018-10-18 01:21:06 -06:00
|
|
|
-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
|
2013-07-16 22:02:35 -06:00
|
|
|
link identifiers to their declarations
|
|
|
|
-write_index=false
|
|
|
|
write index to a file; the file name must be specified with
|
|
|
|
-index_files
|
|
|
|
-maxresults=10000
|
|
|
|
maximum number of full text search results shown
|
|
|
|
(no full text index is built if maxresults <= 0)
|
|
|
|
-notes="BUG"
|
|
|
|
regular expression matching note markers to show
|
|
|
|
(e.g., "BUG|TODO", ".*")
|
|
|
|
-goroot=$GOROOT
|
|
|
|
Go root directory
|
|
|
|
-http=addr
|
|
|
|
HTTP service address (e.g., '127.0.0.1:6060' or just ':6060')
|
2014-04-16 14:35:08 -06:00
|
|
|
-analysis=type,pointer
|
|
|
|
comma-separated list of analyses to perform
|
2017-03-01 19:58:49 -07:00
|
|
|
"type": display identifier resolution, type info, method sets,
|
2014-04-16 14:35:08 -06:00
|
|
|
'implements', and static callees
|
2017-03-01 19:58:49 -07:00
|
|
|
"pointer": display channel peers, callers and dynamic callees
|
2014-04-16 14:35:08 -06:00
|
|
|
(significantly slower)
|
2018-10-18 01:21:06 -06:00
|
|
|
See https://golang.org/lib/godoc/analysis/help.html for details.
|
2013-07-16 22:02:35 -06:00
|
|
|
-templates=""
|
|
|
|
directory containing alternate template files; if set,
|
|
|
|
the directory may provide alternative template files
|
|
|
|
for the files in $GOROOT/lib/godoc
|
|
|
|
-url=path
|
|
|
|
print to standard output the data that would be served by
|
|
|
|
an HTTP request for path
|
|
|
|
-zip=""
|
|
|
|
zip file providing the file system to serve; disabled if empty
|
|
|
|
|
|
|
|
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
|
|
|
|
flag.
|
|
|
|
|
2018-10-18 01:21:06 -06:00
|
|
|
When the -index flag is set, a search index is maintained.
|
2013-07-16 22:02:35 -06:00
|
|
|
The index is created at startup.
|
|
|
|
|
|
|
|
The index contains both identifier and full text search information (searchable
|
|
|
|
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
|
|
|
|
shown, and only an identifier index but no full text search index is created.
|
|
|
|
|
2018-10-18 01:21:06 -06:00
|
|
|
By default, godoc uses the system's GOOS/GOARCH. You can provide the URL parameters
|
|
|
|
"GOOS" and "GOARCH" to set the output on the web page for the target system.
|
2014-12-11 08:10:04 -07:00
|
|
|
|
2013-07-16 22:02:35 -06:00
|
|
|
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:
|
|
|
|
|
|
|
|
all show documentation for all declarations, not just the exported ones
|
|
|
|
methods show all embedded methods, not just those of unexported anonymous fields
|
2019-02-18 12:29:27 -07:00
|
|
|
src show the original source code rather than the extracted documentation
|
|
|
|
flat present flat (not indented) directory listings using full paths
|
2013-07-16 22:02:35 -06:00
|
|
|
|
2018-10-18 01:21:06 -06:00
|
|
|
For instance, https://golang.org/pkg/math/big/?m=all shows the documentation
|
|
|
|
for all (not just the exported) declarations of package big.
|
2013-07-16 22:02:35 -06:00
|
|
|
|
|
|
|
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
|
|
|
|
the file system to serve. The file paths stored in the .zip file must use
|
|
|
|
slash ('/') as path separator; and they must be unrooted. $GOROOT (or -goroot)
|
|
|
|
must be set to the .zip file directory path containing the Go root directory.
|
|
|
|
For instance, for a .zip file created by the command:
|
|
|
|
|
2015-12-01 06:21:54 -07:00
|
|
|
zip -r go.zip $HOME/go
|
2013-07-16 22:02:35 -06:00
|
|
|
|
|
|
|
one may run godoc as follows:
|
|
|
|
|
|
|
|
godoc -http=:6060 -zip=go.zip -goroot=$HOME/go
|
|
|
|
|
2013-10-02 20:08:24 -06:00
|
|
|
Godoc documentation is converted to HTML or to text using the go/doc package;
|
2018-10-18 01:21:06 -06:00
|
|
|
see https://golang.org/pkg/go/doc/#ToHTML for the exact rules.
|
2015-01-07 16:36:07 -07:00
|
|
|
Godoc also shows example code that is runnable by the testing package;
|
2018-10-18 01:21:06 -06:00
|
|
|
see https://golang.org/pkg/testing/#hdr-Examples for the conventions.
|
2013-07-16 22:02:35 -06:00
|
|
|
See "Godoc: documenting Go code" for how to write good comments for godoc:
|
2018-10-18 01:21:06 -06:00
|
|
|
https://golang.org/doc/articles/godoc_documenting_go_code.html
|
2013-07-16 22:02:35 -06:00
|
|
|
|
|
|
|
*/
|
2014-12-08 21:00:58 -07:00
|
|
|
package main // import "golang.org/x/tools/cmd/godoc"
|