[ACCEPTED]-Automatically build Sphinx documentation when a source file changes-python-sphinx

Accepted answer
Score: 36

You can use sphinx-autobuild.

It is easy to use, for example:

sphinx-autobuild docs docs/_build/html

or, if 3 you have a separate build dir,

sphinx-autobuild source build/html

It will also 2 automatically initiate a page refresh in 1 the browser.

Score: 15

Jacob Kaplan-Moss has a good solution:

pip install watchdog
watchmedo shell-command \
          --patterns="*.rst" \
          --ignore-pattern='_build/*' \
          --recursive \
          --command='make html'

Note, change the pattern 2 to match your suffix. Jacob uses *.txt, but 1 I needed to change it to *.rst.

Score: 4

If you're on a *nix system, you can use 4 inotify to monitor filesystem events and 3 trigger actions.

For example, on ubuntu,

apt-get install inotify-tools

Then 2 run a script like this to listen for events 1 in a given dir

while true
    inotifywait -r -e modify -e move -e create -e delete /tmp/docs | while read line
        echo "file changed; time to run make html"
Score: 0

You can create a macro in you favorite editor 2 that saves the file and opens it in your 1 browser, any text editor can do (geany, gedit, emacs, vi, notepad++...)

More Related questions