How can I generate HTML documents using `godoc`?
GoGo Problem Overview
I have written a small go program, and I want to generate standalone HTML documents from source code that can be viewed without godoc server. But I can't find any way to achieve it. if anyone could help me, I'll appreciate it.
Go Solutions
Solution 1 - Go
A bit better form can by produced by:
godoc -url "http://localhost:6060/pkg/container/heap/" > page.html
(I have godoc server running at :6060 and I'm not sure if that's a prerequisite).
The HTML would probably look better if combined with original CSS styles found in the Go repository by adjusting the produced HTML files to properly refer to it.
Solution 2 - Go
This might not directly answer your question, but if you are planning to open source your project, you don't really have to generate HTML manually. Just make sure you have comments properly inserted in your source code, and use godoc.org( http://godoc.org/-/about ) to handle it.
It displays documentation for Go packages on Bitbucket, Github, Launchpad and Google Project Hosting.
Check this out for example: http://godoc.org/code.google.com/p/go.crypto/ssh
Solution 3 - Go
Run the server and get it with wget
godoc -http=:6060
wait for it to start up then ("container/heap/" with your app):
wget -p -k http://localhost:6060/pkg/container/heap/
To download all docs I use following:
wget -m -k -q -erobots=off --no-host-directories --no-use-server-timestamps http://localhost:6060
Solution 4 - Go
(Moved from https://stackoverflow.com/a/63905155/3715832)
If you would like to try a different docs style, you can try Golds, which is an alternate Go docs generation tool (and a local docs server / code reader).
Under your project directory, you can run any of the following commands to generate HTML docs for your Go project:
- golds -gen -nouses -plainsrc -wdpkgs-listing=promoted ./...
- golds -gen -nouses -wdpkgs-listing=promoted ./...
- golds -gen -wdpkgs-listing=promoted ./...
The first command generates the most compact docs and the last one generates the full docs, which size is 6 times of the compact docs.
BTW, I'm the author of Golds. Hope you this tool would satisfy your need.