Commit 005fe411 authored by Andrew Gerrand's avatar Andrew Gerrand

godoc: add -template flag to specify custom templates

R=gri, niemeyer, rsc1
CC=golang-dev
https://golang.org/cl/4291059
parent 76061f72
......@@ -65,6 +65,7 @@ var (
tabwidth = flag.Int("tabwidth", 4, "tab width")
showTimestamps = flag.Bool("timestamps", true, "show timestamps with directory listings")
maxResults = flag.Int("maxresults", 10000, "maximum number of full text search results shown")
templateDir = flag.String("templates", "", "directory containing alternate template files")
// file system mapping
fsMap Mapping // user-defined mapping
......@@ -635,6 +636,14 @@ var fmap = template.FormatterMap{
func readTemplate(name string) *template.Template {
path := filepath.Join(*goroot, "lib", "godoc", name)
if *templateDir != "" {
defaultpath := path
path = filepath.Join(*templateDir, name)
if _, err := os.Stat(path); err != nil {
log.Print("readTemplate:", err)
path = defaultpath
}
}
data, err := ioutil.ReadFile(path)
if err != nil {
log.Fatalf("ReadFile %s: %v", path, err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment