From dbf69907cc72e3d7816a60aeee3c50a5cd508c1c Mon Sep 17 00:00:00 2001 From: Mark McGranaghan Date: Sat, 29 Sep 2012 14:06:57 -0700 Subject: [PATCH] add title --- style/generate.html | 13 +++++++++---- tool/generate.go | 9 ++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/style/generate.html b/style/generate.html index 47841a0..9a86dae 100644 --- a/style/generate.html +++ b/style/generate.html @@ -3,7 +3,7 @@ - Page Title + golit @@ -35,6 +35,11 @@ documentation form Go source files.

Recognize doc lines, extract their comment prefixes.

var docsPat = regexp.MustCompile("^\\s*\\/\\/\\s")
   
+
+ +

Recognize title prefixes, for titling web page.

+
var titlePat = regexp.MustCompile("^\\/\\/\\s##\\s")
+  
 

Abort on non-nil errors.

@@ -148,12 +153,12 @@ Special case the header to go in its own segment.

Print HTML header.

-
    fmt.Print(`
+
    fmt.Printf(`
 <!DOCTYPE html>
 <html>
   <head>
     <meta http-eqiv="content-type" content="text/html;charset=utf-8">
-    <title>Page Title</title>
+    <title>%s</title>
     <link rel=stylesheet href="book.css">
   </head>
   <body>
@@ -163,7 +168,7 @@ Special case the header to go in its own segment.

<thead> <tr><td class=docs></td><td class=code></td></tr> </thead> - <tbody>`) + <tbody>`, titlePat.ReplaceAllString(lines[0], ""))
diff --git a/tool/generate.go b/tool/generate.go index 70dc5f3..59bb270 100644 --- a/tool/generate.go +++ b/tool/generate.go @@ -17,6 +17,9 @@ import ( // Recognize doc lines, extract their comment prefixes. var docsPat = regexp.MustCompile("^\\s*\\/\\/\\s") +// Recognize title prefixes, for titling web page. +var titlePat = regexp.MustCompile("^\\/\\/\\s##\\s") + // Abort on non-nil errors. func check(err error) { if err != nil { @@ -108,12 +111,12 @@ func main() { } // Print HTML header. - fmt.Print(` + fmt.Printf(` - Page Title + %s @@ -123,7 +126,7 @@ func main() { - `) + `, titlePat.ReplaceAllString(lines[0], "")) // Print HTML docs/code segments. for _, seg := range segments {