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;
|
||||
margin: 16px 0;
|
||||
}
|
||||
table {
|
||||
div.chapter {
|
||||
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;
|
||||
min-width: 690px;
|
||||
max-width: 690px;
|
||||
|
@ -1,7 +1,4 @@
|
||||
title
|
||||
contents
|
||||
introduction
|
||||
|
||||
hello-world
|
||||
values
|
||||
variables
|
||||
@ -29,7 +26,6 @@ embedding
|
||||
interfaces
|
||||
errors
|
||||
ok-guards
|
||||
|
||||
goroutines
|
||||
concurrent-goroutines
|
||||
channels
|
||||
@ -47,7 +43,6 @@ timers
|
||||
tickers
|
||||
state-goroutine
|
||||
state-mutex
|
||||
|
||||
sorting
|
||||
sorting-by-functions
|
||||
collection-functions
|
||||
@ -64,7 +59,6 @@ number-parsing
|
||||
urls
|
||||
sha1-hashes
|
||||
base64-encoding
|
||||
|
||||
reading-files
|
||||
writing-files
|
||||
line-filters
|
||||
@ -75,12 +69,10 @@ spawning-processes
|
||||
execing-processes
|
||||
signals
|
||||
exit
|
||||
|
||||
http-client
|
||||
https-client
|
||||
redis
|
||||
postgres
|
||||
|
||||
hello-web
|
||||
responses
|
||||
request-routing
|
||||
@ -90,4 +82,4 @@ basic-authentication
|
||||
canonical-hosts
|
||||
middleware
|
||||
graceful-shutdown
|
||||
https-servers
|
||||
https-servers
|
@ -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>
|
@ -1,5 +1,5 @@
|
||||
<h2>Introduction</h2>
|
||||
|
||||
|
||||
<p>Why you should care.</p>
|
||||
|
||||
|
||||
<p>This is why.</p>
|
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])
|
||||
check(err)
|
||||
ensureCache()
|
||||
|
||||
// Header
|
||||
fmt.Fprint(outF,
|
||||
`<!DOCTYPE html>
|
||||
<html>
|
||||
@ -196,20 +198,31 @@ func main() {
|
||||
</head>
|
||||
<body>`)
|
||||
|
||||
indexLines := readLines("src/index.txt")
|
||||
indexNames := filterStrings(indexLines, func(s string) bool {
|
||||
return s != ""
|
||||
})
|
||||
// Title page
|
||||
fmt.Fprint(outF, mustReadFile("src/title.html"))
|
||||
|
||||
for _, indexName := range indexNames {
|
||||
fmt.Fprintf(outF, `<div id="%s">`, indexName)
|
||||
if (indexName == "title") || (indexName == "contents") || (indexName == "introduction") {
|
||||
sourcePath := "src/" + indexName + "/" + indexName + ".html"
|
||||
source := mustReadFile(sourcePath)
|
||||
_, err = outF.WriteString(source)
|
||||
check(err)
|
||||
// Contents page
|
||||
chapterIds := readLines("src/contents.txt")
|
||||
fmt.Fprint(outF, `<div class="chapter" id="contents"><h2>Contents</h2><ul>`)
|
||||
for _, chapterId := range chapterIds {
|
||||
var chapterName string
|
||||
if chapterId == "introduction" {
|
||||
chapterName = "Introduction"
|
||||
} 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,
|
||||
`<table cellspacing="0" cellpadding="0" id="%s"><tbody>`,
|
||||
chapterPath)
|
||||
@ -235,5 +248,7 @@ func main() {
|
||||
}
|
||||
fmt.Fprintf(outF, `</div>`)
|
||||
}
|
||||
|
||||
// Footer
|
||||
fmt.Fprint(outF, `</body></html>`)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user