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

SublimeText2: multiple unnecessary builds #33

Closed sdawans closed 8 years ago

sdawans commented 8 years ago

Hi. Great tool, keep up the good work!

This is very similar to #25, but concerns SublimeText2.

When I started using sphinx-autobuild with ST2, I was getting a large amount of builds, partly due to .TMP files being generated by Sublime.

Saving with ST2

C:\doc\example>sphinx-autobuild source build/html
[I 150710 14:11:45 server:271] Serving on http://127.0.0.1:8000
[I 150710 14:11:45 handlers:58] Start watching changes
[I 150710 14:11:45 handlers:60] Start detecting changes
[I 150710 14:11:51 handlers:131] Browser Connected: http://127.0.0.1:8000/genindex.html

+--------- source\.sublbb3.tmp changed ------------------------------------------
| Running Sphinx v1.3b2
| loading pickled environment... not yet created
| building [mo]: targets for 0 po files that are out of date
| building [html]: targets for 1 source files that are out of date
| updating environment: 1 added, 0 changed, 0 removed
| reading sources... [100%] index
|
| looking for now-outdated files... none found
| pickling environment... done
| checking consistency... done
| preparing documents... done
| writing output... [100%] index
|
| generating indices... genindex
| writing additional pages... search
| copying static files... done
| copying extra files... done
| dumping search index in English (code: en) ... done
| dumping object inventory... done
| build succeeded.
+--------------------------------------------------------------------------------

+--------- source\.sublbb3.tmp changed ------------------------------------------
| Running Sphinx v1.3b2
| 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, 0 changed, 0 removed
| looking for now-outdated files... none found
| no targets are out of date.
| build succeeded.
+--------------------------------------------------------------------------------

+--------- source\index.rst~RF3503b2eb.TMP changed ------------------------------
| Running Sphinx v1.3b2
| 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, 0 changed, 0 removed
| looking for now-outdated files... none found
| no targets are out of date.
| build succeeded.
+--------------------------------------------------------------------------------

+--------- source\index.rst changed ---------------------------------------------
| Running Sphinx v1.3b2
| 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, 0 changed, 0 removed
| looking for now-outdated files... none found
| no targets are out of date.
| build succeeded.
+--------------------------------------------------------------------------------

+--------- source\index.rst~RF3503b2eb.TMP changed ------------------------------
| Running Sphinx v1.3b2
| 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, 0 changed, 0 removed
| looking for now-outdated files... none found
| no targets are out of date.
| build succeeded.
+--------------------------------------------------------------------------------

+--------- source\index.rst changed ---------------------------------------------
| Running Sphinx v1.3b2
| 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, 0 changed, 0 removed
| looking for now-outdated files... none found
| no targets are out of date.
| build succeeded.
+--------------------------------------------------------------------------------

+--------- source\index.rst changed ---------------------------------------------
| Running Sphinx v1.3b2
| 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, 0 changed, 0 removed
| looking for now-outdated files... none found
| no targets are out of date.
| build succeeded.
+--------------------------------------------------------------------------------

+--------- source\index.rst~RF3503b2eb.TMP changed ------------------------------
| Running Sphinx v1.3b2
| 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, 0 changed, 0 removed
| looking for now-outdated files... none found
| no targets are out of date.
| build succeeded.
+--------------------------------------------------------------------------------

These are straightforward to suppress using the --ignore *.tmp option. However, as you can see from the following output, there are still 2 unneccessary builds.

Saving with ST2 and --ignore *.tmp

C:\doc\example>sphinx-autobuild source build/html --ignore *.tmp
[I 150710 14:12:53 server:271] Serving on http://127.0.0.1:8000
[I 150710 14:12:53 handlers:58] Start watching changes
[I 150710 14:12:53 handlers:60] Start detecting changes
[I 150710 14:12:59 handlers:131] Browser Connected: http://127.0.0.1:8000/genindex.html

+--------- source\index.rst changed ---------------------------------------------
| Running Sphinx v1.3b2
| loading pickled environment... done
| building [mo]: targets for 0 po files that are out of date
| building [html]: targets for 1 source files that are out of date
| updating environment: 0 added, 1 changed, 0 removed
| reading sources... [100%] index
|
| looking for now-outdated files... none found
| pickling environment... done
| checking consistency... done
| preparing documents... done
| writing output... [100%] index
|
| generating indices... genindex
| writing additional pages... search
| copying static files... done
| copying extra files... done
| dumping search index in English (code: en) ... done
| dumping object inventory... done
| build succeeded.
+--------------------------------------------------------------------------------

+--------- source\index.rst changed ---------------------------------------------
| Running Sphinx v1.3b2
| 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, 0 changed, 0 removed
| looking for now-outdated files... none found
| no targets are out of date.
| build succeeded.
+--------------------------------------------------------------------------------

+--------- source\index.rst changed ---------------------------------------------
| Running Sphinx v1.3b2
| 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, 0 changed, 0 removed
| looking for now-outdated files... none found
| no targets are out of date.
| build succeeded.
+--------------------------------------------------------------------------------

[I 150710 14:13:06 handlers:91] Reload 1 waiters: None
[I 150710 14:13:07 handlers:131] Browser Connected: http://127.0.0.1:8000/genindex.html

I know nothing of how Sublime handles files, but I clearly don't have this issue with notepad++.

Saving with Notepad++

[I 150710 14:13:06 handlers:91] Reload 1 waiters: None
[I 150710 14:13:07 handlers:131] Browser Connected: http://127.0.0.1:8000/genindex.html

+--------- source\index.rst changed ---------------------------------------------
| Running Sphinx v1.3b2
| loading pickled environment... done
| building [mo]: targets for 0 po files that are out of date
| building [html]: targets for 1 source files that are out of date
| updating environment: 0 added, 1 changed, 0 removed
| reading sources... [100%] index
|
| looking for now-outdated files... none found
| pickling environment... done
| checking consistency... done
| preparing documents... done
| writing output... [100%] index
|
| generating indices... genindex
| writing additional pages... search
| copying static files... done
| copying extra files... done
| dumping search index in English (code: en) ... done
| dumping object inventory... done
| build succeeded.
+--------------------------------------------------------------------------------

[I 150710 14:14:01 handlers:91] Reload 1 waiters: None
[I 150710 14:14:01 handlers:131] Browser Connected: http://127.0.0.1:8000/genindex.html

I suspect that it's not enough to ignore those temporary files since they probably replace the saved file multiple times during the saving process.

A general workaround for this kind of problem could be to add an option to ignore saves of a file repeated within a certain time interval (~2 seconds or so). I can look into that kind of fix, just wondering if anyone here knows enough about SublimeText2 to be able to disactivate this.

sdawans commented 8 years ago

OK - problem solved.

It turns out I'm using SublimeText3, not 2, which provides an option called atomic_save to save files going through temporary files. So, all I had to do was add this line to the user options:

"atomic_save": false

Don't know how I missed this page the first time around:

http://stackoverflow.com/questions/20634684/what-is-sublime-text-doing-when-i-save-a-file