working selective generate
This commit is contained in:
parent
e16eb41f32
commit
bf370a0434
@ -1,84 +0,0 @@
|
|||||||
hello-world
|
|
||||||
values
|
|
||||||
variables
|
|
||||||
inline-assignment
|
|
||||||
constants
|
|
||||||
for
|
|
||||||
if-else
|
|
||||||
switch
|
|
||||||
arrays
|
|
||||||
slices
|
|
||||||
maps
|
|
||||||
range
|
|
||||||
functions
|
|
||||||
multiple-return-values
|
|
||||||
varadic-functions
|
|
||||||
closures
|
|
||||||
recursion
|
|
||||||
defer
|
|
||||||
panic
|
|
||||||
pointers
|
|
||||||
new
|
|
||||||
structs
|
|
||||||
methods
|
|
||||||
embedding
|
|
||||||
interfaces
|
|
||||||
errors
|
|
||||||
ok-guards
|
|
||||||
goroutines
|
|
||||||
concurrent-goroutines
|
|
||||||
channels
|
|
||||||
channel-buffering
|
|
||||||
channel-directions
|
|
||||||
synchronization
|
|
||||||
select
|
|
||||||
timeouts
|
|
||||||
scatter-gather
|
|
||||||
rate-limiting
|
|
||||||
worker-pools
|
|
||||||
non-blocking-channel-operations
|
|
||||||
closing-channels
|
|
||||||
timers
|
|
||||||
tickers
|
|
||||||
state-goroutine
|
|
||||||
state-mutex
|
|
||||||
sorting
|
|
||||||
sorting-by-functions
|
|
||||||
collection-functions
|
|
||||||
string-functions
|
|
||||||
string-formatting
|
|
||||||
regexs
|
|
||||||
bytes
|
|
||||||
json
|
|
||||||
time
|
|
||||||
epochs
|
|
||||||
elapsed-time
|
|
||||||
random-numbers
|
|
||||||
number-parsing
|
|
||||||
urls
|
|
||||||
sha1-hashes
|
|
||||||
base64-encoding
|
|
||||||
reading-files
|
|
||||||
writing-files
|
|
||||||
line-filters
|
|
||||||
command-line-arguments
|
|
||||||
command-line-flags
|
|
||||||
environment-variables
|
|
||||||
spawning-processes
|
|
||||||
execing-processes
|
|
||||||
signals
|
|
||||||
exit
|
|
||||||
http-client
|
|
||||||
https-client
|
|
||||||
redis
|
|
||||||
postgres
|
|
||||||
hello-web
|
|
||||||
responses
|
|
||||||
request-routing
|
|
||||||
request-logging
|
|
||||||
static-content
|
|
||||||
basic-authentication
|
|
||||||
canonical-hosts
|
|
||||||
middleware
|
|
||||||
graceful-shutdown
|
|
||||||
https-servers
|
|
@ -187,7 +187,14 @@ func parseAndRenderSegs(sourcePath string) []*seg {
|
|||||||
return segs
|
return segs
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateIndex() {
|
func buildChapters() []string {
|
||||||
|
chapterLines := readLines("meta/chapters.txt")
|
||||||
|
return filterStrings(chapterLines, func(ch string) bool {
|
||||||
|
return (ch != "") && !strings.HasPrefix(ch, "#")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func renderIndex(chapterIds []string) {
|
||||||
indexF, err := os.Create(siteDir + "/index.html")
|
indexF, err := os.Create(siteDir + "/index.html")
|
||||||
check(err)
|
check(err)
|
||||||
fmt.Fprint(indexF,
|
fmt.Fprint(indexF,
|
||||||
@ -200,7 +207,7 @@ func generateIndex() {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="chapter" id="contents"><h2>Contents</h2><ul>`)
|
<div class="chapter" id="contents"><h2>Contents</h2><ul>`)
|
||||||
chapterIds := readLines("meta/contents.txt")
|
|
||||||
for _, chapterId := range chapterIds {
|
for _, chapterId := range chapterIds {
|
||||||
chapterLines := readLines("src/" + chapterId + "/" + chapterId + ".go")
|
chapterLines := readLines("src/" + chapterId + "/" + chapterId + ".go")
|
||||||
chapterName := chapterLines[0][6:]
|
chapterName := chapterLines[0][6:]
|
||||||
@ -209,8 +216,7 @@ func generateIndex() {
|
|||||||
fmt.Fprint(indexF, `</ul></div></body></html>`)
|
fmt.Fprint(indexF, `</ul></div></body></html>`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateChapters() {
|
func renderChapters(chapterIds []string) {
|
||||||
chapterIds := readLines("meta/contents.txt")
|
|
||||||
for _, chapterId := range chapterIds {
|
for _, chapterId := range chapterIds {
|
||||||
chapterLines := readLines("src/" + chapterId + "/" + chapterId + ".go")
|
chapterLines := readLines("src/" + chapterId + "/" + chapterId + ".go")
|
||||||
chapterName := chapterLines[0][6:]
|
chapterName := chapterLines[0][6:]
|
||||||
@ -251,6 +257,7 @@ func generateChapters() {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ensureDir(siteDir)
|
ensureDir(siteDir)
|
||||||
generateIndex()
|
chapters := buildChapters()
|
||||||
generateChapters()
|
renderIndex(chapters)
|
||||||
|
renderChapters(chapters)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user