gopherdoc

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2021 License: BSD-3-Clause Imports: 23 Imported by: 0

README

GopherDoc

Improved go doc with terminal syntax highlighting.

This is a modification of the original go doc command that adds terminal syntax highlighting.

preview

Uses go-colorable so colors will work on Windows as well.

Install

$ git clone https://github.com/ravener/gopherdoc
$ cd gopherdoc
$ go install

It will install into $GOPATH/bin/gopherdoc (Use go env GOPATH to find your path) hopefully that's probably in your PATH already.

Usage

Usage is the same as go doc with just a new flag available.

-style allows to change the syntax highlighting style, the style must be a valid chroma style. (e.g gopherdoc -style monokai encoding/json)

You may also set the style via GDOC_STYLE environment variable, so you can e.g set that in your .bashrc or something. The flag will still take precedence when available.

The default style is vim

License

Because I modified Go's cmd/doc I decided to release it under Go's license. See LICENSE

Documentation

Overview

Doc (usually run as go doc) accepts zero, one or two arguments.

Zero arguments:

go doc

Show the documentation for the package in the current directory.

One argument:

go doc <pkg>
go doc <sym>[.<methodOrField>]
go doc [<pkg>.]<sym>[.<methodOrField>]
go doc [<pkg>.][<sym>.]<methodOrField>

The first item in this list that succeeds is the one whose documentation is printed. If there is a symbol but no package, the package in the current directory is chosen. However, if the argument begins with a capital letter it is always assumed to be a symbol in the current directory.

Two arguments:

go doc <pkg> <sym>[.<methodOrField>]

Show the documentation for the package, symbol, and method or field. The first argument must be a full package path. This is similar to the command-line usage for the godoc command.

For commands, unless the -cmd flag is present "go doc command" shows only the package-level docs for the package.

The -src flag causes doc to print the full source code for the symbol, such as the body of a struct, function or method.

The -all flag causes doc to print all documentation for the package and all its visible symbols. The argument must identify a package.

For complete documentation, run "go help doc".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL