summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2016-12-12 23:24:22 +0900
committershimizukawa <shimizukawa@gmail.com>2016-12-12 23:28:00 +0900
commit5fc8d3db9160cf9dcbb5ed1034aec9302dbac0dd (patch)
treed8623ff3df970ce2b2df3aa60ad159f938d0dc05
parentd0fe6ba21530ab90a8dca51bd117b428f69b247e (diff)
downloadsphinx-git-5fc8d3db9160cf9dcbb5ed1034aec9302dbac0dd.tar.gz
Fix: #2469: Ignore updates of catalog files for gettext builder. Thanks to Hiroshi Ohkubo.
-rw-r--r--CHANGES2
-rw-r--r--sphinx/application.py2
-rw-r--r--sphinx/environment/__init__.py31
-rw-r--r--tests/test_intl.py9
4 files changed, 31 insertions, 13 deletions
diff --git a/CHANGES b/CHANGES
index 9481299cb..8e73f560a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -21,6 +21,8 @@ Bugs fixed
* #3220: KeyError when having a duplicate citation
* #3200: LaTeX: xref inside desc_name not allowed
* #3228: ``build_sphinx`` command crashes when missing dependency
+* #2469: Ignore updates of catalog files for gettext builder. Thanks to
+ Hiroshi Ohkubo.
Release 1.5 (released Dec 5, 2016)
diff --git a/sphinx/application.py b/sphinx/application.py
index baca1c8f1..00661aa61 100644
--- a/sphinx/application.py
+++ b/sphinx/application.py
@@ -281,7 +281,7 @@ class Sphinx(object):
if freshenv:
self.env = BuildEnvironment(self.srcdir, self.doctreedir, self.config)
self.env.set_warnfunc(self.warn)
- self.env.find_files(self.config)
+ self.env.find_files(self.config, self.buildername)
for domain in self.domains.keys():
self.env.domains[domain] = self.domains[domain](self.env)
else:
diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py
index f5cd1550b..0f978e42e 100644
--- a/sphinx/environment/__init__.py
+++ b/sphinx/environment/__init__.py
@@ -379,7 +379,7 @@ class BuildEnvironment(object):
enc_rel_fn = rel_fn.encode(sys.getfilesystemencoding())
return rel_fn, path.abspath(path.join(self.srcdir, enc_rel_fn))
- def find_files(self, config):
+ def find_files(self, config, buildername=None):
"""Find all source files in the source dir and put them in
self.found_docs.
"""
@@ -397,16 +397,23 @@ class BuildEnvironment(object):
else:
self.warn(docname, "document not readable. Ignored.")
- # add catalog mo file dependency
- for docname in self.found_docs:
- catalog_files = find_catalog_files(
- docname,
- self.srcdir,
- self.config.locale_dirs,
- self.config.language,
- self.config.gettext_compact)
- for filename in catalog_files:
- self.dependencies.setdefault(docname, set()).add(filename)
+ # Current implementation is applying translated messages in the reading
+ # phase.Therefore, in order to apply the updated message catalog, it is
+ # necessary to re-process from the reading phase. Here, if dependency
+ # is set for the doc source and the mo file, it is processed again from
+ # the reading phase when mo is updated. In the future, we would like to
+ # move i18n process into the writing phase, and remove these lines.
+ if buildername != 'gettext':
+ # add catalog mo file dependency
+ for docname in self.found_docs:
+ catalog_files = find_catalog_files(
+ docname,
+ self.srcdir,
+ self.config.locale_dirs,
+ self.config.language,
+ self.config.gettext_compact)
+ for filename in catalog_files:
+ self.dependencies.setdefault(docname, set()).add(filename)
def get_outdated_files(self, config_changed):
"""Return (added, changed, removed) sets."""
@@ -488,7 +495,7 @@ class BuildEnvironment(object):
# the source and doctree directories may have been relocated
self.srcdir = srcdir
self.doctreedir = doctreedir
- self.find_files(config)
+ self.find_files(config, app.buildername)
self.config = config
# this cache also needs to be updated every time
diff --git a/tests/test_intl.py b/tests/test_intl.py
index 68fae6b15..4a517c111 100644
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -367,6 +367,15 @@ def test_gettext_builder(app, status, warning):
for expect_msg in [m for m in expect if m.id]:
yield assert_in, expect_msg.id, [m.id for m in actual if m.id]
+ # --- don't rebuild by .mo mtime
+ app.builder.build_update()
+ updated = app.env.update(app.config, app.srcdir, app.doctreedir, app)
+ yield assert_equal, len(updated), 0
+
+ (app.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').utime(None)
+ updated = app.env.update(app.config, app.srcdir, app.doctreedir, app)
+ yield assert_equal, len(updated), 0
+
@gen_with_intl_app('html', freshenv=True)
def test_html_builder(app, status, warning):