mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch 'stable'
This commit is contained in:
commit
1ce051d4a4
1
CHANGES
1
CHANGES
@ -89,6 +89,7 @@ Bugs fixed
|
||||
* #3796: env.resolve_references() crashes when non-document node given
|
||||
* #3803: Sphinx crashes with invalid PO files
|
||||
* #3791: PDF "continued on next page" for long tables isn't internationalized
|
||||
* #3788: smartquotes emits warnings for unsupported languages
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -24,7 +24,7 @@ from sphinx.errors import SphinxError
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.util import Tee, format_exception_cut_frames, save_traceback
|
||||
from sphinx.util.console import red, nocolor, color_terminal # type: ignore
|
||||
from sphinx.util.docutils import docutils_namespace
|
||||
from sphinx.util.docutils import docutils_namespace, patch_docutils
|
||||
from sphinx.util.osutil import abspath, fs_encoding
|
||||
from sphinx.util.pycompat import terminal_safe
|
||||
|
||||
@ -299,7 +299,7 @@ def main(argv=sys.argv[1:]): # type: ignore
|
||||
|
||||
app = None
|
||||
try:
|
||||
with docutils_namespace():
|
||||
with patch_docutils(), docutils_namespace():
|
||||
app = Sphinx(srcdir, confdir, outdir, doctreedir, opts.builder,
|
||||
confoverrides, status, warning, opts.freshenv,
|
||||
opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
|
||||
|
@ -25,7 +25,7 @@ from six.moves import cPickle as pickle
|
||||
|
||||
from docutils.io import NullOutput
|
||||
from docutils.core import Publisher
|
||||
from docutils.utils import Reporter, get_source_line
|
||||
from docutils.utils import Reporter, get_source_line, normalize_language_tag
|
||||
from docutils.utils.smartquotes import smartchars
|
||||
from docutils.parsers.rst import roles
|
||||
from docutils.parsers.rst.languages import en as english
|
||||
@ -672,10 +672,15 @@ class BuildEnvironment(object):
|
||||
self.settings['trim_footnote_reference_space'] = \
|
||||
self.config.trim_footnote_reference_space
|
||||
self.settings['gettext_compact'] = self.config.gettext_compact
|
||||
language = (self.config.language or 'en').replace('_', '-')
|
||||
|
||||
language = self.config.language or 'en'
|
||||
self.settings['language_code'] = language
|
||||
if language in smartchars.quotes: # We enable smartypants by default
|
||||
self.settings['smart_quotes'] = True
|
||||
self.settings['smart_quotes'] = True
|
||||
for tag in normalize_language_tag(language):
|
||||
if tag in smartchars.quotes:
|
||||
break
|
||||
else:
|
||||
self.settings['smart_quotes'] = False
|
||||
|
||||
docutilsconf = path.join(self.srcdir, 'docutils.conf')
|
||||
# read docutils.conf from source dir, not from current dir
|
||||
|
@ -23,7 +23,7 @@ from distutils.errors import DistutilsOptionError, DistutilsExecError # type: i
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.cmdline import handle_exception
|
||||
from sphinx.util.console import nocolor, color_terminal
|
||||
from sphinx.util.docutils import docutils_namespace
|
||||
from sphinx.util.docutils import docutils_namespace, patch_docutils
|
||||
from sphinx.util.osutil import abspath
|
||||
|
||||
if False:
|
||||
@ -183,7 +183,7 @@ class BuildDoc(Command):
|
||||
app = None
|
||||
|
||||
try:
|
||||
with docutils_namespace():
|
||||
with patch_docutils(), docutils_namespace():
|
||||
app = Sphinx(self.source_dir, self.config_dir,
|
||||
builder_target_dir, self.doctree_dir,
|
||||
builder, confoverrides, status_stream,
|
||||
|
@ -13,9 +13,11 @@ from __future__ import absolute_import
|
||||
import re
|
||||
import types
|
||||
from copy import copy
|
||||
from distutils.version import LooseVersion
|
||||
from contextlib import contextmanager
|
||||
|
||||
import docutils
|
||||
from docutils.languages import get_language
|
||||
from docutils.utils import Reporter
|
||||
from docutils.parsers.rst import directives, roles, convert_directive_function
|
||||
|
||||
@ -34,7 +36,7 @@ if False:
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
||||
|
||||
__version_info__ = tuple(map(int, docutils.__version__.split('.')))
|
||||
__version_info__ = tuple(LooseVersion(docutils.__version__).version)
|
||||
|
||||
|
||||
@contextmanager
|
||||
@ -51,6 +53,29 @@ def docutils_namespace():
|
||||
roles._roles = _roles
|
||||
|
||||
|
||||
def patched_get_language(language_code, reporter=None):
|
||||
# type: (unicode, Reporter) -> Any
|
||||
"""A wrapper for docutils.languages.get_language().
|
||||
|
||||
This ignores the second argument ``reporter`` to suppress warnings.
|
||||
refs: https://github.com/sphinx-doc/sphinx/issues/3788
|
||||
"""
|
||||
return get_language(language_code)
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_docutils():
|
||||
# type: () -> Iterator[None]
|
||||
"""Patch to docutils temporarily."""
|
||||
try:
|
||||
docutils.languages.get_language = patched_get_language
|
||||
|
||||
yield
|
||||
finally:
|
||||
# restore original implementations
|
||||
docutils.languages.get_language = get_language
|
||||
|
||||
|
||||
class ElementLookupError(Exception):
|
||||
pass
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
from sphinx.websupport import WebSupport
|
||||
try:
|
||||
sqlalchemy_missing = False
|
||||
import sqlalchemy # NOQA
|
||||
except ImportError:
|
||||
sqlalchemy_missing = True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user