3

godoc -html generates documents for only one package. However, I want to ship the project with all documents for all packages, just like when I run godoc -http. With that, I could find all packages and navigate through them from the browser.

Is it possible to generate HTML pages for all packages linked together through godoc -html?

Darshan Rivka Whittle
  • 32,989
  • 7
  • 91
  • 109
Ali Dabour
  • 135
  • 1
  • 7
  • hmm, are you hosting the docs yourself? or do you expect this to stay in go doc reference? –  Mar 19 '18 at 03:14
  • I think it will be a separate repository holding the documents (HTML Files) for this project, so any one of the team could easily read it – Ali Dabour Mar 19 '18 at 03:30
  • https://stackoverflow.com/a/38338422/1267177 might help, maybe have a look, or I'd do some bash scripting and generate in CI server. –  Mar 19 '18 at 04:19

2 Answers2

2

You have two questions here:

Is it possible to generate HTML pages for all packages linked together through godoc -html?

No. Because it is not implemented into godoc (https://godoc.org/golang.org/x/tools/cmd/godoc).

The other question:

How can I generate HTML documents for all packages inside a folder using godoc

I think the simplest way is to start godoc with the http flag: godoc -http=:6060

Then you navigate to the folder you want to get the docs. For that url you can use a webcrawler for getting the html documentation. There are already some crawler in Go (https://godoc.org/?q=crawler), if you don't want to write a crawler by your own.

apxp
  • 5,240
  • 4
  • 23
  • 43
1

I developed Golds, which is an alternate Go docs generation tool (and a local docs server / code reader). Hope you this tool would satisfy your need.

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.

T.L
  • 105
  • 8