mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
refactor: Move \tablename to sphinxmessage.sty
This commit is contained in:
parent
1c34501e85
commit
ebd484ead2
@ -422,6 +422,7 @@ class LaTeXBuilder(Builder):
|
||||
context = {
|
||||
'addtocaptions': '',
|
||||
'figurename': self.config.numfig_format.get('figure', '').split('%s', 1),
|
||||
'tablename': self.config.numfig_format.get('table', '').split('%s', 1)
|
||||
}
|
||||
|
||||
if self.context['babel'] or self.context['polyglossia']:
|
||||
|
@ -16,3 +16,8 @@
|
||||
<%- if figurename[1] %>
|
||||
\def\fnum@figure{\figurename\thefigure\relax{}<%= figurename[1].strip() | e %>}
|
||||
<%- endif %>
|
||||
|
||||
<%= addtocaptions %>{\renewcommand{\tablename}{<%= tablename[0].strip() %>}}
|
||||
<%- if tablename[1] %>
|
||||
\def\fnum@table{\tablename\thetable\relax{}<%= tablename[1].strip() | e %>}
|
||||
<%- endif %>
|
||||
|
@ -203,7 +203,6 @@ def test_numref(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table}}' in result
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Listing}}' in result
|
||||
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
||||
'{Fig.\\@ \\ref{\\detokenize{index:fig1}}}') in result
|
||||
@ -230,6 +229,7 @@ def test_numref(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -245,7 +245,6 @@ def test_numref_with_prefix1(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Tab\\_}}' in result
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Code-}}' in result
|
||||
assert '\\ref{\\detokenize{index:fig1}}' in result
|
||||
assert '\\ref{\\detokenize{baz:fig22}}' in result
|
||||
@ -278,6 +277,7 @@ def test_numref_with_prefix1(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Figure:}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Tab_}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -293,8 +293,6 @@ def test_numref_with_prefix2(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Tab\\_}}' in result
|
||||
assert '\\def\\fnum@table{\\tablename\\thetable:}' in result
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Code-}}' in result
|
||||
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
||||
'{Figure:\\ref{\\detokenize{index:fig1}}.\\@}') in result
|
||||
@ -322,6 +320,8 @@ def test_numref_with_prefix2(app, status, warning):
|
||||
print(result)
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Figure:}}' in result
|
||||
assert r'\def\fnum@figure{\figurename\thefigure\relax{}.}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Tab_}}' in result
|
||||
assert r'\def\fnum@table{\tablename\thetable\relax{}:}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -333,7 +333,6 @@ def test_numref_with_language_ja(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert '\\renewcommand{\\tablename}{\u8868}' in result # 表
|
||||
assert '\\renewcommand{\\literalblockname}{\u30ea\u30b9\u30c8}' in result # リスト
|
||||
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
||||
'{\u56f3 \\ref{\\detokenize{index:fig1}}}') in result
|
||||
@ -360,6 +359,7 @@ def test_numref_with_language_ja(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert '\n{\\renewcommand{\\figurename}{図}}' in result
|
||||
assert '\n{\\renewcommand{\\tablename}{表}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-numfig')
|
||||
@ -435,7 +435,6 @@ def test_babel_with_no_language_settings(app, status, warning):
|
||||
assert '\\usepackage[Bjarne]{fncychap}' in result
|
||||
assert ('\\addto\\captionsenglish{\\renewcommand{\\contentsname}{Table of content}}\n'
|
||||
in result)
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||
assert '\\shorthandoff' not in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
@ -443,6 +442,7 @@ def test_babel_with_no_language_settings(app, status, warning):
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{page}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table.}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -460,7 +460,6 @@ def test_babel_with_language_de(app, status, warning):
|
||||
assert '\\usepackage[Sonny]{fncychap}' in result
|
||||
assert ('\\addto\\captionsngerman{\\renewcommand{\\contentsname}{Table of content}}\n'
|
||||
in result)
|
||||
assert '\\addto\\captionsngerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||
assert '\\shorthandoff{"}' in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
@ -468,6 +467,7 @@ def test_babel_with_language_de(app, status, warning):
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{Seite}' in result
|
||||
assert r'\addto\captionsngerman{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsngerman{\renewcommand{\tablename}{Table.}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -485,7 +485,6 @@ def test_babel_with_language_ru(app, status, warning):
|
||||
assert '\\usepackage[Sonny]{fncychap}' in result
|
||||
assert ('\\addto\\captionsrussian{\\renewcommand{\\contentsname}{Table of content}}\n'
|
||||
in result)
|
||||
assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||
assert '\\shorthandoff{"}' in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
@ -493,6 +492,7 @@ def test_babel_with_language_ru(app, status, warning):
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{страница}' in result
|
||||
assert r'\addto\captionsrussian{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsrussian{\renewcommand{\tablename}{Table.}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -510,7 +510,6 @@ def test_babel_with_language_tr(app, status, warning):
|
||||
assert '\\usepackage[Sonny]{fncychap}' in result
|
||||
assert ('\\addto\\captionsturkish{\\renewcommand{\\contentsname}{Table of content}}\n'
|
||||
in result)
|
||||
assert '\\addto\\captionsturkish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||
assert '\\shorthandoff{=}' in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
@ -518,6 +517,7 @@ def test_babel_with_language_tr(app, status, warning):
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{sayfa}' in result
|
||||
assert r'\addto\captionsturkish{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsturkish{\renewcommand{\tablename}{Table.}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -534,7 +534,6 @@ def test_babel_with_language_ja(app, status, warning):
|
||||
assert '\\usepackage{times}' in result
|
||||
assert '\\usepackage[Sonny]{fncychap}' not in result
|
||||
assert '\\renewcommand{\\contentsname}{Table of content}\n' in result
|
||||
assert '\\renewcommand{\\tablename}{Table.}\n' in result
|
||||
assert '\\shorthandoff' not in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
@ -542,6 +541,7 @@ def test_babel_with_language_ja(app, status, warning):
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{ページ}' in result
|
||||
assert '\n{\\renewcommand{\\figurename}{Fig.}}' in result
|
||||
assert '\n{\\renewcommand{\\tablename}{Table.}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -559,7 +559,6 @@ def test_babel_with_unknown_language(app, status, warning):
|
||||
assert '\\usepackage[Sonny]{fncychap}' in result
|
||||
assert ('\\addto\\captionsenglish{\\renewcommand{\\contentsname}{Table of content}}\n'
|
||||
in result)
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||
assert '\\shorthandoff' in result
|
||||
|
||||
assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue()
|
||||
@ -569,6 +568,7 @@ def test_babel_with_unknown_language(app, status, warning):
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{page}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table.}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -587,7 +587,6 @@ def test_polyglossia_with_language_de(app, status, warning):
|
||||
assert '\\usepackage[Sonny]{fncychap}' in result
|
||||
assert ('\\addto\\captionsgerman{\\renewcommand{\\contentsname}{Table of content}}\n'
|
||||
in result)
|
||||
assert '\\addto\\captionsgerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||
assert '\\shorthandoff' not in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
@ -595,6 +594,7 @@ def test_polyglossia_with_language_de(app, status, warning):
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{Seite}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\tablename}{Table.}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -613,7 +613,6 @@ def test_polyglossia_with_language_de_1901(app, status, warning):
|
||||
assert '\\usepackage[Sonny]{fncychap}' in result
|
||||
assert ('\\addto\\captionsgerman{\\renewcommand{\\contentsname}{Table of content}}\n'
|
||||
in result)
|
||||
assert '\\addto\\captionsgerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||
assert '\\shorthandoff' not in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
@ -621,6 +620,7 @@ def test_polyglossia_with_language_de_1901(app, status, warning):
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{page}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\tablename}{Table.}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex')
|
||||
|
Loading…
Reference in New Issue
Block a user