mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Deprecate sphinx.writers.latex.ExtBabel.get_shorthandoff()
This partially reverts d17f3955a5
This commit is contained in:
parent
a32c358342
commit
b41b1dac5c
@ -216,6 +216,11 @@ The following is a list of deprecated interface.
|
|||||||
- 3.0
|
- 3.0
|
||||||
- N/A
|
- N/A
|
||||||
|
|
||||||
|
* - ``sphinx.writers.latex.ExtBabel.get_shorthandoff()``
|
||||||
|
- 1.8
|
||||||
|
- 2.0
|
||||||
|
- N/A
|
||||||
|
|
||||||
* - ``sphinx.application.CONFIG_FILENAME``
|
* - ``sphinx.application.CONFIG_FILENAME``
|
||||||
- 1.8
|
- 1.8
|
||||||
- 3.0
|
- 3.0
|
||||||
|
@ -2114,6 +2114,7 @@ information.
|
|||||||
``'author'``
|
``'author'``
|
||||||
``'logo'``
|
``'logo'``
|
||||||
``'makeindex'``
|
``'makeindex'``
|
||||||
|
``'shorthandoff'``
|
||||||
|
|
||||||
.. confval:: latex_docclass
|
.. confval:: latex_docclass
|
||||||
|
|
||||||
|
@ -44,14 +44,17 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
BEGIN_DOC = r'''
|
BEGIN_DOC = r'''
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\ifdefined\shorthandoff
|
%(shorthandoff)s
|
||||||
\ifnum\catcode`\=\string=\active\shorthandoff{=}\fi
|
|
||||||
\ifnum\catcode`\"=\active\shorthandoff{"}\fi
|
|
||||||
\fi
|
|
||||||
%(maketitle)s
|
%(maketitle)s
|
||||||
%(tableofcontents)s
|
%(tableofcontents)s
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
SHORTHANDOFF = r'''
|
||||||
|
\ifdefined\shorthandoff
|
||||||
|
\ifnum\catcode`\=\string=\active\shorthandoff{=}\fi
|
||||||
|
\ifnum\catcode`\"=\active\shorthandoff{"}\fi
|
||||||
|
\fi
|
||||||
|
'''
|
||||||
|
|
||||||
MAX_CITATION_LABEL_LENGTH = 8
|
MAX_CITATION_LABEL_LENGTH = 8
|
||||||
LATEXSECTIONNAMES = ["part", "chapter", "section", "subsection",
|
LATEXSECTIONNAMES = ["part", "chapter", "section", "subsection",
|
||||||
@ -104,6 +107,7 @@ DEFAULT_SETTINGS = {
|
|||||||
'logo': '\\vbox{}',
|
'logo': '\\vbox{}',
|
||||||
'releasename': '',
|
'releasename': '',
|
||||||
'makeindex': '\\makeindex',
|
'makeindex': '\\makeindex',
|
||||||
|
'shorthandoff': '',
|
||||||
'maketitle': '\\maketitle',
|
'maketitle': '\\maketitle',
|
||||||
'tableofcontents': '\\sphinxtableofcontents',
|
'tableofcontents': '\\sphinxtableofcontents',
|
||||||
'atendofbody': '',
|
'atendofbody': '',
|
||||||
@ -201,16 +205,6 @@ class LaTeXWriter(writers.Writer):
|
|||||||
|
|
||||||
class ExtBabel(Babel):
|
class ExtBabel(Babel):
|
||||||
cyrillic_languages = ('bulgarian', 'kazakh', 'mongolian', 'russian', 'ukrainian')
|
cyrillic_languages = ('bulgarian', 'kazakh', 'mongolian', 'russian', 'ukrainian')
|
||||||
shorthands = {
|
|
||||||
'ngerman': '"',
|
|
||||||
'slovene': '"',
|
|
||||||
'portuges': '"',
|
|
||||||
'brazil': '"',
|
|
||||||
'spanish': '"',
|
|
||||||
'dutch': '"',
|
|
||||||
'polish': '"',
|
|
||||||
'italian': '"',
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, language_code, use_polyglossia=False):
|
def __init__(self, language_code, use_polyglossia=False):
|
||||||
# type: (unicode, bool) -> None
|
# type: (unicode, bool) -> None
|
||||||
@ -219,6 +213,12 @@ class ExtBabel(Babel):
|
|||||||
self.supported = True
|
self.supported = True
|
||||||
super(ExtBabel, self).__init__(language_code or '')
|
super(ExtBabel, self).__init__(language_code or '')
|
||||||
|
|
||||||
|
def get_shorthandoff(self):
|
||||||
|
# type: () -> unicode
|
||||||
|
warnings.warn('ExtBabel.get_shorthandoff() is deprecated.',
|
||||||
|
RemovedInSphinx20Warning)
|
||||||
|
return SHORTHANDOFF
|
||||||
|
|
||||||
def uses_cyrillic(self):
|
def uses_cyrillic(self):
|
||||||
# type: () -> bool
|
# type: () -> bool
|
||||||
return self.language in self.cyrillic_languages
|
return self.language in self.cyrillic_languages
|
||||||
@ -574,6 +574,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
# this branch is not taken for xelatex/lualatex if default settings
|
# this branch is not taken for xelatex/lualatex if default settings
|
||||||
self.elements['multilingual'] = self.elements['babel']
|
self.elements['multilingual'] = self.elements['babel']
|
||||||
if builder.config.language:
|
if builder.config.language:
|
||||||
|
self.elements['shorthandoff'] = SHORTHANDOFF
|
||||||
|
|
||||||
# Times fonts don't work with Cyrillic languages
|
# Times fonts don't work with Cyrillic languages
|
||||||
if self.babel.uses_cyrillic() \
|
if self.babel.uses_cyrillic() \
|
||||||
@ -586,6 +587,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.elements['classoptions'] = ',dvipdfmx'
|
self.elements['classoptions'] = ',dvipdfmx'
|
||||||
# disable babel which has not publishing quality in Japanese
|
# disable babel which has not publishing quality in Japanese
|
||||||
self.elements['babel'] = ''
|
self.elements['babel'] = ''
|
||||||
|
self.elements['shorthandoff'] = ''
|
||||||
self.elements['multilingual'] = ''
|
self.elements['multilingual'] = ''
|
||||||
# disable fncychap in Japanese documents
|
# disable fncychap in Japanese documents
|
||||||
self.elements['fncychap'] = ''
|
self.elements['fncychap'] = ''
|
||||||
|
@ -424,6 +424,7 @@ def test_babel_with_no_language_settings(app, status, warning):
|
|||||||
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
|
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
|
||||||
|
assert '\\shorthandoff' not in result
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -444,6 +445,7 @@ def test_babel_with_language_de(app, status, warning):
|
|||||||
assert '\\addto\\captionsngerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsngerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsngerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsngerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\addto\\extrasngerman{\\def\\pageautorefname{Seite}}\n' in result
|
assert '\\addto\\extrasngerman{\\def\\pageautorefname{Seite}}\n' in result
|
||||||
|
assert '\\shorthandoff{"}' in result
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -465,6 +467,7 @@ def test_babel_with_language_ru(app, status, warning):
|
|||||||
assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert (u'\\addto\\extrasrussian{\\def\\pageautorefname'
|
assert (u'\\addto\\extrasrussian{\\def\\pageautorefname'
|
||||||
u'{\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430}}\n' in result)
|
u'{\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430}}\n' in result)
|
||||||
|
assert '\\shorthandoff{"}' in result
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -485,6 +488,7 @@ def test_babel_with_language_tr(app, status, warning):
|
|||||||
assert '\\addto\\captionsturkish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsturkish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsturkish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsturkish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\addto\\extrasturkish{\\def\\pageautorefname{sayfa}}\n' in result
|
assert '\\addto\\extrasturkish{\\def\\pageautorefname{sayfa}}\n' in result
|
||||||
|
assert '\\shorthandoff{=}' in result
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -504,6 +508,7 @@ def test_babel_with_language_ja(app, status, warning):
|
|||||||
assert '\\renewcommand{\\figurename}{Fig.}\n' in result
|
assert '\\renewcommand{\\figurename}{Fig.}\n' in result
|
||||||
assert '\\renewcommand{\\tablename}{Table.}\n' in result
|
assert '\\renewcommand{\\tablename}{Table.}\n' in result
|
||||||
assert u'\\def\\pageautorefname{ページ}\n' in result
|
assert u'\\def\\pageautorefname{ページ}\n' in result
|
||||||
|
assert '\\shorthandoff' not in result
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -524,6 +529,7 @@ def test_babel_with_unknown_language(app, status, warning):
|
|||||||
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
|
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
|
||||||
|
assert '\\shorthandoff' in result
|
||||||
|
|
||||||
assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue()
|
assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue()
|
||||||
|
|
||||||
@ -547,6 +553,7 @@ def test_polyglossia_with_language_de(app, status, warning):
|
|||||||
assert '\\addto\\captionsgerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsgerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsgerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsgerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\def\\pageautorefname{Seite}\n' in result
|
assert '\\def\\pageautorefname{Seite}\n' in result
|
||||||
|
assert '\\shorthandoff' not in result
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -568,6 +575,7 @@ def test_polyglossia_with_language_de_1901(app, status, warning):
|
|||||||
assert '\\addto\\captionsgerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsgerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsgerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsgerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\def\\pageautorefname{page}\n' in result
|
assert '\\def\\pageautorefname{page}\n' in result
|
||||||
|
assert '\\shorthandoff' not in result
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('latex')
|
@pytest.mark.sphinx('latex')
|
||||||
|
Loading…
Reference in New Issue
Block a user