Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/py-polars/docs/run_live_docs_server.py
6939 views
1
from livereload import Server, shell
2
from source.conf import html_static_path, templates_path
3
4
# -------------------------------------------------------------------------
5
# To use, just execute `python run_live_docs_server.py` in a terminal
6
# and a local server will run the docs in your browser, automatically
7
# refreshing/reloading the pages you're working on as they are modified.
8
# Extremely helpful to see the real output before it gets uploaded, and
9
# a much smoother experience than constantly running `make html` yourself.
10
# -------------------------------------------------------------------------
11
12
if __name__ == "__main__":
13
# establish a local docs server
14
svr = Server()
15
16
# command to rebuild the docs
17
refresh_docs = shell("make html")
18
19
# watch for source file changes and trigger rebuild/refresh
20
svr.watch("*.rst", refresh_docs, delay=1)
21
svr.watch("*.md", refresh_docs, delay=1)
22
svr.watch("source/reference/*", refresh_docs, delay=1)
23
for path in html_static_path + templates_path:
24
svr.watch(f"source/{path}/*", refresh_docs, delay=1)
25
26
# path from which to serve the docs
27
svr.serve(root="build/html")
28
29