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
|
||||
}
|
||||
|
||||
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")
|
||||
check(err)
|
||||
fmt.Fprint(indexF,
|
||||
@ -200,7 +207,7 @@ func generateIndex() {
|
||||
</head>
|
||||
<body>
|
||||
<div class="chapter" id="contents"><h2>Contents</h2><ul>`)
|
||||
chapterIds := readLines("meta/contents.txt")
|
||||
|
||||
for _, chapterId := range chapterIds {
|
||||
chapterLines := readLines("src/" + chapterId + "/" + chapterId + ".go")
|
||||
chapterName := chapterLines[0][6:]
|
||||
@ -209,8 +216,7 @@ func generateIndex() {
|
||||
fmt.Fprint(indexF, `</ul></div></body></html>`)
|
||||
}
|
||||
|
||||
func generateChapters() {
|
||||
chapterIds := readLines("meta/contents.txt")
|
||||
func renderChapters(chapterIds []string) {
|
||||
for _, chapterId := range chapterIds {
|
||||
chapterLines := readLines("src/" + chapterId + "/" + chapterId + ".go")
|
||||
chapterName := chapterLines[0][6:]
|
||||
@ -251,6 +257,7 @@ func generateChapters() {
|
||||
|
||||
func main() {
|
||||
ensureDir(siteDir)
|
||||
generateIndex()
|
||||
generateChapters()
|
||||
chapters := buildChapters()
|
||||
renderIndex(chapters)
|
||||
renderChapters(chapters)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user