mango
Generate manual pages from the source code of your Go commands
mango
is a small command line utility that allows you to create manual pages
from the source code of your Go commands. It builds manual pages from the
comments and flag function calls found in your .go files.
mango
starts as a fork of vanilla mango by
slyrz. Main evolutions are:
- detect bound variables for flag.XxX and flag.XxXVar declaration form
- opinionated refactor of the code
Installing
go get github.com/pirmd/mango
go install github.com/pirmd/mango
Running
Pass path to your application package as a command line argument to mango
.
mango path_to_package
You can as well access the complete mango
manpage:
man -l mango.1
Usage
Several examples are to be found in ./testdata/
, you might also have a look
at mango.go
source code directly.
Source File
// example - shows the basic usage of mango
//
// Description:
//
// It doesn't take much to create manual pages with mango. Just write down
// stuff you want to include in the manual page in a comment at the top
// of your source file like this. Feel free to add as many sections as you
// want.
package main
import (
"flag"
)
var (
optFoo = flag.Bool("foo", false, "This text should show up in the manual page.")
// If the flag declaration follows a comment like this, mango displays the
// comment as description in the manual page.
optBar = flag.Bool("bar", false, "The above comment should show up in the manual page.")
optBaz = ""
)
func init() {
// These two calls reference the same variable and will appear
// grouped in the manual page. Since these aren't boolean flags, mango
// prints the argument type as well.
flag.StringVar(&optBaz, "baz", "", "Two calls, but one entry in the manual.")
flag.StringVar(&optBaz, "b", "", "Two calls, but one entry in the manual.")
}
func main() {
return
}
Result
License
mango is released under MIT license.
You can find a copy of the MIT License in the LICENSE file.