Skip to content

Commit e4a01a0

Browse files
mergify[bot]Tomoya Fujita
andauthored
add make target "serve" to start the live html server. (#6876) (#6889)
* add make target "serve" to start the live html server. * use doc server port number 2022 as "ROS2" vibes. --------- (cherry picked from commit 739b3cb) Signed-off-by: Tomoya Fujita <tomoya.fujita825@gmail.com> Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
1 parent 5a9921b commit e4a01a0

4 files changed

Lines changed: 49 additions & 1 deletion

File tree

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ ifeq ($(OS),Windows_NT)
99
endif
1010
BUILD = $(PYTHON) -m sphinx
1111
OPTS =-c . -W # Treat warnings as errors
12+
LIVE_HOST ?= 0.0.0.0
13+
LIVE_PORT ?= 2022
1214

1315
DICTIONARIES := codespell_dictionary.txt codespell_whitelist.txt
1416

@@ -61,4 +63,7 @@ linkcheck:
6163
@echo
6264
@echo "Check finished. Report is in $(LINKCHECKDIR)."
6365

64-
.PHONY: help Makefile multiversion test test-tools linkcheck lint spellcheck check-dictionaries sort-dictionaries
66+
serve:
67+
sphinx-autobuild --host $(LIVE_HOST) --port $(LIVE_PORT) -c . $(SOURCE) $(OUT)/html
68+
69+
.PHONY: help Makefile multiversion test test-tools linkcheck serve lint spellcheck check-dictionaries sort-dictionaries

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,27 @@ For local testing of the current tree use:
5151

5252
`sensible-browser build/html/index.html`
5353

54+
### Live-reload local development
55+
56+
To iterate on documentation without manually rebuilding and refreshing the browser, use [`sphinx-autobuild`](https://github.com/sphinx-doc/sphinx-autobuild).
57+
It watches the source files, rebuilds incrementally on save, and serves the result with automatic browser reload.
58+
59+
`sphinx-autobuild` is installed as part of `requirements.txt`.
60+
Start the live server with:
61+
62+
```
63+
make serve
64+
```
65+
66+
Then open `http://localhost:2022` in a browser.
67+
68+
The `serve` target binds to `0.0.0.0:2022` by default (a little ROS 2 vibe) so the server is reachable through devcontainer / port forwarding.
69+
Override the bind address or port if needed:
70+
71+
```
72+
make serve LIVE_HOST=127.0.0.1 LIVE_PORT=8080
73+
```
74+
5475
### Spelling Check
5576

5677
To check the spelling, use:

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ docutils
44
pip
55
pytest
66
sphinx
7+
sphinx-autobuild
78
sphinx-copybutton
89
sphinx-lint
910
sphinx-multiversion

source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,27 @@ This is the recommended way to test out local changes.
9696
The build process can take some time.
9797
To see the output, open ``build/html/index.html`` in your browser.
9898

99+
Live-reload local development
100+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
101+
102+
When iterating on documentation, instead of re-running ``make html`` and refreshing the browser after every edit, use `sphinx-autobuild <https://github.com/sphinx-doc/sphinx-autobuild>`__ to watch the source files, rebuild incrementally on save, and serve the result with automatic browser reload.
103+
104+
``sphinx-autobuild`` is installed as part of ``requirements.txt``.
105+
Start the live server with:
106+
107+
.. code-block:: console
108+
109+
$ make serve
110+
111+
Then open ``http://localhost:8000`` in a browser.
112+
113+
The ``serve`` target binds to ``0.0.0.0:8000`` by default so the server is reachable through devcontainer / port forwarding.
114+
Override the bind address or port if needed:
115+
116+
.. code-block:: console
117+
118+
$ make serve LIVE_HOST=127.0.0.1 LIVE_PORT=8080
119+
99120
100121
Checking / Testing the site
101122
^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)