Skip to content

Commit 9589ed7

Browse files
authored
Set up a live-reload server with make autobuild (#1855)
1 parent c2bbb5c commit 9589ed7

File tree

4 files changed

+57
-15
lines changed

4 files changed

+57
-15
lines changed

CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ set(SPHINX_BUILD_JSON_EN_DIR "${SPHINX_OUTPUT_DIR}/json/_build_en/doctrees
7171
set(SPHINX_BUILD_JSON_RU_DIR "${SPHINX_OUTPUT_DIR}/json/_build_ru/doctrees")
7272

7373
set(SPHINX_EN_HTML_DIR "${SPHINX_OUTPUT_DIR}/html/en/")
74+
set(SPHINX_EN_AUTOBUILD_DIR "${SPHINX_OUTPUT_DIR}/html_auto/en/")
7475
set(SPHINX_RU_HTML_DIR "${SPHINX_OUTPUT_DIR}/html/ru/")
7576
set(SPHINX_EN_HTML_OLD_DIR "${SPHINX_OUTPUT_DIR}/html_old/en/")
7677
set(SPHINX_RU_HTML_OLD_DIR "${SPHINX_OUTPUT_DIR}/html_old/ru/")
@@ -128,6 +129,19 @@ add_custom_target(singlehtml-website
128129
COMMENT "Building HTML single-page documentation with Sphinx"
129130
)
130131

132+
add_custom_target(autobuild
133+
COMMAND sphinx-autobuild
134+
-b html
135+
-d "${SPHINX_BUILD_HTML_DIR}"
136+
-c html/
137+
--host 0.0.0.0
138+
--port 8000
139+
-A nolang_path=true
140+
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
141+
"${SPHINX_EN_AUTOBUILD_DIR}"
142+
COMMENT "Build & Live-reload on https://127.0.0.1:8000"
143+
)
144+
131145
add_custom_target(html-ru ALL
132146
COMMAND "${SPHINX_EXECUTABLE}"
133147
-b html

README.md

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Tarantool documentation source, published at https://www.tarantool.io/doc/.
77
## How to build Tarantool documentation using [Docker](https://www.docker.com)
88

99
### Build docker image
10+
1011
```bash
1112
docker build -t tarantool-doc-builder .
1213
```
@@ -38,7 +39,44 @@ Init make commands:
3839
docker run --rm -it -v $(pwd):/doc tarantool-doc-builder sh -c "cmake ."
3940
```
4041

41-
Run a required make command inside *tarantool-doc-builder* container:
42+
Now you're ready to build and preview the documentation locally.
43+
44+
### Build and run the documentation on your machine
45+
46+
When editing the documentation, you can set up a live-reload server.
47+
It will build your documentation and serve it on [127.0.0.1:8000](http://127.0.0.1:8000).
48+
Every time you make changes in the source files, it will rebuild the docs
49+
and refresh the browser page.
50+
51+
```bash
52+
docker run --rm -it -p 8000:8000 -v $(pwd):/doc tarantool-doc-builder sh -c "make autobuild"
53+
```
54+
55+
First build will take some time.
56+
When it's done, open [127.0.0.1:8000](http://127.0.0.1:8000) in the browser.
57+
Now when you make changes, they will be rebuilt in a few seconds,
58+
and the browser tab with preview will reload automatically.
59+
60+
You can also build the docs manually with `make html`,
61+
and then serve them using python3 built-in server:
62+
```bash
63+
docker run --rm -it -v $(pwd):/doc tarantool-doc-builder sh -c "make html"
64+
docker run --rm -it -v $(pwd):/doc tarantool-doc-builder sh -c "make html-ru"
65+
python3 -m http.server --directory output/html
66+
```
67+
68+
or python2 built-in server:
69+
```bash
70+
cd output/html
71+
python -m SimpleHTTPServer
72+
```
73+
74+
then go to [localhost:8000](http://localhost:8000) in your browser.
75+
76+
77+
There are other commands which can run
78+
in the *tarantool-doc-builder* container:
79+
4280
```bash
4381
docker run --rm -it -v $(pwd):/doc tarantool-doc-builder sh -c "make html"
4482
docker run --rm -it -v $(pwd):/doc tarantool-doc-builder sh -c "make html-ru"
@@ -55,19 +93,6 @@ docker run --rm -it -v $(pwd):/doc tarantool-doc-builder sh -c "make update-po"
5593
docker run --rm -it -v $(pwd):/doc tarantool-doc-builder sh -c "make update-po-force"
5694
```
5795

58-
### Run documentation locally on your machine
59-
using python3 built-in server:
60-
```bash
61-
cd output/html
62-
python3 -m http.server
63-
```
64-
or python2 built-in server:
65-
```bash
66-
cd output/html
67-
python -m SimpleHTTPServer
68-
```
69-
then go to [localhost:8000](http://localhost:8000) in your browser.
70-
7196
## Localization
7297

7398
Terms:

_theme/tarantool/elements.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
{%- macro abspath(path) -%}
77
{%- if rel_path == "true" -%}
88
{{ path }}
9+
{%- elif nolang_path == "true" -%}
10+
{{ [ "/", path ] | join('') }}
911
{%- else -%}
1012
{{ [ "/", language, "/", path ] | join('') }}
1113
{%- endif -%}

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ Sphinx==1.8.5
22
sphinx-intl
33
lupa
44
docutils==0.14
5-
sphinxcontrib-svg2pdfconverter
5+
sphinxcontrib-svg2pdfconverter
6+
sphinx-autobuild

0 commit comments

Comments
 (0)