16d1af8d88
This CL groups the package list into two groups - standard library(GOROOT), and third-party code(GOPATH). It also wraps the list with a collapsible div header used in the package documentation page. This makes the entire page easy to view and manage, and also makes it consistent with the rest of the pages. To implement this, a new function was added to the filesystem interface which returns the root type of the filesystem. In most cases, it is either GOROOT or GOPATH. There are other kinds of filesystems which are not used in the home page, so additional values have been added to satisfy the interface. A side effect of this is that the html template code has become a bit spaghetti-like with if conditions all over. This is because the same template is used to render a package directory as well as the package home page. A better way is to use two separate templates for the different tasks. This cleans out a lot of the if conditions and make for a much cleaner code. This has been taken care in CL 101295. Fixes golang/go#3305 Fixes golang/go#15020 Change-Id: I876357dc76280a7df2ed08d7c6bc53d9a41e69ab Reviewed-on: https://go-review.googlesource.com/95835 Run-TryBot: Andrew Bonventre <andybons@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org> |
||
---|---|---|
.. | ||
analysis | ||
dl | ||
proxy | ||
redirect | ||
short | ||
static | ||
util | ||
vfs | ||
appengine.go | ||
cmdline_test.go | ||
cmdline.go | ||
corpus.go | ||
dirtrees_test.go | ||
dirtrees.go | ||
format.go | ||
godoc17_test.go | ||
godoc_test.go | ||
godoc.go | ||
index_test.go | ||
index.go | ||
linkify.go | ||
meta.go | ||
page.go | ||
parser.go | ||
pres.go | ||
README.md | ||
search.go | ||
server.go | ||
snippet.go | ||
spec.go | ||
spot.go | ||
tab.go | ||
template.go |
godoc
This directory contains most of the code for running a godoc server. The executable lives at golang.org/x/tools/cmd/godoc.
Development mode
In production, CSS/JS/template assets need to be compiled into the godoc binary. It can be tedious to recompile assets every time, but you can pass a flag to load CSS/JS/templates from disk every time a page loads:
godoc -templates=$GOPATH/src/golang.org/x/tools/godoc/static -http=:6060
Recompiling static assets
The files that live at static/style.css
, static/jquery.js
and so on are not
present in the final binary. They are placed into static/static.go
by running
go generate
. So to compile a change and test it in your browser:
-
Make changes to e.g.
static/style.css
. -
Run
go generate golang.org/x/tools/godoc/static
sostatic/static.go
picks up the change. -
Run
go install golang.org/x/tools/cmd/godoc
so the compiledgodoc
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.