Fix: #2469: Ignore updates of catalog files for gettext builder. Thanks to Hiroshi Ohkubo.

This commit is contained in:
shimizukawa 2016-12-12 23:24:22 +09:00
parent d0fe6ba215
commit 5fc8d3db91
4 changed files with 31 additions and 13 deletions

View File

@ -21,6 +21,8 @@ Bugs fixed
* #3220: KeyError when having a duplicate citation * #3220: KeyError when having a duplicate citation
* #3200: LaTeX: xref inside desc_name not allowed * #3200: LaTeX: xref inside desc_name not allowed
* #3228: ``build_sphinx`` command crashes when missing dependency * #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) Release 1.5 (released Dec 5, 2016)

View File

@ -281,7 +281,7 @@ class Sphinx(object):
if freshenv: if freshenv:
self.env = BuildEnvironment(self.srcdir, self.doctreedir, self.config) self.env = BuildEnvironment(self.srcdir, self.doctreedir, self.config)
self.env.set_warnfunc(self.warn) 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(): for domain in self.domains.keys():
self.env.domains[domain] = self.domains[domain](self.env) self.env.domains[domain] = self.domains[domain](self.env)
else: else:

View File

@ -379,7 +379,7 @@ class BuildEnvironment(object):
enc_rel_fn = rel_fn.encode(sys.getfilesystemencoding()) enc_rel_fn = rel_fn.encode(sys.getfilesystemencoding())
return rel_fn, path.abspath(path.join(self.srcdir, enc_rel_fn)) 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 """Find all source files in the source dir and put them in
self.found_docs. self.found_docs.
""" """
@ -397,16 +397,23 @@ class BuildEnvironment(object):
else: else:
self.warn(docname, "document not readable. Ignored.") self.warn(docname, "document not readable. Ignored.")
# add catalog mo file dependency # Current implementation is applying translated messages in the reading
for docname in self.found_docs: # phase.Therefore, in order to apply the updated message catalog, it is
catalog_files = find_catalog_files( # necessary to re-process from the reading phase. Here, if dependency
docname, # is set for the doc source and the mo file, it is processed again from
self.srcdir, # the reading phase when mo is updated. In the future, we would like to
self.config.locale_dirs, # move i18n process into the writing phase, and remove these lines.
self.config.language, if buildername != 'gettext':
self.config.gettext_compact) # add catalog mo file dependency
for filename in catalog_files: for docname in self.found_docs:
self.dependencies.setdefault(docname, set()).add(filename) 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): def get_outdated_files(self, config_changed):
"""Return (added, changed, removed) sets.""" """Return (added, changed, removed) sets."""
@ -488,7 +495,7 @@ class BuildEnvironment(object):
# the source and doctree directories may have been relocated # the source and doctree directories may have been relocated
self.srcdir = srcdir self.srcdir = srcdir
self.doctreedir = doctreedir self.doctreedir = doctreedir
self.find_files(config) self.find_files(config, app.buildername)
self.config = config self.config = config
# this cache also needs to be updated every time # this cache also needs to be updated every time

View File

@ -367,6 +367,15 @@ def test_gettext_builder(app, status, warning):
for expect_msg in [m for m in expect if m.id]: 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] 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) @gen_with_intl_app('html', freshenv=True)
def test_html_builder(app, status, warning): def test_html_builder(app, status, warning):