working build again
This commit is contained in:
parent
f98dba348c
commit
f0b976cea1
@ -1,7 +1,7 @@
|
|||||||
<h2>Contents</h2>
|
<h2>Contents</h2>
|
||||||
|
|
||||||
<ul class="toc">
|
<ul class="toc">
|
||||||
<li><a href="#009-for">For</a></li>
|
<li><a href="#for">For</a></li>
|
||||||
<li><a href="#023-pointers">Pointers</a></li>
|
<li><a href="#pointers">Pointers</a></li>
|
||||||
<li><a href="#041-worker-pools">Worker Pools</a></li>
|
<li><a href="#worker-pools">Worker Pools</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
exec go run tool/build-html.go
|
exec go run tool/build-html.go $1
|
||||||
|
@ -171,38 +171,74 @@ func parseAndRenderSegs(sourcePath string) []*seg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if len(os.Args) != 2 {
|
||||||
|
panic("Wrong number of args")
|
||||||
|
}
|
||||||
|
outF, err := os.Create(os.Args[1])
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
ensureCache()
|
ensureCache()
|
||||||
fmt.Print(`<!DOCTYPE html>
|
fmt.Fprint(outF,
|
||||||
|
`<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-eqiv="content-type" content="text/html;charset=utf-8">
|
<meta http-eqiv="content-type" content="text/html;charset=utf-8">
|
||||||
<title>Go by Example</title>
|
<title>Go by Example</title>
|
||||||
<link rel=stylesheet href="../style/book.css">
|
<link rel=stylesheet href="../src/book.css">
|
||||||
</head>
|
</head>
|
||||||
<body>`)
|
<body>`)
|
||||||
chapterPaths := mustGlob("./src/0*")
|
|
||||||
for _, chapterPath := range chapterPaths {
|
|
||||||
if strings.HasSuffix(chapterPath, ".html") {
|
|
||||||
|
|
||||||
|
indexBytes, err := ioutil.ReadFile("src/index.txt")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
indexLines := strings.Split(string(indexBytes), "\n")
|
||||||
|
indexNames := make([]string, 0)
|
||||||
|
for _, indexLine := range indexLines {
|
||||||
|
if indexLine != "" && !strings.Contains(indexLine, "#") && !strings.Contains(indexLine, "~") {
|
||||||
|
indexNames = append(indexNames, indexLine)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, indexName := range indexNames {
|
||||||
|
fmt.Fprintf(outF, `<div id="%s">`, indexName)
|
||||||
|
if (indexName == "title") || (indexName == "contents") || (indexName == "introduction") {
|
||||||
|
sourcePath := "src/" + indexName + "/" + indexName + ".html"
|
||||||
|
sourceBytes, err := ioutil.ReadFile(sourcePath)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
_, err = outF.Write(sourceBytes)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf(`<table cellspacing="0" cellpadding="0" id="%s"><tbody>`, chapterPath)
|
chapterPath := "src/" + indexName
|
||||||
|
fmt.Fprintf(outF,
|
||||||
|
`<table cellspacing="0" cellpadding="0" id="%s"><tbody>`,
|
||||||
|
chapterPath)
|
||||||
sourcePaths := mustGlob(chapterPath + "/*")
|
sourcePaths := mustGlob(chapterPath + "/*")
|
||||||
for _, sourcePath := range sourcePaths {
|
for _, sourcePath := range sourcePaths {
|
||||||
|
if strings.HasSuffix(sourcePath, ".go") || strings.HasSuffix(sourcePath, ".sh") {
|
||||||
segs := parseAndRenderSegs(sourcePath)
|
segs := parseAndRenderSegs(sourcePath)
|
||||||
for _, seg := range segs {
|
for _, seg := range segs {
|
||||||
codeClasses := "code"
|
codeClasses := "code"
|
||||||
if seg.code == "" {
|
if seg.code == "" {
|
||||||
codeClasses = codeClasses + " empty"
|
codeClasses = codeClasses + " empty"
|
||||||
}
|
}
|
||||||
fmt.Printf(
|
fmt.Fprintf(outF,
|
||||||
`<tr>
|
`<tr>
|
||||||
<td class=docs>%s</td>
|
<td class=docs>%s</td>
|
||||||
<td class="%s">%s</td>
|
<td class="%s">%s</td>
|
||||||
</tr>`, seg.docsRendered, codeClasses, seg.codeRendered)
|
</tr>`,
|
||||||
|
seg.docsRendered, codeClasses, seg.codeRendered)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Print(`</tbody></table>`)
|
|
||||||
}
|
}
|
||||||
|
fmt.Fprint(outF, `</tbody></table>`)
|
||||||
}
|
}
|
||||||
fmt.Print(`</body></html>`)
|
fmt.Fprintf(outF, `</div>`)
|
||||||
|
}
|
||||||
|
fmt.Fprint(outF, `</body></html>`)
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
exec prince build/gobyexample.html -o build/gobyexample.pdf
|
exec prince $1 -o $2
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
set -e
|
set -e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
ls tool/src/*.go src/*/*.go | xargs gofmt -tabs=false -tabwidth=4 -w=true
|
ls tool/*.go src/*/*.go | xargs gofmt -tabs=false -tabwidth=4 -w=true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user