Skip to content

Commit 7945aeb

Browse files
authored
LaTeX: fix 5.1.0 bugs related to topic and contents boxes (#11102)
* Fix #11095 (PDF wrong placement of shadow of topic boxes since 5.1.0) * Fix #11096 (LaTeX shadowsize regression at 5.1.0) * Fix #11099 (shadowrule legacy sphinxsetup key vanished at 5.1.0) * Fix #11101 (LaTeX div.topic_padding of sphinxsetup had wrong name) * Add some checks that various sphinxsetup keys do not break PDF build * Update LaTeX docs * Update CHANGES * Can not use :dudir:`contents` has it links to wrong place
1 parent 77aaa86 commit 7945aeb

File tree

5 files changed

+135
-18
lines changed

5 files changed

+135
-18
lines changed

CHANGES

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
Release 6.1.2 (in development)
2+
==============================
3+
4+
Bugs fixed
5+
----------
6+
7+
* #11101: LaTeX: ``div.topic_padding`` key of sphinxsetup documented at 5.1.0 was
8+
implemented with name ``topic_padding``
9+
* #11099: LaTeX: ``shadowrule`` key of sphinxsetup causes PDF build to crash
10+
since Sphinx 5.1.0
11+
* #11096: LaTeX: ``shadowsize`` key of sphinxsetup causes PDF build to crash
12+
since Sphinx 5.1.0
13+
* #11095: LaTeX: shadow of :dudir:`topic` and contents_ boxes not in page
14+
margin since Sphinx 5.1.0
15+
16+
.. _contents: https://docutils.sourceforge.io/docs/ref/rst/directives.html#table-of-contents
17+
118
Release 6.1.1 (released Jan 05, 2023)
219
=====================================
320

doc/latex.rst

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -933,26 +933,43 @@ Do not use quotes to enclose values, whether numerical or strings.
933933
``verbatimsep``
934934
The separation between code lines and the frame.
935935

936+
See :ref:`additionalcss` for its alias ``pre_padding`` and
937+
additional keys.
938+
936939
Default: ``\fboxsep``
937940

938941
``verbatimborder``
939-
The width of the frame around :rst:dir:`code-block`\ s.
942+
The width of the frame around :rst:dir:`code-block`\ s. See also
943+
:ref:`additionalcss` for ``pre_border-width``.
940944

941945
Default: ``\fboxrule``
942946

943947
``shadowsep``
944-
The separation between contents and frame for :dudir:`contents` and
948+
The separation between contents and frame for contents_ and
945949
:dudir:`topic` boxes.
946950

951+
See :ref:`additionalcss` for the alias ``div.topic_padding``.
952+
947953
Default: ``5pt``
948954

955+
.. _contents: https://docutils.sourceforge.io/docs/ref/rst/directives.html#table-of-contents
956+
949957
``shadowsize``
950958
The width of the lateral "shadow" to the right and bottom.
951959

960+
See :ref:`additionalcss` for ``div.topic_box-shadow`` which allows to
961+
configure separately the widths of the vertical and horizontal shadows.
962+
952963
Default: ``4pt``
953964

965+
.. versionchanged:: 6.1.2
966+
Fixed a regression introduced at `5.1.0` which modified unintentionally
967+
the width of topic boxes and worse had made usage of this key break PDF
968+
builds.
969+
954970
``shadowrule``
955-
The width of the frame around :dudir:`topic` boxes.
971+
The width of the frame around :dudir:`topic` boxes. See also
972+
:ref:`additionalcss` for ``div.topic_border-width``.
956973

957974
Default: ``\fboxrule``
958975

@@ -987,7 +1004,9 @@ Do not use quotes to enclose values, whether numerical or strings.
9871004
Default: ``{rgb}{1,1,1}`` (white)
9881005

9891006
|warningborders|
990-
The width of the frame.
1007+
The width of the frame. See
1008+
:ref:`additionalcss` for keys allowing to configure separately each
1009+
border width.
9911010

9921011
Default: ``1pt``
9931012

@@ -1146,6 +1165,10 @@ Options for topic boxes:
11461165
| ``div.topic_padding-left``,
11471166
| ``div.topic_padding``,
11481167
again this is a single dimension. Its default is ``5pt``.
1168+
1169+
.. versionchanged:: 6.1.2
1170+
These keys had been implemented at 5.1.0 without ``div.`` in
1171+
their names.
11491172
- | ``div.topic_border-top-left-radius``,
11501173
| ``div.topic_border-top-right-radius``,
11511174
| ``div.topic_border-bottom-right-radius``,
@@ -1439,7 +1462,7 @@ Environments
14391462

14401463
.. versionadded:: 6.1.0
14411464

1442-
- The :dudir:`contents` directive (with ``:local:`` option) and the
1465+
- The contents_ directive (with ``:local:`` option) and the
14431466
:dudir:`topic` directive are implemented by environment ``sphinxShadowBox``.
14441467

14451468
.. versionadded:: 1.4.2

sphinx/texinputs/sphinx.sty

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
%
77

88
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
9-
\ProvidesPackage{sphinx}[2023/01/03 v6.1.0 LaTeX package (Sphinx markup)]
9+
\ProvidesPackage{sphinx}[2023/01/06 v6.1.2 LaTeX package (Sphinx markup)]
1010

1111
% provides \ltx@ifundefined
1212
% (many packages load ltxcmds: graphicx does for pdftex and lualatex but
@@ -436,7 +436,7 @@ will be set to white}%
436436
\let\spx@topic@border@bottom\spx@topic@border@top
437437
\let\spx@topic@border@left \spx@topic@border@top
438438
\expandafter\let\expandafter\KV@sphinx@shadowrule
439-
\csname KV@sphinx@topic_border-width\endcsname
439+
\csname KV@sphinx@div.topic_border-width\endcsname
440440
\newif\ifspx@topic@border@open % defaults to false (legacy)
441441
\define@key{sphinx}{div.topic_box-decoration-break}%
442442
{\begingroup\edef\spx@tempa{#1}\expandafter\endgroup
@@ -445,11 +445,13 @@ will be set to white}%
445445
\else\spx@topic@border@opentrue\fi}%
446446
%
447447
% MEMO: \sphinxshadowsep not used anywhere anymore in code base and to be removed
448-
\define@key{sphinx}{topic_padding-top}{\def\spx@topic@padding@top{#1}}
449-
\define@key{sphinx}{topic_padding-right}{\def\spx@topic@padding@right{#1}}
450-
\define@key{sphinx}{topic_padding-bottom}{\def\spx@topic@padding@bottom{#1}}
451-
\define@key{sphinx}{topic_padding-left}{\def\spx@topic@padding@left{#1}}
452-
\define@key{sphinx}{topic_padding}{%
448+
% Sadly the 5.1.0 definitions forgot the "div." part of the key names
449+
% Fixed at 6.1.2
450+
\define@key{sphinx}{div.topic_padding-top}{\def\spx@topic@padding@top{#1}}
451+
\define@key{sphinx}{div.topic_padding-right}{\def\spx@topic@padding@right{#1}}
452+
\define@key{sphinx}{div.topic_padding-bottom}{\def\spx@topic@padding@bottom{#1}}
453+
\define@key{sphinx}{div.topic_padding-left}{\def\spx@topic@padding@left{#1}}
454+
\define@key{sphinx}{div.topic_padding}{%
453455
\def\spx@topic@padding@top {#1}%
454456
\let\spx@topic@padding@right \spx@topic@padding@top
455457
\let\spx@topic@padding@bottom\spx@topic@padding@top
@@ -460,7 +462,7 @@ will be set to white}%
460462
\let\spx@topic@padding@bottom\spx@topic@padding@top
461463
\let\spx@topic@padding@left \spx@topic@padding@top
462464
\expandafter\let\expandafter\KV@sphinx@shadowsep
463-
\csname KV@sphinx@topic_padding\endcsname
465+
\csname KV@sphinx@div.topic_padding\endcsname
464466
%
465467
\define@key{sphinx}{div.topic_border-top-left-radius}{\def\spx@topic@radius@topleft{#1}}
466468
\define@key{sphinx}{div.topic_border-top-right-radius}{\def\spx@topic@radius@topright{#1}}
@@ -504,14 +506,15 @@ will be set to white}%
504506
\spx@topic@box@shadow@setter 4pt 4pt {} \@nnil
505507
% Suport for legacy shadowsize, the \sphinxshadowsize \dimen register
506508
% is not used anymore and should not even be allocated in future
509+
% This definition was broken at 5.1.0 and fixed at 6.1.2
507510
\define@key{sphinx}{shadowsize}{%
508511
\edef\spx@topic@shadow@xoffset{\number\dimexpr#1\relax sp}%
509512
\let\spx@topic@shadow@yoffset\spx@topic@shadow@xoffset
510513
\ifdim\spx@topic@shadow@xoffset=\z@
511-
\spx@topic@box@withshadowtrue
514+
\spx@topic@withshadowfalse
512515
\else
513-
\spx@topic@box@withshadowfalse
514-
\spx@topic@box@shadow@insetfalse
516+
\spx@topic@withshadowtrue
517+
\spx@topic@insetshadowfalse
515518
\fi
516519
}%
517520
\definecolor{sphinxTopicBorderColor}{rgb}{0,0,0}

sphinx/texinputs/sphinxlatexshadowbox.sty

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%% TOPIC AND CONTENTS BOXES
22
%
33
% change this info string if making any custom modification
4-
\ProvidesFile{sphinxlatexshadowbox.sty}[2022/07/03 sphinxShadowBox]
4+
\ProvidesFile{sphinxlatexshadowbox.sty}[2023/01/06 sphinxShadowBox]
55

66
% Provides support for this output mark-up from Sphinx latex writer:
77
%
@@ -89,7 +89,9 @@
8989
\fi
9090
\ifspx@topic@withshadow
9191
\ifspx@topic@insetshadow\else
92-
\ifdim\spx@topic@shadow@xoffset>\z@\hskip\spx@topic@shadow@xoffset\relax
92+
% A strangely unnoticed 5.1.0 breakage of the legacy placement of the
93+
% shadow was caused by a lacking minus sign here, fixed at 6.1.2
94+
\ifdim\spx@topic@shadow@xoffset>\z@\hskip-\spx@topic@shadow@xoffset\relax
9395
\fi
9496
\fi
9597
\fi

tests/roots/test-root/conf.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,78 @@
3838
html_context = {'hckey': 'hcval', 'hckey_co': 'wrong_hcval_co'}
3939

4040
latex_additional_files = ['svgimg.svg']
41+
# some random pdf layout parameters to check they don't break build
42+
latex_elements = {
43+
'sphinxsetup': """
44+
verbatimwithframe,
45+
verbatimwrapslines,
46+
verbatimforcewraps,
47+
verbatimmaxoverfull=1,
48+
verbatimmaxunderfull=5,
49+
verbatimhintsturnover=true,
50+
verbatimcontinuesalign=l,
51+
VerbatimColor={RGB}{242,242,242},
52+
VerbatimBorderColor={RGB}{32,32,32},
53+
VerbatimHighlightColor={RGB}{200,200,200},
54+
pre_box-decoration-break=slice,
55+
pre_border-top-left-radius=20pt,
56+
pre_border-top-right-radius=0pt,
57+
pre_border-bottom-right-radius=20pt,
58+
pre_border-bottom-left-radius=0pt,
59+
verbatimsep=1pt,
60+
pre_padding=5pt,% alias to verbatimsep
61+
pre_border-top-width=5pt,
62+
pre_border-right-width=10pt,
63+
pre_border-bottom-width=15pt,
64+
pre_border-left-width=20pt,
65+
pre_border-width=3pt,% overrides all previous four
66+
verbatimborder=2pt,% alias to pre_border-width
67+
%
68+
shadowrule=1pt,
69+
shadowsep=10pt,
70+
shadowsize=10pt,
71+
div.topic_border-width=2pt,% alias to shadowrule
72+
div.topic_padding=6pt,% alias to shadowsep
73+
div.topic_box-shadow=5pt,% overrides/alias shadowsize
74+
%
75+
noteBorderColor={RGB}{204,204,204},
76+
hintBorderColor={RGB}{204,204,204},
77+
importantBorderColor={RGB}{204,204,204},
78+
tipBorderColor={RGB}{204,204,204},
79+
%
80+
noteborder=5pt,
81+
hintborder=5pt,
82+
importantborder=5pt,
83+
tipborder=5pt,
84+
%
85+
warningborder=3pt,
86+
cautionborder=3pt,
87+
attentionborder=3pt,
88+
errorborder=3pt,
89+
%
90+
dangerborder=3pt,
91+
div.danger_border-width=10pt,
92+
div.danger_background-TeXcolor={rgb}{0,1,0},
93+
div.danger_border-TeXcolor={rgb}{0,0,1},
94+
div.danger_box-shadow=20pt -20pt,
95+
div.danger_box-shadow-TeXcolor={rgb}{0.5,0.5,0.5},
96+
%
97+
warningBorderColor={RGB}{255,119,119},
98+
cautionBorderColor={RGB}{255,119,119},
99+
attentionBorderColor={RGB}{255,119,119},
100+
dangerBorderColor={RGB}{255,119,119},
101+
errorBorderColor={RGB}{255,119,119},
102+
warningBgColor={RGB}{255,238,238},
103+
cautionBgColor={RGB}{255,238,238},
104+
attentionBgColor={RGB}{255,238,238},
105+
dangerBgColor={RGB}{255,238,238},
106+
errorBgColor={RGB}{255,238,238},
107+
%
108+
TableRowColorHeader={rgb}{0,1,0},
109+
TableRowColorOdd={rgb}{0.5,0,0},
110+
TableRowColorEven={rgb}{0.1,0.1,0.1},
111+
""",
112+
}
41113

42114
coverage_c_path = ['special/*.h']
43115
coverage_c_regexes = {'function': r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)'}

0 commit comments

Comments
 (0)