Generating static documentation from godoc

1,370 views
Skip to first unread message

Mike Chaten

unread,
Sep 20, 2012, 2:27:13 AM9/20/12
to golan...@googlegroups.com
Is there a way to generate static html + css + js from godoc instead of having it served via net/http? I need to serve up documentation from an apache server that I don't control. As far as I can tell, the -html flag only outputs html with invalid links to *.go files.

Thanks,
-Mike

Dave Cheney

unread,
Sep 20, 2012, 2:38:52 AM9/20/12
to Mike Chaten, golan...@googlegroups.com
What about something like this (not fully tested)

godoc -http=:8080 &
wget -e robots=off -m http://localhost:8080

You may need to do some rewriting in apache to do any final fixups.

On Thu, Sep 20, 2012 at 4:27 PM, Mike Chaten <mch...@gmail.com> wrote:
> Is there a way to generate static html + css js from godoc instead of
> having it served via net/http? I need to serve up documentation from an
> apache server that I don't control. As far as I can tell, the -html flag
> only outputs html with invalid links to *.go files.
>
> Thanks,
> -Mike
>
> --
>
>

Mike Chaten

unread,
Sep 20, 2012, 3:04:29 AM9/20/12
to golan...@googlegroups.com, Mike Chaten
Interesting hack, that certainly downloads the entire website. I'll probably have to write my own templates to get rid of the header at the top and everything not under src/ and pkg/, but that's to be expected.
If there is truly no way to do this with just go & godoc cmds, then I might see about adding this functionality into godoc itself to speed things up (took 2m on my laptop here).

Thanks for your help, Dave!

-Mike

Tymoteusz Blazejczyk

unread,
May 16, 2020, 3:11:44 PM5/16/20
to golang-nuts
This can be also achieved using simple wget command for that. Example: snippet

I have a similar issue with that. I'm using GitLab for my projects and I have decide to create and share with some handy GitLab CI YAML templates for Go projects that will automatically generate a static HTML Go documentation without any external packages: https://gitlab.com/tymonx/gitlab-ci


Two nice features:
  • Embedded Go source code files
  • Search box is referencing to GitLab
TB
Reply all
Reply to author
Forward
0 new messages