vanitydoc command

go install

vanitydoc generates go documentation as a static site (HTML and Gemtext). When hosted at the package 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] | <jsonPath> }
# or using go run:     go run { [flags] | <jsonPath> }
# or using nix flakes: nix run git+ { [flags] | <jsonPath> }

If no jsonPath argument is provided, a local HTTP server will be started to render the documentation on demand, 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 ".")
-moduleDir string
	Local path to the module to generate the documentation for (default ".")
-modulePath string
	Module path (will be read from go.mod if empty)

If a jsonPath argument is provided, the given modules will be downloaded and their documentation generated.

Example to generate this documentation

  "domain": "",

  "defaults": { // allows to specify defaults for all "modules" below
    "type": "forgejo", // forgejo, gitsrht and github are supported
    "url_prefix": "", // the module name will be appended
    "default_branch": "main"
  "max_conns_per_host": 3,

  "modules": {
    "vanitydoc": {}, // use all defaults
    "devf": {},
    "fluhus/godoc-tricks": {
      "type": "github",
      "url": "",
      "default_branch": "master",
      "archive_ref": "heads/master" // github tweak to download the archive of a branch
    "exp": {
      "type": "gitsrht",
      "url": ""

  "html": {
    "output": "dist/http",
    "template.pattern": "header.gohtml",
    "template.root": ".",
    "first_clone_url_info_refs_path": "info/refs.redirect"
  "gemtext": {
    "output": "dist/gmi"

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). It includes the go-import meta tag as well as the meta tags proposed by the VCS Autodiscovery RFC


Source Files

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


Path Synopsis
autodiscovery package autodiscovery is an implementation of the [VCS Autodiscovery RFC].
pkg package pkg computes and generate documentation for a given package.


git clone