mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #3813 from jfbu/3788_docutils_language_warnings
Fix #3788: Docutils emits warnings for unsupported languages
This commit is contained in:
commit
402e0bc706
1
CHANGES
1
CHANGES
@ -34,6 +34,7 @@ Bugs fixed
|
|||||||
* #3796: env.resolve_references() crashes when non-document node given
|
* #3796: env.resolve_references() crashes when non-document node given
|
||||||
* #3803: Sphinx crashes with invalid PO files
|
* #3803: Sphinx crashes with invalid PO files
|
||||||
* #3791: PDF "continued on next page" for long tables isn't internationalized
|
* #3791: PDF "continued on next page" for long tables isn't internationalized
|
||||||
|
* #3788: smartquotes emits warnings for unsupported languages
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -22,7 +22,9 @@ from collections import deque
|
|||||||
from six import iteritems
|
from six import iteritems
|
||||||
from six.moves import cStringIO
|
from six.moves import cStringIO
|
||||||
|
|
||||||
|
import docutils
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
|
from docutils.languages import get_language as docutils_get_language
|
||||||
from docutils.parsers.rst import directives, roles
|
from docutils.parsers.rst import directives, roles
|
||||||
|
|
||||||
import sphinx
|
import sphinx
|
||||||
@ -106,6 +108,14 @@ ENV_PICKLE_FILENAME = 'environment.pickle'
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
# monkey patch docutils get_language
|
||||||
|
def patched_docutils_get_language(language_code, reporter=None): # NOQA
|
||||||
|
return docutils_get_language(language_code)
|
||||||
|
|
||||||
|
|
||||||
|
docutils.languages.get_language = patched_docutils_get_language
|
||||||
|
|
||||||
|
|
||||||
class Sphinx(object):
|
class Sphinx(object):
|
||||||
|
|
||||||
def __init__(self, srcdir, confdir, outdir, doctreedir, buildername,
|
def __init__(self, srcdir, confdir, outdir, doctreedir, buildername,
|
||||||
|
@ -25,7 +25,7 @@ from six.moves import cPickle as pickle
|
|||||||
|
|
||||||
from docutils.io import NullOutput
|
from docutils.io import NullOutput
|
||||||
from docutils.core import Publisher
|
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.utils.smartquotes import smartchars
|
||||||
from docutils.parsers.rst import roles
|
from docutils.parsers.rst import roles
|
||||||
from docutils.parsers.rst.languages import en as english
|
from docutils.parsers.rst.languages import en as english
|
||||||
@ -672,18 +672,22 @@ class BuildEnvironment(object):
|
|||||||
self.settings['trim_footnote_reference_space'] = \
|
self.settings['trim_footnote_reference_space'] = \
|
||||||
self.config.trim_footnote_reference_space
|
self.config.trim_footnote_reference_space
|
||||||
self.settings['gettext_compact'] = self.config.gettext_compact
|
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
|
self.settings['language_code'] = language
|
||||||
|
self.settings['smart_quotes'] = True
|
||||||
if self.config.html_use_smartypants is not None:
|
if self.config.html_use_smartypants is not None:
|
||||||
warnings.warn("html_use_smartypants option is deprecated. Smart "
|
warnings.warn("html_use_smartypants option is deprecated. Smart "
|
||||||
"quotes are on by default; if you want to disable "
|
"quotes are on by default; if you want to disable "
|
||||||
"or customize them, use the smart_quotes option in "
|
"or customize them, use the smart_quotes option in "
|
||||||
"docutils.conf.",
|
"docutils.conf.",
|
||||||
RemovedInSphinx17Warning)
|
RemovedInSphinx17Warning)
|
||||||
if language in smartchars.quotes:
|
self.settings['smart_quotes'] = self.config.html_use_smartypants
|
||||||
self.settings['smart_quotes'] = self.config.html_use_smartypants
|
for tag in normalize_language_tag(language):
|
||||||
elif language in smartchars.quotes: # We enable smartypants by default
|
if tag in smartchars.quotes:
|
||||||
self.settings['smart_quotes'] = True
|
break
|
||||||
|
else:
|
||||||
|
self.settings['smart_quotes'] = False
|
||||||
|
|
||||||
docutilsconf = path.join(self.srcdir, 'docutils.conf')
|
docutilsconf = path.join(self.srcdir, 'docutils.conf')
|
||||||
# read docutils.conf from source dir, not from current dir
|
# read docutils.conf from source dir, not from current dir
|
||||||
|
Loading…
Reference in New Issue
Block a user