vanitydoc command

go install

vanitydoc generates go documentation as a static site (HTML and Gemtext). When served under the import path URL, it makes the package importable by the Go tools ("vanity import path").

For instance the import path for this command is and the documentation is hosted at the following URL:


vanitydoc [flags] <path>
# or using go run:     go run [flags] <path>
# or using nix flakes: nix run git+ [flags] <path>

If the <path> argument points to a folder (or is omitted), a local HTTP server will be started to render the documentation on demand of the given folder (or the current folder), taking into account the following flags:

-addr string
	listen address to expose the documentation (default "localhost:8080")
-html.template.pattern string
	Pattern for additional HTML templates
-html.template.root string
	Root folder of the additional HTML templates (default ".")
-modulePath string
	Module path (will be read from <path>/go.mod if empty)

If the <path> argument points to a file (or "-" for stdin), the file is read as JSON, the configured modules are downloaded and their documentation generated.

Example to generate this documentation

The path to the JSON file containing the configuration should be given as argument to the executable. See the README for configuration reference.

	"defaults": { // allows to specify defaults for all "modules" below
		// forgejo, gitsrht, hgsrht and github are supported
		"type": "forgejo",

		// the module name will be appended to construct the forge url
		"url_prefix": "",
		"default_branch": "main"

	"modules": {
		"vanitydoc": {}, // use all defaults for the module hosted at "{url_prefix}/vanitydoc"
		"risefront": {
			"ref": "v1.0.0" // specify the ref to retrieve for this module
		"fluhus/godoc-tricks": {
			"type": "github",
			"url": "",
			"default_branch": "master",
			"ref": "master",

			// github tweak to download the archive of a branch
			// (use "tags/" when "ref" is a tag)
			"archive_ref_prefix": "heads/"
		"exp": {
			"type": "gitsrht",
			"url": ""

	"html": {
		"output": "dist/http",

		// you can add your templates to customize the HTML
		"template.pattern": "header.gohtml",
		"first_clone_url_info_refs_path": "info/refs.redirect"
	"gemtext": {
		"output": "dist/gmi"

	"max_conns_per_host": 3 // be nice with the forge when downloading module archives

License and credits

Code is available under the BSD-3-Clause license.

Most of the templates originate from gddo (available under BSD-3-Clause). The CSS styling is achieved using simple.css by default (available under MIT). go-import meta tag as well as the meta tags proposed by the VCS Autodiscovery RFC are included in the HTML output.

Source Files

http.go ideas.go json.go main.go


Path Synopsis
autodiscovery package autodiscovery is an implementation of the [VCS Autodiscovery RFC].
template package template generates documentation for a given package.


git clone