tweak approach to metadata
This commit is contained in:
parent
00990744bb
commit
a65209fa8a
13
src/book.css
13
src/book.css
@ -31,8 +31,19 @@ hr {
|
|||||||
height: 1px;
|
height: 1px;
|
||||||
margin: 16px 0;
|
margin: 16px 0;
|
||||||
}
|
}
|
||||||
table {
|
div.chapter {
|
||||||
page-break-inside: avoid;
|
page-break-inside: avoid;
|
||||||
|
}
|
||||||
|
div#title {
|
||||||
|
page-break-after: always;
|
||||||
|
}
|
||||||
|
div#contents {
|
||||||
|
page-break-after: always;
|
||||||
|
}
|
||||||
|
div#introduction {
|
||||||
|
page-break-after: always;
|
||||||
|
}
|
||||||
|
table {
|
||||||
width: 690px;
|
width: 690px;
|
||||||
min-width: 690px;
|
min-width: 690px;
|
||||||
max-width: 690px;
|
max-width: 690px;
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
title
|
|
||||||
contents
|
|
||||||
introduction
|
introduction
|
||||||
|
|
||||||
hello-world
|
hello-world
|
||||||
values
|
values
|
||||||
variables
|
variables
|
||||||
@ -29,7 +26,6 @@ embedding
|
|||||||
interfaces
|
interfaces
|
||||||
errors
|
errors
|
||||||
ok-guards
|
ok-guards
|
||||||
|
|
||||||
goroutines
|
goroutines
|
||||||
concurrent-goroutines
|
concurrent-goroutines
|
||||||
channels
|
channels
|
||||||
@ -47,7 +43,6 @@ timers
|
|||||||
tickers
|
tickers
|
||||||
state-goroutine
|
state-goroutine
|
||||||
state-mutex
|
state-mutex
|
||||||
|
|
||||||
sorting
|
sorting
|
||||||
sorting-by-functions
|
sorting-by-functions
|
||||||
collection-functions
|
collection-functions
|
||||||
@ -64,7 +59,6 @@ number-parsing
|
|||||||
urls
|
urls
|
||||||
sha1-hashes
|
sha1-hashes
|
||||||
base64-encoding
|
base64-encoding
|
||||||
|
|
||||||
reading-files
|
reading-files
|
||||||
writing-files
|
writing-files
|
||||||
line-filters
|
line-filters
|
||||||
@ -75,12 +69,10 @@ spawning-processes
|
|||||||
execing-processes
|
execing-processes
|
||||||
signals
|
signals
|
||||||
exit
|
exit
|
||||||
|
|
||||||
http-client
|
http-client
|
||||||
https-client
|
https-client
|
||||||
redis
|
redis
|
||||||
postgres
|
postgres
|
||||||
|
|
||||||
hello-web
|
hello-web
|
||||||
responses
|
responses
|
||||||
request-routing
|
request-routing
|
@ -1,7 +0,0 @@
|
|||||||
<h2>Contents</h2>
|
|
||||||
|
|
||||||
<ul class="toc">
|
|
||||||
<li><a href="#for">For</a></li>
|
|
||||||
<li><a href="#pointers">Pointers</a></li>
|
|
||||||
<li><a href="#worker-pools">Worker Pools</a></li>
|
|
||||||
</ul>
|
|
7
src/title.html
Normal file
7
src/title.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<div class="chapter" id="title">
|
||||||
|
<h1>Go by Example</h1>
|
||||||
|
|
||||||
|
<h4>Mark McGranaghan</h4>
|
||||||
|
|
||||||
|
<p>Version eb9cf61d</p>
|
||||||
|
</div>
|
@ -1,5 +0,0 @@
|
|||||||
<h1>Go by Example</h1>
|
|
||||||
|
|
||||||
<h4>Mark McGranaghan</h4>
|
|
||||||
|
|
||||||
<p>Version eb9cf61d</p>
|
|
@ -186,6 +186,8 @@ func main() {
|
|||||||
outF, err := os.Create(os.Args[1])
|
outF, err := os.Create(os.Args[1])
|
||||||
check(err)
|
check(err)
|
||||||
ensureCache()
|
ensureCache()
|
||||||
|
|
||||||
|
// Header
|
||||||
fmt.Fprint(outF,
|
fmt.Fprint(outF,
|
||||||
`<!DOCTYPE html>
|
`<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@ -196,20 +198,31 @@ func main() {
|
|||||||
</head>
|
</head>
|
||||||
<body>`)
|
<body>`)
|
||||||
|
|
||||||
indexLines := readLines("src/index.txt")
|
// Title page
|
||||||
indexNames := filterStrings(indexLines, func(s string) bool {
|
fmt.Fprint(outF, mustReadFile("src/title.html"))
|
||||||
return s != ""
|
|
||||||
})
|
|
||||||
|
|
||||||
for _, indexName := range indexNames {
|
// Contents page
|
||||||
fmt.Fprintf(outF, `<div id="%s">`, indexName)
|
chapterIds := readLines("src/contents.txt")
|
||||||
if (indexName == "title") || (indexName == "contents") || (indexName == "introduction") {
|
fmt.Fprint(outF, `<div class="chapter" id="contents"><h2>Contents</h2><ul>`)
|
||||||
sourcePath := "src/" + indexName + "/" + indexName + ".html"
|
for _, chapterId := range chapterIds {
|
||||||
source := mustReadFile(sourcePath)
|
var chapterName string
|
||||||
_, err = outF.WriteString(source)
|
if chapterId == "introduction" {
|
||||||
check(err)
|
chapterName = "Introduction"
|
||||||
} else {
|
} else {
|
||||||
chapterPath := "src/" + indexName
|
chapterLines := readLines("src/" + chapterId + "/" + chapterId + ".go")
|
||||||
|
chapterName = chapterLines[0][6:]
|
||||||
|
}
|
||||||
|
fmt.Fprintf(outF, `<li><a href="#%s">%s</a></li>`, chapterId, chapterName)
|
||||||
|
}
|
||||||
|
fmt.Fprint(outF, `</ul></div>`)
|
||||||
|
|
||||||
|
// Content chapters
|
||||||
|
for _, chapterId := range chapterIds {
|
||||||
|
fmt.Fprintf(outF, `<div class="chapter" id="%s">`, chapterId)
|
||||||
|
if chapterId == "introduction" {
|
||||||
|
fmt.Fprint(outF, mustReadFile("src/introduction.html"))
|
||||||
|
} else {
|
||||||
|
chapterPath := "src/" + chapterId
|
||||||
fmt.Fprintf(outF,
|
fmt.Fprintf(outF,
|
||||||
`<table cellspacing="0" cellpadding="0" id="%s"><tbody>`,
|
`<table cellspacing="0" cellpadding="0" id="%s"><tbody>`,
|
||||||
chapterPath)
|
chapterPath)
|
||||||
@ -235,5 +248,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
fmt.Fprintf(outF, `</div>`)
|
fmt.Fprintf(outF, `</div>`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Footer
|
||||||
fmt.Fprint(outF, `</body></html>`)
|
fmt.Fprint(outF, `</body></html>`)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user