github.com/ader1990/go@v0.0.0-20140630135419-8c24447fa791/src/cmd/godoc/doc.go (about)

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  /*
     6  
     7  Godoc extracts and generates documentation for Go programs.
     8  
     9  It has two modes.
    10  
    11  Without the -http flag, it runs in command-line mode and prints plain text
    12  documentation to standard output and exits. If both a library package and
    13  a command with the same name exists, using the prefix cmd/ will force
    14  documentation on the command rather than the library package. If the -src
    15  flag is specified, godoc prints the exported interface of a package in Go
    16  source form, or the implementation of a specific exported language entity:
    17  
    18  	godoc fmt                # documentation for package fmt
    19  	godoc fmt Printf         # documentation for fmt.Printf
    20  	godoc cmd/go             # force documentation for the go command
    21  	godoc -src fmt           # fmt package interface in Go source form
    22  	godoc -src fmt Printf    # implementation of fmt.Printf
    23  
    24  In command-line mode, the -q flag enables search queries against a godoc running
    25  as a webserver. If no explicit server address is specified with the -server flag,
    26  godoc first tries localhost:6060 and then http://golang.org.
    27  
    28  	godoc -q Reader
    29  	godoc -q math.Sin
    30  	godoc -server=:6060 -q sin
    31  
    32  With the -http flag, it runs as a web server and presents the documentation as a
    33  web page.
    34  
    35  	godoc -http=:6060
    36  
    37  Usage:
    38  	godoc [flag] package [name ...]
    39  
    40  The flags are:
    41  	-v
    42  		verbose mode
    43  	-q
    44  		arguments are considered search queries: a legal query is a
    45  		single identifier (such as ToLower) or a qualified identifier
    46  		(such as math.Sin)
    47  	-src
    48  		print (exported) source in command-line mode
    49  	-tabwidth=4
    50  		width of tabs in units of spaces
    51  	-timestamps=true
    52  		show timestamps with directory listings
    53  	-index
    54  		enable identifier and full text search index
    55  		(no search box is shown if -index is not set)
    56  	-index_files=""
    57  		glob pattern specifying index files; if not empty,
    58  		the index is read from these files in sorted order
    59  	-index_throttle=0.75
    60  		index throttle value; a value of 0 means no time is allocated
    61  		to the indexer (the indexer will never finish), a value of 1.0
    62  		means that index creation is running at full throttle (other
    63  		goroutines may get no time while the index is built)
    64  	-links=true:
    65  		link identifiers to their declarations
    66  	-write_index=false
    67  		write index to a file; the file name must be specified with
    68  		-index_files
    69  	-maxresults=10000
    70  		maximum number of full text search results shown
    71  		(no full text index is built if maxresults <= 0)
    72  	-notes="BUG"
    73  		regular expression matching note markers to show
    74  		(e.g., "BUG|TODO", ".*")
    75  	-html
    76  		print HTML in command-line mode
    77  	-goroot=$GOROOT
    78  		Go root directory
    79  	-http=addr
    80  		HTTP service address (e.g., '127.0.0.1:6060' or just ':6060')
    81  	-server=addr
    82  		webserver address for command line searches
    83  	-analysis=type,pointer
    84  		comma-separated list of analyses to perform
    85      		"type": display identifier resolution, type info, method sets,
    86  			'implements', and static callees
    87  		"pointer" display channel peers, callers and dynamic callees
    88  			(significantly slower)
    89  		See http://golang.org/lib/godoc/analysis/help.html for details.
    90  	-templates=""
    91  		directory containing alternate template files; if set,
    92  		the directory may provide alternative template files
    93  		for the files in $GOROOT/lib/godoc
    94  	-url=path
    95  		print to standard output the data that would be served by
    96  		an HTTP request for path
    97  	-zip=""
    98  		zip file providing the file system to serve; disabled if empty
    99  
   100  By default, godoc looks at the packages it finds via $GOROOT and $GOPATH (if set).
   101  This behavior can be altered by providing an alternative $GOROOT with the -goroot
   102  flag.
   103  
   104  When godoc runs as a web server and -index is set, a search index is maintained.
   105  The index is created at startup.
   106  
   107  The index contains both identifier and full text search information (searchable
   108  via regular expressions). The maximum number of full text search results shown
   109  can be set with the -maxresults flag; if set to 0, no full text results are
   110  shown, and only an identifier index but no full text search index is created.
   111  
   112  The presentation mode of web pages served by godoc can be controlled with the
   113  "m" URL parameter; it accepts a comma-separated list of flag names as value:
   114  
   115  	all	show documentation for all declarations, not just the exported ones
   116  	methods	show all embedded methods, not just those of unexported anonymous fields
   117  	src	show the original source code rather then the extracted documentation
   118  	text	present the page in textual (command-line) form rather than HTML
   119  	flat	present flat (not indented) directory listings using full paths
   120  
   121  For instance, http://golang.org/pkg/math/big/?m=all,text shows the documentation
   122  for all (not just the exported) declarations of package big, in textual form (as
   123  it would appear when using godoc from the command line: "godoc -src math/big .*").
   124  
   125  By default, godoc serves files from the file system of the underlying OS.
   126  Instead, a .zip file may be provided via the -zip flag, which contains
   127  the file system to serve. The file paths stored in the .zip file must use
   128  slash ('/') as path separator; and they must be unrooted. $GOROOT (or -goroot)
   129  must be set to the .zip file directory path containing the Go root directory.
   130  For instance, for a .zip file created by the command:
   131  
   132  	zip go.zip $HOME/go
   133  
   134  one may run godoc as follows:
   135  
   136  	godoc -http=:6060 -zip=go.zip -goroot=$HOME/go
   137  
   138  Godoc documentation is converted to HTML or to text using the go/doc package;
   139  see http://golang.org/pkg/go/doc/#ToHTML for the exact rules.
   140  See "Godoc: documenting Go code" for how to write good comments for godoc:
   141  http://golang.org/doc/articles/godoc_documenting_go_code.html
   142  
   143  */
   144  package documentation