Commit 1ddedbae authored by Rob Pike's avatar Rob Pike

tmpltohtml: put a DO NOT EDIT mark automatically in the output

R=r, rsc, r
CC=golang-dev
https://golang.org/cl/5469045
parent 0397b28a
<!-- Effective Go --> <!-- Effective Go -->
<!--
DO NOT EDIT: created by
tmpltohtml effective_go.tmpl
-->
<h2 id="introduction">Introduction</h2> <h2 id="introduction">Introduction</h2>
......
<!-- Effective Go --> <!-- Effective Go -->
{{donotedit}}
<h2 id="introduction">Introduction</h2> <h2 id="introduction">Introduction</h2>
......
<!-- A Tutorial for the Go Programming Language --> <!-- A Tutorial for the Go Programming Language -->
<!--
DO NOT EDIT: created by
tmpltohtml go_tutorial.tmpl
-->
<h2>Introduction</h2> <h2>Introduction</h2>
<p> <p>
This document is a tutorial introduction to the basics of the Go programming This document is a tutorial introduction to the basics of the Go programming
......
<!-- A Tutorial for the Go Programming Language --> <!-- A Tutorial for the Go Programming Language -->
{{donotedit}}
<h2>Introduction</h2> <h2>Introduction</h2>
<p> <p>
This document is a tutorial introduction to the basics of the Go programming This document is a tutorial introduction to the basics of the Go programming
......
...@@ -35,6 +35,11 @@ func Usage() { ...@@ -35,6 +35,11 @@ func Usage() {
os.Exit(2) os.Exit(2)
} }
var templateFuncs = template.FuncMap{
"code": code,
"donotedit": donotedit,
}
func main() { func main() {
flag.Usage = Usage flag.Usage = Usage
flag.Parse() flag.Parse()
...@@ -44,7 +49,7 @@ func main() { ...@@ -44,7 +49,7 @@ func main() {
// Read and parse the input. // Read and parse the input.
name := flag.Args()[0] name := flag.Args()[0]
tmpl := template.New(name).Funcs(template.FuncMap{"code": code}) tmpl := template.New(name).Funcs(templateFuncs)
if _, err := tmpl.ParseFiles(name); err != nil { if _, err := tmpl.ParseFiles(name); err != nil {
log.Fatal(err) log.Fatal(err)
} }
...@@ -80,6 +85,11 @@ func format(arg interface{}) string { ...@@ -80,6 +85,11 @@ func format(arg interface{}) string {
return "" return ""
} }
func donotedit() string {
// No editing please.
return fmt.Sprintf("<!--\n DO NOT EDIT: created by\n tmpltohtml %s\n-->\n", flag.Args()[0])
}
func code(file string, arg ...interface{}) (string, error) { func code(file string, arg ...interface{}) (string, error) {
text := contents(file) text := contents(file)
var command string var command string
......
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