-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrebuild-docs.nu
More file actions
executable file
·34 lines (27 loc) · 916 Bytes
/
rebuild-docs.nu
File metadata and controls
executable file
·34 lines (27 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env nu
# Script to rebuild documentation when changes are detected.
# This script is written in [Nushell](https://www.nushell.sh/).
use std log
let watch_path = ("docs" | path expand)
def skip-path [] {
let outer_dir = ($in | path relative-to $watch_path | path split | first)
(
($outer_dir | str starts-with ".") # not required for rebuild (e.g. `.mypy-cache`)
or ($in | str ends-with "~") # temporary files created by sphinx extension
or ($outer_dir == "_build") # generated files
or ($outer_dir == "api") # generated files
)
}
def build-docs [] {
poetry run sphinx-build -M html docs docs/_build
}
build-docs
run-external $env.BROWSER docs/_build/html/index.html
watch $watch_path {|operation, path, new_path|
if ($path | skip-path) {
log debug $"Skipping ($path)"
return
}
log info $"($operation) ($path) ($new_path)"
build-docs
}