Merge branch '1.7' into 4979_latex_index_escaping

This commit is contained in:
Takeshi KOMIYA 2018-05-21 10:40:38 +09:00 committed by GitHub
commit 0261b76bcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 7 deletions

View File

@ -30,6 +30,9 @@ Bugs fixed
* #4969: autodoc: constructor method should not have return annotation
* latex: deeply nested enumerated list which is beginning with non-1 causes
LaTeX engine crashed
* #4978: latex: shorthandoff is not set up for Brazil locale
* #4928: i18n: Ignore dot-directories like .git/ in LC_MESSAGES/
* #4946: py domain: type field could not handle "None" as a type
* #4979: latex: Incorrect escaping of curly braces in index entries
Testing

View File

@ -19,6 +19,7 @@ from sphinx.environment.adapters.asset import ImageAdapter
from sphinx.util import i18n, logging, status_iterator
from sphinx.util.console import bold # type: ignore
from sphinx.util.i18n import find_catalog
from sphinx.util.matching import Matcher
from sphinx.util.osutil import SEP, ensuredir, relative_uri, relpath
from sphinx.util.parallel import ParallelTasks, SerialTasks, make_chunks, \
parallel_available
@ -252,7 +253,8 @@ class Builder(object):
self.config.language,
charset=self.config.source_encoding,
gettext_compact=self.config.gettext_compact,
force_all=True)
force_all=True,
excluded=Matcher(['**/.?**']))
message = 'all of %d po files' % len(catalogs)
self.compile_catalogs(catalogs, message)
@ -273,7 +275,8 @@ class Builder(object):
self.config.language,
domains=list(specified_domains),
charset=self.config.source_encoding,
gettext_compact=self.config.gettext_compact)
gettext_compact=self.config.gettext_compact,
excluded=Matcher(['**/.?**']))
message = 'targets for %d po files that are specified' % len(catalogs)
self.compile_catalogs(catalogs, message)
@ -283,7 +286,8 @@ class Builder(object):
[path.join(self.srcdir, x) for x in self.config.locale_dirs],
self.config.language,
charset=self.config.source_encoding,
gettext_compact=self.config.gettext_compact)
gettext_compact=self.config.gettext_compact,
excluded=Matcher(['**/.?**']))
message = 'targets for %d po files that are out of date' % len(catalogs)
self.compile_catalogs(catalogs, message)

View File

@ -156,7 +156,15 @@ class PyGroupedField(PyXrefMixin, GroupedField):
class PyTypedField(PyXrefMixin, TypedField):
pass
def make_xref(self, rolename, domain, target,
innernode=nodes.emphasis, contnode=None, env=None):
# type: (unicode, unicode, unicode, nodes.Node, nodes.Node, BuildEnvironment) -> nodes.Node # NOQA
if rolename == 'class' and target == 'None':
# None is not a type, so use obj role instead.
rolename = 'obj'
return super(PyTypedField, self).make_xref(rolename, domain, target,
innernode, contnode, env)
class PyObject(ObjectDescription):

View File

@ -22,8 +22,10 @@ from babel.messages.pofile import read_po
from sphinx.errors import SphinxError
from sphinx.util import logging
from sphinx.util.matching import Matcher
from sphinx.util.osutil import SEP, relpath, walk
logger = logging.getLogger(__name__)
if False:
@ -101,8 +103,9 @@ def find_catalog_files(docname, srcdir, locale_dirs, lang, compaction):
def find_catalog_source_files(locale_dirs, locale, domains=None, gettext_compact=False,
charset='utf-8', force_all=False):
# type: (List[unicode], unicode, List[unicode], bool, unicode, bool) -> Set[CatalogInfo]
charset='utf-8', force_all=False,
excluded=Matcher([])):
# type: (List[unicode], unicode, List[unicode], bool, unicode, bool, Matcher) -> Set[CatalogInfo] # NOQA
"""
:param list locale_dirs:
list of path as `['locale_dir1', 'locale_dir2', ...]` to find
@ -136,6 +139,8 @@ def find_catalog_source_files(locale_dirs, locale, domains=None, gettext_compact
for dirpath, dirnames, filenames in walk(base_dir, followlinks=True):
filenames = [f for f in filenames if f.endswith('.po')]
for filename in filenames:
if excluded(path.join(relpath(dirpath, base_dir), filename)):
continue
base = path.splitext(filename)[0]
domain = relpath(path.join(dirpath, base), base_dir)
if gettext_compact and path.sep in domain:

View File

@ -197,7 +197,7 @@ class ExtBabel(Babel):
shortlang = self.language.split('_')[0]
if shortlang in ('de', 'ngerman', 'sl', 'slovene', 'pt', 'portuges',
'es', 'spanish', 'nl', 'dutch', 'pl', 'polish', 'it',
'italian'):
'italian', 'pt-BR', 'brazil'):
return '\\ifnum\\catcode`\\"=\\active\\shorthandoff{"}\\fi'
elif shortlang in ('tr', 'turkish'):
# memo: if ever Sphinx starts supporting 'Latin', do as for Turkish

View File

@ -157,6 +157,17 @@ def test_get_catalogs_with_compact(tempdir):
assert domains == set(['test1', 'test2', 'sub'])
def test_get_catalogs_excluded(tempdir):
(tempdir / 'loc1' / 'en' / 'LC_MESSAGES' / '.git').makedirs()
(tempdir / 'loc1' / 'en' / 'LC_MESSAGES' / 'en_dom.po').write_text('#')
(tempdir / 'loc1' / 'en' / 'LC_MESSAGES' / '.git' / 'no_no.po').write_text('#')
catalogs = i18n.find_catalog_source_files(
[tempdir / 'loc1'], 'en', force_all=False, excluded=lambda path: '.git' in path)
domains = set(c.domain for c in catalogs)
assert domains == set(['en_dom'])
def test_format_date():
date = datetime.date(2016, 2, 7)