Skip to content

Commit ca90e8f

Browse files
tevansukn2ygk
andauthored
Add live docs rebuilding using sphinx-autobuild (#916)
Add a new tox target, `livedocs`, that uses sphinx-autobuild to monitor the docs and auto rebuild the HTML docs when they change. It also starts a webserver on 127.0.0.1:8000 using livereload to serve the docs, which will automatically reload the pages in your browser as they are changed. Add docs on updating the docs. Add sphinx-rtd-theme so that the docs generated in development match the style that they are displayed in on readthedocs. Co-authored-by: Alan Crosswell <[email protected]>
1 parent 331b49d commit ca90e8f

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

docs/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,6 @@ pseudoxml:
175175
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
176176
@echo
177177
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
178+
179+
livehtml:
180+
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"sphinx.ext.coverage",
4343
"rfc",
4444
"m2r",
45+
"sphinx_rtd_theme",
4546
]
4647

4748
# Add any paths that contain templates here, relative to this directory.
@@ -120,7 +121,7 @@
120121

121122
# The theme to use for HTML and HTML Help pages. See the documentation for
122123
# a list of builtin themes.
123-
# html_theme = 'classic'
124+
html_theme = "sphinx_rtd_theme"
124125

125126
# Theme options are theme-specific and customize the look and feel of a theme
126127
# further. For a list of options available for each theme, see the
@@ -200,11 +201,11 @@
200201

201202
latex_elements = {
202203
# The paper size ('letterpaper' or 'a4paper').
203-
#'papersize': 'letterpaper',
204+
# 'papersize': 'letterpaper',
204205
# The font size ('10pt', '11pt' or '12pt').
205-
#'pointsize': '10pt',
206+
# 'pointsize': '10pt',
206207
# Additional stuff for the LaTeX preamble.
207-
#'preamble': '',
208+
# 'preamble': '',
208209
}
209210

210211
# Grouping the document tree into LaTeX files. List of tuples

docs/contributing.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,32 @@ can also (largely) stop worrying about code style, although you should always
5252
check how the code looks after ``black`` has formatted it, and think if there
5353
is a better way to structure the code so that it is more readable.
5454

55+
Documentation
56+
=============
57+
58+
You can edit the documentation by editing files in ``docs/``. This project
59+
uses sphinx to turn ``ReStructuredText`` into the HTML docs you are reading.
60+
61+
In order to build the docs in to HTML, you can run::
62+
63+
tox -e docs
64+
65+
This will build the docs, and place the result in ``docs/_build/html``.
66+
Alternatively, you can run::
67+
68+
tox -e livedocs
69+
70+
This will run ``sphinx`` in a live reload mode, so any changes that you make to
71+
the ``RST`` files will be automatically detected and the HTML files rebuilt.
72+
It will also run a simple HTTP server available at `<http://localhost:8000/>`_
73+
serving the HTML files, and auto-reload the page when changes are made.
74+
75+
This allows you to edit the docs and see your changes instantly reflected in
76+
the browser.
77+
78+
* `ReStructuredText primer
79+
<https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`_
80+
5581
Pull requests
5682
=============
5783

tox.ini

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,19 @@ passenv =
4646
ignore_errors = true
4747
ignore_outcome = true
4848

49-
[testenv:docs]
49+
[testenv:{docs,livedocs}]
5050
basepython = python3.8
5151
changedir = docs
5252
whitelist_externals = make
53-
commands = make html
53+
commands =
54+
docs: make html
55+
livedocs: make livehtml
5456
deps =
5557
sphinx<3
5658
oauthlib>=3.1.0
5759
m2r>=0.2.1
60+
sphinx-rtd-theme
61+
livedocs: sphinx-autobuild
5862

5963
[testenv:flake8]
6064
basepython = python3.8

0 commit comments

Comments
 (0)