mango

command module
v0.0.0-...-55b3440 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: MIT Imports: 16 Imported by: 0

README

mango

GoDoc  Go Report Card 

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.

Documentation

Overview

mango - generate manual pages from Go source code

Description:

mango generates manual pages from the source code of Go commands. It aims to generate full-fledged manual pages soley based on the comments and flag function calls found inside Go source code.

See Also:

man(1), man-pages(7)

Jump to

Keyboard shortcuts

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