LaTeX: `\sphinxstyletheadfamily` to allow multiparagraph headers

Deprecate ``\sphinxstylethead`` at 1.6 with removal at 1.7.
This commit is contained in:
jfbu 2017-05-07 10:40:07 +02:00
parent df002416b6
commit e02f3f12b8
4 changed files with 29 additions and 13 deletions

View File

@ -11,6 +11,9 @@ Incompatible changes
Deprecated
----------
* LaTeX ``\sphinxstylethead`` is deprecated at 1.6 and will be removed at 1.7.
Please move customization into new macro ``\sphinxstyletheadfamily``.
Features added
--------------
@ -33,6 +36,7 @@ Bugs fixed
* #3714: viewcode extension not taking ``highlight_code='none'`` in account
* #3698: Moving :doc: to std domain broke backwards compatibility
* #3633: misdetect unreferenced citations
* LaTeX tables do not allow multiple paragraphs in a header cell
Testing
--------

View File

@ -1402,7 +1402,17 @@
\let\sphinxstylesidebartitle\sphinxstyletopictitle
\protected\def\sphinxstyleothertitle {\textbf}
\protected\def\sphinxstylesidebarsubtitle #1{~\\\textbf{#1} \smallskip}
\protected\def\sphinxstylethead {\textsf}
% \text.. commands do not allow multiple paragraphs
\let\sphinxstylethead\empty
\protected\def\sphinxstyletheadfamily {\ifx\sphinxstylethead\empty\sffamily\fi}
\AtBeginDocument{\ifx\sphinxstylethead\empty\else
\sphinxdeprecationwarning{\sphinxstylethead}{1.6}{1.7}{%
\string\sphinxstyletheadfamily\space replaces it
(it defaults to \string\sffamily) to allow use^^J
with multiple paragraphs. Backwards compatibility is maintained, but please^^J
move customization into \string\sphinxstyletheadfamily\space
in time for 1.7.^^J
And if you do it now, you will spare yourself this warning!}\fi}
\protected\def\sphinxstyleemphasis {\emph}
\protected\def\sphinxstyleliteralemphasis#1{\emph{\sphinxcode{#1}}}
\protected\def\sphinxstylestrong {\textbf}

View File

@ -1448,7 +1448,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
if len(node) == 1 and isinstance(node[0], nodes.paragraph) and node.astext() == '':
pass
else:
self.body.append('\\sphinxstylethead{\\relax ')
self.body.append('\\sphinxstylethead{\\sphinxstyletheadfamily ')
context = '\\unskip}\\relax ' + context
if self.needs_linetrimming:
self.pushbody([])

View File

@ -858,8 +858,9 @@ def test_latex_table_tabulars(app, status, warning):
assert ('\\begin{savenotes}\\sphinxattablestart\n\\centering\n'
'\\begin{tabulary}{\\linewidth}[t]{|T|T|}' in table)
assert ('\\hline\n'
'\\sphinxstylethead{\\relax \nheader1\n\\unskip}\\relax &'
'\\sphinxstylethead{\\relax \nheader2\n\\unskip}\\relax' in table)
'\\sphinxstylethead{\\sphinxstyletheadfamily \nheader1\n\\unskip}\\relax &'
'\\sphinxstylethead{\\sphinxstyletheadfamily \nheader2\n\\unskip}\\relax'
in table)
assert ('\\hline\ncell1-1\n&\ncell1-2\n\\\\' in table)
assert ('\\hline\ncell2-1\n&\ncell2-2\n\\\\' in table)
assert ('\\hline\ncell3-1\n&\ncell3-2\n\\\\' in table)
@ -930,15 +931,15 @@ def test_latex_table_longtable(app, status, warning):
assert ('\\begin{savenotes}\\sphinxatlongtablestart'
'\\begin{longtable}{|l|l|}\n\\hline' in table)
assert ('\\hline\n'
'\\sphinxstylethead{\\relax \nheader1\n\\unskip}\\relax &'
'\\sphinxstylethead{\\relax \nheader2\n\\unskip}\\relax \\\\\n'
'\\hline\n\\endfirsthead' in table)
'\\sphinxstylethead{\\sphinxstyletheadfamily \nheader1\n\\unskip}\\relax &'
'\\sphinxstylethead{\\sphinxstyletheadfamily \nheader2\n\\unskip}\\relax '
'\\\\\n\\hline\n\\endfirsthead' in table)
assert ('\\multicolumn{2}{c}%\n'
'{\\makebox[0pt]{\\sphinxtablecontinued{\\tablename\\ \\thetable{} -- '
'continued from previous page}}}\\\\\n\\hline\n'
'\\sphinxstylethead{\\relax \nheader1\n\\unskip}\\relax &'
'\\sphinxstylethead{\\relax \nheader2\n\\unskip}\\relax \\\\\n'
'\\hline\n\\endhead' in table)
'\\sphinxstylethead{\\sphinxstyletheadfamily \nheader1\n\\unskip}\\relax &'
'\\sphinxstylethead{\\sphinxstyletheadfamily \nheader2\n\\unskip}\\relax '
'\\\\\n\\hline\n\\endhead' in table)
assert ('\\hline\n\\multicolumn{2}{r}'
'{\\makebox[0pt][r]{\\sphinxtablecontinued{Continued on next page}}}\\\\\n'
'\\endfoot\n\n\\endlastfoot' in table)
@ -995,9 +996,10 @@ def test_latex_table_complex_tables(app, status, warning):
table = tables['grid table']
assert ('\\begin{tabulary}{\\linewidth}[t]{|T|T|T|}' in table)
assert ('\\hline\n'
'\\sphinxstylethead{\\relax \nheader1\n\\unskip}\\relax &'
'\\sphinxstylethead{\\relax \nheader2\n\\unskip}\\relax &'
'\\sphinxstylethead{\\relax \nheader3\n\\unskip}\\relax \\\\' in table)
'\\sphinxstylethead{\\sphinxstyletheadfamily \nheader1\n\\unskip}\\relax &'
'\\sphinxstylethead{\\sphinxstyletheadfamily \nheader2\n\\unskip}\\relax &'
'\\sphinxstylethead{\\sphinxstyletheadfamily \nheader3\n\\unskip}\\relax '
'\\\\' in table)
assert ('\\hline\ncell1-1\n&\\sphinxmultirow{2}{5}{%\n\\begin{varwidth}[t]'
'{\\sphinxcolwidth{1}{3}}\n'
'cell1-2\n\\par\n' in table)