diff --git a/cmd/godoc/bake.sh b/cmd/godoc/bake.sh deleted file mode 100755 index 0b73a0a4db..0000000000 --- a/cmd/godoc/bake.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2013 The Go Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -set -e - -go run bake.go template/* | gofmt > template.go - diff --git a/cmd/godoc/main.go b/cmd/godoc/main.go index d44e90876e..7067a5784e 100644 --- a/cmd/godoc/main.go +++ b/cmd/godoc/main.go @@ -49,6 +49,7 @@ import ( "strings" "code.google.com/p/go.tools/godoc" + "code.google.com/p/go.tools/godoc/static" "code.google.com/p/go.tools/godoc/vfs" "code.google.com/p/go.tools/godoc/vfs/mapfs" "code.google.com/p/go.tools/godoc/vfs/zipfs" @@ -197,7 +198,7 @@ func main() { if *templateDir != "" { fs.Bind("/lib/godoc", vfs.OS(*templateDir), "/", vfs.BindBefore) } else { - fs.Bind("/lib/godoc", mapfs.New(bakedFiles), "/", vfs.BindReplace) + fs.Bind("/lib/godoc", mapfs.New(static.Files), "/", vfs.BindReplace) } } else { // use file system specified via .zip file (path separator must be '/') diff --git a/cmd/godoc/bake.go b/godoc/static/bake.go similarity index 94% rename from cmd/godoc/bake.go rename to godoc/static/bake.go index cabd2f9c84..078b782d99 100644 --- a/cmd/godoc/bake.go +++ b/godoc/static/bake.go @@ -33,8 +33,8 @@ func main() { func bake(files []string) error { w := bufio.NewWriter(os.Stdout) - fmt.Fprintf(w, "%v\n\npackage main\n\n", warning) - fmt.Fprintf(w, "var bakedFiles = map[string]string{\n") + fmt.Fprintf(w, "%v\n\npackage static\n\n", warning) + fmt.Fprintf(w, "var Files = map[string]string{\n") for _, fn := range files { b, err := ioutil.ReadFile(fn) if err != nil { diff --git a/godoc/static/bake.sh b/godoc/static/bake.sh new file mode 100755 index 0000000000..c1491cac77 --- /dev/null +++ b/godoc/static/bake.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Copyright 2013 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +set -e + +STATIC=" + codewalk.html + codewalkdir.html + dirlist.html + error.html + example.html + godoc.html + godocs.js + jquery.js + opensearch.xml + package.html + package.txt + playground.js + search.html + search.txt + style.css +" + +go run bake.go $STATIC | gofmt > static.go diff --git a/cmd/godoc/template/codewalk.html b/godoc/static/codewalk.html similarity index 100% rename from cmd/godoc/template/codewalk.html rename to godoc/static/codewalk.html diff --git a/cmd/godoc/template/codewalkdir.html b/godoc/static/codewalkdir.html similarity index 100% rename from cmd/godoc/template/codewalkdir.html rename to godoc/static/codewalkdir.html diff --git a/cmd/godoc/template/dirlist.html b/godoc/static/dirlist.html similarity index 100% rename from cmd/godoc/template/dirlist.html rename to godoc/static/dirlist.html diff --git a/godoc/static/doc.go b/godoc/static/doc.go new file mode 100644 index 0000000000..3f3a27cbb5 --- /dev/null +++ b/godoc/static/doc.go @@ -0,0 +1,8 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package static exports a map of static file content that supports the godoc +// user interface. The map should be used with the mapfs package, see +// code.google.com/p/godoc/vfs/mapfs. +package static diff --git a/cmd/godoc/template/error.html b/godoc/static/error.html similarity index 100% rename from cmd/godoc/template/error.html rename to godoc/static/error.html diff --git a/cmd/godoc/template/example.html b/godoc/static/example.html similarity index 100% rename from cmd/godoc/template/example.html rename to godoc/static/example.html diff --git a/cmd/godoc/template/godoc.html b/godoc/static/godoc.html similarity index 100% rename from cmd/godoc/template/godoc.html rename to godoc/static/godoc.html diff --git a/cmd/godoc/template/godocs.js b/godoc/static/godocs.js similarity index 100% rename from cmd/godoc/template/godocs.js rename to godoc/static/godocs.js diff --git a/cmd/godoc/template/jquery.js b/godoc/static/jquery.js similarity index 100% rename from cmd/godoc/template/jquery.js rename to godoc/static/jquery.js diff --git a/cmd/godoc/template/opensearch.xml b/godoc/static/opensearch.xml similarity index 100% rename from cmd/godoc/template/opensearch.xml rename to godoc/static/opensearch.xml diff --git a/cmd/godoc/template/package.html b/godoc/static/package.html similarity index 100% rename from cmd/godoc/template/package.html rename to godoc/static/package.html diff --git a/cmd/godoc/template/package.txt b/godoc/static/package.txt similarity index 100% rename from cmd/godoc/template/package.txt rename to godoc/static/package.txt diff --git a/cmd/godoc/template/playground.js b/godoc/static/playground.js similarity index 100% rename from cmd/godoc/template/playground.js rename to godoc/static/playground.js diff --git a/cmd/godoc/template/search.html b/godoc/static/search.html similarity index 100% rename from cmd/godoc/template/search.html rename to godoc/static/search.html diff --git a/cmd/godoc/template/search.txt b/godoc/static/search.txt similarity index 100% rename from cmd/godoc/template/search.txt rename to godoc/static/search.txt diff --git a/cmd/godoc/template.go b/godoc/static/static.go similarity index 99% rename from cmd/godoc/template.go rename to godoc/static/static.go index 60920d830d..f3baa8acd4 100644 --- a/cmd/godoc/template.go +++ b/godoc/static/static.go @@ -1,8 +1,8 @@ // DO NOT EDIT ** This file was generated with the bake tool ** DO NOT EDIT // -package main +package static -var bakedFiles = map[string]string{ +var Files = map[string]string{ "codewalk.html": `