💾 Archived View for log.pfad.fr › 2022 › vanitydoc captured on 2024-08-18 at 17:15:01. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-02-05)
-=-=-=-=-=-=-
[Update 2024] Vanitydoc reloaded
I updated this post after updating large parts of vanitydoc (it can now serve the documentation of the current module and generate static files of multiple modules at once).
Go packages are identified by their import path. This import path usually starts with the URL where the code is hosted, but it can also be another domain that informs the go tool where the actual code can be downloaded (so-called "vanity import paths"). Using a domain you control is great because it allows for the code to be moved between software forges without any disruption for people using the package.
There are already a couple of packages able to automatically generate html with the right meta tags:
4d63.com/vangen (static html, with links to repo and doc)
code.rocketnine.space/tslocum/godoc-static (static godoc)
go.yhsif.com/vanity (redirects to pkg.go.dev)
kkn.fi/vanity (redirects to pkg.go.dev)
However I wasn't delighted with any of those solutions, so I developed my own.
The vanitydoc command has the following features:
The last point is an RFC that aims at increasing interoperability between software forges and third-party tools:
To show an example of interoperability, consider one of my other packages:
code.pfad.fr/risefront
godocs.io/code.pfad.fr/risefront
https://codeberg.org/pfad.fr/risefront
To preview the documentation of the module of the current folder, simply run `vanitydoc` (it does not rely on `go list` since March 2023):
go run code.pfad.fr/vanitydoc@latest
To generate the static files, a JSON file must be prepared. Its format is documented in the README:
Configuration documentation of vanitydoc
I am currently happy with this package and plan to use it as-is. It could be improved in multiple ways, however, I havn't found an elegant solution to the following problems yet:
Feel free to send a patch on Codeberg or by email to contribute to this package (licensed under BSD-3-Clause)!
📅 2022-12-02