-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun_livereload.py
More file actions
30 lines (20 loc) · 825 Bytes
/
Copy pathrun_livereload.py
File metadata and controls
30 lines (20 loc) · 825 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
"""
Automatically re-build Sphinx docs while editing, serve docs on an
HTTP port, and also reload any browsers pointed to the docs.
"""
import glob
from livereload import Server, shell
from livereload.watcher import Watcher
sphinx = ".venv/bin/python3 .venv/bin/sphinx-build -E -b html docs docs/_build"
class CustomWatcher(Watcher):
""" Handle recursive globs with Python 3.5+ globbing """
def is_glob_changed(self, path, ignore=None):
for f in glob.glob(path, recursive=True):
if self.is_file_changed(f, ignore):
return True
return False
server = Server(watcher=CustomWatcher())
server.watch('docs/**', shell(sphinx),
ignore=lambda s: '_build' in s)
server.watch('src/kaybee/**.py', shell(sphinx))
server.serve(root='docs/_build', live_css=False)