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.
Run go generate golang.org/x/tools/godoc/static so static/static.go picks up the change. Run go install golang.org/x/tools/cmd/godoc so the compiled godoc binary picks up the change. Run godoc -http=:6060 and view your changes in the browser. You may need to disable your browser's cache to avoid reloading a stale file.
Running a Godoc Server Once you have commented your code, you can run the godoc command in your terminal, from your project's code directory. The command above hosts your code documentation on localhost, or 127.0. 0.1. The port doesn't have to 6060; godoc will run on any unoccupied port.
Overview. Godoc extracts and generates documentation for Go programs. It runs as a web server and presents the documentation as a web page.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With