sphinx-doc / sphinx-autobuild

Watch a Sphinx directory and rebuild the documentation when a change is detected. Also includes a hot-reload web server.
MIT License
524 stars 75 forks source link

Infinite loop during a plot whose source is watched #49

Closed Startouf closed 3 years ago

Startouf commented 7 years ago

I am watching a directory containing plot code with the -z flag. This directory contains graph python code that I am reading in a documentation file using the plot directive.

#benchmark/report.rst:309 (imported in my sphinx documentation)
.. plot:: ../../benchmark/pyplots/scalability.py

#benchmark/pyplots/scalability.rb
# -*- coding: UTF-8 -*-
#! /usr/bin/python
# My plot code here, crashing or not crashing, both trigger infinite loops

There is an infinite loop with the plot

Also for some reason the watch line writes doc/sphinx/benchmark/pyplots/scalability.py. The output of the plots are not placed under the _build folder of my command argument (though this is maybe unrelated to autobuild)

+--------- doc/sphinx/benchmark/pyplots/scalability.py changed ------------------
| Running Sphinx v1.4.5
WARNING: while setting up extension ['?', 'matplotlib.sphinxext.only_directives']: node class 'html_only' is already registered, its visitors will be overridden
WARNING: while setting up extension ['?', 'matplotlib.sphinxext.only_directives']: node class 'html_only' is already registered, its visitors will be overridden
WARNING: while setting up extension ['?', 'matplotlib.sphinxext.only_directives']: node class 'latex_only' is already registered, its visitors will be overridden
WARNING: while setting up extension ['?', 'matplotlib.sphinxext.only_directives']: node class 'latex_only' is already registered, its visitors will be overridden
| loading pickled environment... done
| building [mo]: targets for 0 po files that are out of date
| building [html]: targets for 0 source files that are out of date
| updating environment: 0 added, 2 changed, 0 removed
benchmark/report.rst:44: WARNING: Title underline too short.

Mathematical and computational context
____________________________________
benchmark/report.rst:44: WARNING: Title underline too short.

Mathematical and computational context
____________________________________

| reading sources... [ 50%] benchmarking                                                                                                                                     reading sources... [100%] index
| looking for now-outdated files... none found
| pickling environment... done
| checking consistency... done
| preparing documents... done
| writing output... [ 50%] benchmarking                                                                                                                                      writing output... [100%] index
| generating indices... genindex
| writing additional pages... search
| copying images... [100%] _build/benchmark/pyplots/scalability.png
| copying static files... done
| copying extra files... done
| dumping search index in English (code: en) ... done
| dumping object inventory... done
| build succeeded, 15 warnings.
+--------------------------------------------------------------------------------

+--------- doc/sphinx/benchmark/pyplots/scalability.png changed ------------------
# Similar stuff. Note that the watched files is not the same 8 (.png). Also the output color changes.

# It will do it again with `scalability.pdf` and `scalability.hires.png` then loop back to `.py`
# And inside this loop there is a browser refresh sent

In case my directory structure is not clear

-- myproject/
-- -- doc/sphinx/
-- -- -- config.py
-- -- -- index.rst (does an `.. include:: ../../benchmark/report.rst`)
-- -- benchmark/
-- -- -- report.rst (does `.. plot:: ../../benchmark/pyplots/scalability.py`)
-- -- -- pyplots/
-- -- -- -- scalability.py

And my run command is from the myproject/ directory

sphinx-autobuild doc/sphinx doc/sphinx/_build/html --open-browser -z benchmark/

Mac OS X 10.11.6 Python 2.7.12 Sphinx-autobuild Version: 0.6.0

qiuwch commented 7 years ago

I also have this issue. I think it is because when the plot is generated, the output is detected as file changes. So everything is started again.

pradyunsg commented 3 years ago

Yup! A file that gets generated like that triggers a loop.

Maybe, we need some sort of loop-detection logic here. Hmm...

pradyunsg commented 3 years ago

Closing as a duplicate of #67.