-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task: adding a bit more of content to the build command
- Loading branch information
1 parent
d4712e3
commit 098b7ec
Showing
13 changed files
with
134 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/fsnotify/fsnotify" | ||
) | ||
|
||
// watch a folder for changes and rebuild the documentation | ||
// when a change is detected. | ||
func watch(docsFolder, dstFolder string) { | ||
log.Println("> 👀 Watching for changes in", docsFolder) | ||
|
||
watcher, err := fsnotify.NewWatcher() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer watcher.Close() | ||
|
||
// Start listening for events. | ||
go func() { | ||
for { | ||
select { | ||
case event, ok := <-watcher.Events: | ||
if !ok { | ||
return | ||
} | ||
|
||
if event.Has(fsnotify.Write) { | ||
build(docsFolder, dstFolder) | ||
log.Println(">", event.Name, "changed, documentation rebuilt.") | ||
} | ||
case err, ok := <-watcher.Errors: | ||
if !ok { | ||
return | ||
} | ||
log.Println("error:", err) | ||
} | ||
} | ||
}() | ||
|
||
// add the folder and its subfolders to the watcher by | ||
// walking the folder. | ||
err = filepath.Walk(docsFolder, func(path string, info os.FileInfo, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = watcher.Add(path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}) | ||
|
||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Block main goroutine forever. | ||
<-make(chan struct{}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
index: 3 | ||
--- | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: Help | ||
index: 2 | ||
--- | ||
|
||
The help command prints usage information about the CLI. | ||
|
||
```sh | ||
$ doco help | ||
Doco is a simple, lightweight, and easy to use documentation generator for Markdown files. It takes a directory of Markdown files and generates a static site with a table of contents. | ||
|
||
Usage | ||
doco command [arguments] | ||
|
||
Commands | ||
build Generates the documentation site into the /public directory (see options) | ||
help Prints the CLI help | ||
init Creates a /docs directory with base files (see options) | ||
serve Starts a local server to view the documentation site | ||
|
||
Options: | ||
--folder source folder for the documentation | ||
--output folder to put the generated files | ||
``` | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
Title: Serve | ||
index: 2 | ||
--- | ||
|
||
Serve builds the static website and starts a local server to serve the static website on port 3000. It will also watch for changes in the markdown files and rebuild the website. | ||
|
||
```sh | ||
$ doco serve | ||
2024/01/19 13:46:16 > 👀 Watching for changes in docs | ||
2024/01/19 13:46:16 > Serving documentation on http://localhost:3000/ | ||
2024/01/19 13:46:20 > docs/the_cli/build.md changed, documentation rebuilt. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters