mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #2629. Add new config option `latex_keep_old_macro_names
`
The cause of the issue was a clash about ``\titleref`` macro being already defined in memoir class context. To avoid similar problems, this makes the text styling macros ``\strong``, ``\code``, ``\bfcode``, ``\email``, ``\tablecontinued``, ``\titleref``, ``\menuselection``, ``\accelerator``, ``\crossref``, ``\termref``, ``\optional``, also available with ``\sphinx`` prefix, with a conf.py boolean option to let sphinx.sty only define ``\sphinx``-prefixed macros. As default value is False, backwards compatibility is maintained. On this occasion, some internal non-public macros have been renamed with prefix ``\spx@``. The command find . -name '*.sty' -exec grep -l \\\\spx@ {} \; has been executed in TeXLive 2015 and 2016 installations to check no package defines macros starting with ``\spx@``. Some internal macros having public names (because they are written by latex.py into the body of the latex document) have been renamed to have ``\sphinx`` prefix. The macros in sphinx.sty starting with \py@, or \DU, or \PYG have not been modified. Similarly ``\release``, ``\version``, ``\releasename``, etc... have not been renamed.
This commit is contained in:
parent
8608387585
commit
5510653d6e
6
CHANGES
6
CHANGES
@ -1,10 +1,16 @@
|
|||||||
Release 1.4.5 (in development)
|
Release 1.4.5 (in development)
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
|
Features added
|
||||||
|
--------------
|
||||||
|
|
||||||
|
* new config option ``latex_keep_old_macro_names``, defaults to True. If False, let macros (for text styling) be defined only with ``\sphinx``-prefixed names.
|
||||||
|
|
||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
* #2676: (latex) Error with verbatim text in captions since Sphinx 1.4.4
|
* #2676: (latex) Error with verbatim text in captions since Sphinx 1.4.4
|
||||||
|
* #2629: memoir class crashes LaTeX. Fixed ``by latex_keep_old_macro_names=False`` (ref 2675)
|
||||||
|
|
||||||
|
|
||||||
Release 1.4.4 (released Jun 12, 2016)
|
Release 1.4.4 (released Jun 12, 2016)
|
||||||
|
@ -1565,6 +1565,21 @@ These options influence LaTeX output.
|
|||||||
value selected the ``'inline'`` display. For backwards compatibility,
|
value selected the ``'inline'`` display. For backwards compatibility,
|
||||||
``True`` is still accepted.
|
``True`` is still accepted.
|
||||||
|
|
||||||
|
.. confval:: latex_keep_old_macro_names
|
||||||
|
|
||||||
|
If ``True`` (default) the ``\strong``, ``\code``, ``\bfcode``, ``\email``,
|
||||||
|
``\tablecontinued``, ``\titleref``, ``\menuselection``, ``\accelerator``,
|
||||||
|
``\crossref``, ``\termref``, and ``\optional`` text styling macros are
|
||||||
|
pre-defined by Sphinx and may be user-customized by some
|
||||||
|
``\renewcommand``'s inserted either via ``'preamble'`` key or :dudir:`raw
|
||||||
|
<raw-data-pass-through>` directive. If ``False``, only ``\sphinxstrong``,
|
||||||
|
etc... macros are defined (and may be redefined by user). Setting to
|
||||||
|
``False`` may help solve macro name conflicts caused by user-added latex
|
||||||
|
packages.
|
||||||
|
|
||||||
|
.. versionadded:: 1.4.5
|
||||||
|
|
||||||
|
|
||||||
.. confval:: latex_elements
|
.. confval:: latex_elements
|
||||||
|
|
||||||
.. versionadded:: 0.5
|
.. versionadded:: 0.5
|
||||||
|
@ -209,6 +209,7 @@ class Config(object):
|
|||||||
None),
|
None),
|
||||||
latex_logo = (None, None, string_classes),
|
latex_logo = (None, None, string_classes),
|
||||||
latex_appendices = ([], None),
|
latex_appendices = ([], None),
|
||||||
|
latex_keep_old_macro_names = (True, None),
|
||||||
# now deprecated - use latex_toplevel_sectioning
|
# now deprecated - use latex_toplevel_sectioning
|
||||||
latex_use_parts = (False, None),
|
latex_use_parts = (False, None),
|
||||||
latex_toplevel_sectioning = (None, None, [str]),
|
latex_toplevel_sectioning = (None, None, [str]),
|
||||||
|
@ -359,6 +359,12 @@ latex_documents = [
|
|||||||
#
|
#
|
||||||
# latex_appendices = []
|
# latex_appendices = []
|
||||||
|
|
||||||
|
# It false, will not define \strong, \code, \titleref, \crossref ... but only
|
||||||
|
# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added
|
||||||
|
# packages.
|
||||||
|
#
|
||||||
|
# latex_keep_old_macro_names = True
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#
|
#
|
||||||
# latex_domain_indices = True
|
# latex_domain_indices = True
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
\RequirePackage{makeidx}
|
\RequirePackage{makeidx}
|
||||||
% For framing code-blocks and warning type notices, and shadowing topics
|
% For framing code-blocks and warning type notices, and shadowing topics
|
||||||
\RequirePackage{framed}
|
\RequirePackage{framed}
|
||||||
\newif\ifSphinx@inframed % flag set if we are in a framed environment
|
\newif\ifspx@inframed % flag set if we are in a framed environment
|
||||||
% ifthen not used anymore and will be removed at Sphinx-1.5
|
% ifthen not used anymore and will be removed at Sphinx-1.5
|
||||||
\RequirePackage{ifthen}
|
\RequirePackage{ifthen}
|
||||||
% The xcolor package draws better fcolorboxes around verbatim code
|
% The xcolor package draws better fcolorboxes around verbatim code
|
||||||
@ -69,7 +69,7 @@
|
|||||||
\RequirePackage{graphicx}
|
\RequirePackage{graphicx}
|
||||||
|
|
||||||
% for PDF output, use colors and maximal compression
|
% for PDF output, use colors and maximal compression
|
||||||
\newif\ifsphinxpdfoutput\sphinxpdfoutputfalse
|
\newif\ifsphinxpdfoutput % used in \maketitle
|
||||||
\ifx\pdfoutput\undefined\else\ifcase\pdfoutput
|
\ifx\pdfoutput\undefined\else\ifcase\pdfoutput
|
||||||
\let\py@NormalColor\relax
|
\let\py@NormalColor\relax
|
||||||
\let\py@TitleColor\relax
|
\let\py@TitleColor\relax
|
||||||
@ -114,6 +114,7 @@
|
|||||||
|
|
||||||
% Use this to set the font family for headers and other decor:
|
% Use this to set the font family for headers and other decor:
|
||||||
\newcommand{\py@HeaderFamily}{\sffamily\bfseries}
|
\newcommand{\py@HeaderFamily}{\sffamily\bfseries}
|
||||||
|
\newcommand{\sphinxSetHeaderFamily}[1]{\renewcommand{\py@HeaderFamily}{#1}}
|
||||||
|
|
||||||
% Redefine the 'normal' header/footer style when using "fancyhdr" package:
|
% Redefine the 'normal' header/footer style when using "fancyhdr" package:
|
||||||
\@ifundefined{fancyhf}{}{
|
\@ifundefined{fancyhf}{}{
|
||||||
@ -143,23 +144,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
% Some custom font markup commands.
|
% Some custom font markup commands.
|
||||||
%
|
% *** the macros without \sphinx prefix are still defined at bottom of file ***
|
||||||
\newcommand{\strong}[1]{{\textbf{#1}}}
|
\newcommand{\sphinxstrong}[1]{{\textbf{#1}}}
|
||||||
% let \code and \bfcode use straight quotes. \@noligs patched by upquote,
|
% let \sphinxcode and \sphinxbfcode use straight quotes. \@noligs patched by upquote,
|
||||||
% but needs protection in "moving arguments" such as for captions.
|
% but needs protection in "moving arguments" such as for captions.
|
||||||
\newcommand{\code}{}% raise error if exists already
|
% Use \scantokens to handle e.g. \item[{\sphinxcode{'fontenc'}}]
|
||||||
\DeclareRobustCommand{\code}[1]{{\@noligs\scantokens{\texttt{#1}}}}
|
\DeclareRobustCommand{\sphinxcode}[1]{{\@noligs\scantokens{\texttt{#1}}}}
|
||||||
\newcommand{\bfcode}[1]{\code{\bfseries#1}}
|
\newcommand{\sphinxbfcode}[1]{\sphinxcode{\bfseries#1}}
|
||||||
\newcommand{\email}[1]{\textsf{#1}}
|
\newcommand{\sphinxemail}[1]{\textsf{#1}}
|
||||||
\newcommand{\tablecontinued}[1]{\textsf{#1}}
|
\newcommand{\sphinxtablecontinued}[1]{\textsf{#1}}
|
||||||
\newcommand{\titleref}[1]{\emph{#1}}
|
\newcommand{\sphinxtitleref}[1]{\emph{#1}}
|
||||||
\newcommand{\menuselection}[1]{\emph{#1}}
|
\newcommand{\sphinxmenuselection}[1]{\emph{#1}}
|
||||||
\newcommand{\accelerator}[1]{\underline{#1}}
|
\newcommand{\sphinxaccelerator}[1]{\underline{#1}}
|
||||||
\newcommand{\crossref}[1]{\emph{#1}}
|
\newcommand{\sphinxcrossref}[1]{\emph{#1}}
|
||||||
\newcommand{\termref}[1]{\emph{#1}}
|
\newcommand{\sphinxtermref}[1]{\emph{#1}}
|
||||||
|
|
||||||
|
% miscellaneous related to footnotes
|
||||||
\newcommand*{\sphinxAtStartFootnote}{\mbox{ }}
|
\newcommand*{\sphinxAtStartFootnote}{\mbox{ }}
|
||||||
|
|
||||||
% Support large numbered footnotes in minipage (cf. admonitions)
|
% Support large numbered footnotes in minipage (cf. admonitions)
|
||||||
\def\thempfootnote{\arabic{mpfootnote}}
|
\def\thempfootnote{\arabic{mpfootnote}}
|
||||||
|
|
||||||
@ -169,8 +170,8 @@
|
|||||||
\let\OriginalVerbatim=\Verbatim
|
\let\OriginalVerbatim=\Verbatim
|
||||||
\let\endOriginalVerbatim=\endVerbatim
|
\let\endOriginalVerbatim=\endVerbatim
|
||||||
|
|
||||||
\newcommand\Sphinx@colorbox [2]{%
|
\newcommand\spx@colorbox [2]{%
|
||||||
% #1 will be \fcolorbox or, for first part of frame: \Sphinx@fcolorbox
|
% #1 will be \fcolorbox or, for first part of frame: \spx@fcolorbox
|
||||||
% let the framing obey the current indentation (adapted from framed.sty's code).
|
% let the framing obey the current indentation (adapted from framed.sty's code).
|
||||||
\hskip\@totalleftmargin
|
\hskip\@totalleftmargin
|
||||||
\hskip-\fboxsep\hskip-\fboxrule
|
\hskip-\fboxsep\hskip-\fboxrule
|
||||||
@ -179,47 +180,46 @@
|
|||||||
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth
|
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth
|
||||||
}
|
}
|
||||||
% use of \color@b@x here is compatible with both xcolor.sty and color.sty
|
% use of \color@b@x here is compatible with both xcolor.sty and color.sty
|
||||||
\def\Sphinx@fcolorbox #1#2%
|
\def\spx@fcolorbox #1#2%
|
||||||
{\color@b@x {\fboxsep\z@\color{#1}\Sphinx@VerbatimFBox}{\color{#2}}}%
|
{\color@b@x {\fboxsep\z@\color{#1}\spx@VerbatimFBox}{\color{#2}}}%
|
||||||
|
|
||||||
% The title is specified from outside as macro \SphinxVerbatimTitle.
|
% The title is specified from outside as macro \sphinxVerbatimTitle.
|
||||||
% \SphinxVerbatimTitle is reset to empty after each use of Verbatim.
|
% \sphinxVerbatimTitle is reset to empty after each use of Verbatim.
|
||||||
\newcommand*\SphinxVerbatimTitle {}
|
\newcommand*\sphinxVerbatimTitle {}
|
||||||
% Holder macro for labels of literal blocks. Set-up by LaTeX writer.
|
% Holder macro for labels of literal blocks. Set-up by LaTeX writer.
|
||||||
\newcommand*\SphinxLiteralBlockLabel {}
|
\newcommand*\sphinxLiteralBlockLabel {}
|
||||||
\newcommand*\SphinxSetupCaptionForVerbatim [2]
|
\newcommand*\sphinxSetupCaptionForVerbatim [2]
|
||||||
{%
|
{%
|
||||||
\needspace{\literalblockneedspace}%
|
\needspace{\sphinxliteralblockneedspace}%
|
||||||
% insert a \label via \SphinxLiteralBlockLabel
|
% insert a \label via \sphinxLiteralBlockLabel
|
||||||
% reset to normal the color for the literal block caption
|
% reset to normal the color for the literal block caption
|
||||||
% the caption inserts \abovecaptionskip whitespace above itself (usually 10pt)
|
% the caption inserts \abovecaptionskip whitespace above itself (usually 10pt)
|
||||||
% there is also \belowcaptionskip but it is usually zero, hence the \smallskip
|
% there is also \belowcaptionskip but it is usually zero, hence the \smallskip
|
||||||
\def\SphinxVerbatimTitle
|
\def\sphinxVerbatimTitle
|
||||||
{\py@NormalColor\captionof{#1}{\SphinxLiteralBlockLabel #2}\smallskip }%
|
{\py@NormalColor\captionof{#1}{\sphinxLiteralBlockLabel #2}\smallskip }%
|
||||||
}
|
}
|
||||||
|
|
||||||
% Inspired and adapted from framed.sty's \CustomFBox with extra handling
|
% Inspired and adapted from framed.sty's \CustomFBox with extra handling
|
||||||
% of a non separable by pagebreak caption, and controlled counter stepping.
|
% of a non separable by pagebreak caption, and controlled counter stepping.
|
||||||
\newif\ifSphinx@myfirstframedpass
|
\newif\ifspx@myfirstframedpass
|
||||||
|
\long\def\spx@VerbatimFBox#1{%
|
||||||
\long\def\Sphinx@VerbatimFBox#1{%
|
|
||||||
\leavevmode
|
\leavevmode
|
||||||
\begingroup
|
\begingroup
|
||||||
% framed.sty does some measuring but this macro adds possibly a caption
|
% framed.sty does some measuring but this macro adds possibly a caption
|
||||||
% use amsmath conditional to inhibit the caption counter stepping after
|
% use amsmath conditional to inhibit the caption counter stepping after
|
||||||
% first pass
|
% first pass
|
||||||
\ifSphinx@myfirstframedpass\else\firstchoice@false\fi
|
\ifspx@myfirstframedpass\else\firstchoice@false\fi
|
||||||
\setbox\@tempboxa\hbox{\kern\fboxsep{#1}\kern\fboxsep}%
|
\setbox\@tempboxa\hbox{\kern\fboxsep{#1}\kern\fboxsep}%
|
||||||
\hbox
|
\hbox
|
||||||
{\lower\dimexpr\fboxrule+\fboxsep+\dp\@tempboxa
|
{\lower\dimexpr\fboxrule+\fboxsep+\dp\@tempboxa
|
||||||
\hbox{%
|
\hbox{%
|
||||||
\vbox{\ifx\SphinxVerbatimTitle\empty\else
|
\vbox{\ifx\sphinxVerbatimTitle\empty\else
|
||||||
% add the caption in a centered way above possibly indented frame
|
% add the caption in a centered way above possibly indented frame
|
||||||
% hide its width from framed.sty's measuring step
|
% hide its width from framed.sty's measuring step
|
||||||
% note that the caption brings \abovecaptionskip top vertical space
|
% note that the caption brings \abovecaptionskip top vertical space
|
||||||
\moveright\dimexpr\fboxrule+.5\wd\@tempboxa
|
\moveright\dimexpr\fboxrule+.5\wd\@tempboxa
|
||||||
\hb@xt@\z@{\hss\begin{minipage}{\wd\@tempboxa}%
|
\hb@xt@\z@{\hss\begin{minipage}{\wd\@tempboxa}%
|
||||||
\SphinxVerbatimTitle
|
\sphinxVerbatimTitle
|
||||||
\end{minipage}\hss}\fi
|
\end{minipage}\hss}\fi
|
||||||
% draw frame border _latest_ to avoid pdf viewer issue
|
% draw frame border _latest_ to avoid pdf viewer issue
|
||||||
\kern\fboxrule
|
\kern\fboxrule
|
||||||
@ -236,51 +236,51 @@
|
|||||||
\hrule\@height\fboxrule}%
|
\hrule\@height\fboxrule}%
|
||||||
}}%
|
}}%
|
||||||
\endgroup
|
\endgroup
|
||||||
\global\Sphinx@myfirstframedpassfalse
|
\global\spx@myfirstframedpassfalse
|
||||||
}
|
}
|
||||||
|
|
||||||
% For linebreaks inside Verbatim environment from package fancyvrb.
|
% For linebreaks inside Verbatim environment from package fancyvrb.
|
||||||
\newbox\Sphinxcontinuationbox
|
\newbox\sphinxcontinuationbox
|
||||||
\newbox\Sphinxvisiblespacebox
|
\newbox\sphinxvisiblespacebox
|
||||||
% These are user customizable e.g. from latex_elements's preamble key.
|
% These are user customizable e.g. from latex_elements's preamble key.
|
||||||
% Use of \textvisiblespace for compatibility with XeTeX/LuaTeX/fontspec.
|
% Use of \textvisiblespace for compatibility with XeTeX/LuaTeX/fontspec.
|
||||||
\newcommand*\Sphinxvisiblespace {\textcolor{red}{\textvisiblespace}}
|
\newcommand*\sphinxvisiblespace {\textcolor{red}{\textvisiblespace}}
|
||||||
\newcommand*\Sphinxcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}}
|
\newcommand*\sphinxcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}}
|
||||||
\newcommand*\Sphinxcontinuationindent {3ex }
|
\newcommand*\sphinxcontinuationindent {3ex }
|
||||||
\newcommand*\Sphinxafterbreak {\kern\Sphinxcontinuationindent\copy\Sphinxcontinuationbox}
|
\newcommand*\sphinxafterbreak {\kern\sphinxcontinuationindent\copy\sphinxcontinuationbox}
|
||||||
|
|
||||||
% Take advantage of the already applied Pygments mark-up to insert
|
% Take advantage of the already applied Pygments mark-up to insert
|
||||||
% potential linebreaks for TeX processing.
|
% potential linebreaks for TeX processing.
|
||||||
% {, <, #, %, $, ' and ": go to next line.
|
% {, <, #, %, $, ' and ": go to next line.
|
||||||
% _, }, ^, &, >, - and ~: stay at end of broken line.
|
% _, }, ^, &, >, - and ~: stay at end of broken line.
|
||||||
% Use of \textquotesingle for straight quote.
|
% Use of \textquotesingle for straight quote.
|
||||||
\newcommand*\Sphinxbreaksatspecials {%
|
\newcommand*\sphinxbreaksatspecials {%
|
||||||
\def\PYGZus{\discretionary{\char`\_}{\Sphinxafterbreak}{\char`\_}}%
|
\def\PYGZus{\discretionary{\char`\_}{\sphinxafterbreak}{\char`\_}}%
|
||||||
\def\PYGZob{\discretionary{}{\Sphinxafterbreak\char`\{}{\char`\{}}%
|
\def\PYGZob{\discretionary{}{\sphinxafterbreak\char`\{}{\char`\{}}%
|
||||||
\def\PYGZcb{\discretionary{\char`\}}{\Sphinxafterbreak}{\char`\}}}%
|
\def\PYGZcb{\discretionary{\char`\}}{\sphinxafterbreak}{\char`\}}}%
|
||||||
\def\PYGZca{\discretionary{\char`\^}{\Sphinxafterbreak}{\char`\^}}%
|
\def\PYGZca{\discretionary{\char`\^}{\sphinxafterbreak}{\char`\^}}%
|
||||||
\def\PYGZam{\discretionary{\char`\&}{\Sphinxafterbreak}{\char`\&}}%
|
\def\PYGZam{\discretionary{\char`\&}{\sphinxafterbreak}{\char`\&}}%
|
||||||
\def\PYGZlt{\discretionary{}{\Sphinxafterbreak\char`\<}{\char`\<}}%
|
\def\PYGZlt{\discretionary{}{\sphinxafterbreak\char`\<}{\char`\<}}%
|
||||||
\def\PYGZgt{\discretionary{\char`\>}{\Sphinxafterbreak}{\char`\>}}%
|
\def\PYGZgt{\discretionary{\char`\>}{\sphinxafterbreak}{\char`\>}}%
|
||||||
\def\PYGZsh{\discretionary{}{\Sphinxafterbreak\char`\#}{\char`\#}}%
|
\def\PYGZsh{\discretionary{}{\sphinxafterbreak\char`\#}{\char`\#}}%
|
||||||
\def\PYGZpc{\discretionary{}{\Sphinxafterbreak\char`\%}{\char`\%}}%
|
\def\PYGZpc{\discretionary{}{\sphinxafterbreak\char`\%}{\char`\%}}%
|
||||||
\def\PYGZdl{\discretionary{}{\Sphinxafterbreak\char`\$}{\char`\$}}%
|
\def\PYGZdl{\discretionary{}{\sphinxafterbreak\char`\$}{\char`\$}}%
|
||||||
\def\PYGZhy{\discretionary{\char`\-}{\Sphinxafterbreak}{\char`\-}}%
|
\def\PYGZhy{\discretionary{\char`\-}{\sphinxafterbreak}{\char`\-}}%
|
||||||
\def\PYGZsq{\discretionary{}{\Sphinxafterbreak\textquotesingle}{\textquotesingle}}%
|
\def\PYGZsq{\discretionary{}{\sphinxafterbreak\textquotesingle}{\textquotesingle}}%
|
||||||
\def\PYGZdq{\discretionary{}{\Sphinxafterbreak\char`\"}{\char`\"}}%
|
\def\PYGZdq{\discretionary{}{\sphinxafterbreak\char`\"}{\char`\"}}%
|
||||||
\def\PYGZti{\discretionary{\char`\~}{\Sphinxafterbreak}{\char`\~}}%
|
\def\PYGZti{\discretionary{\char`\~}{\sphinxafterbreak}{\char`\~}}%
|
||||||
}
|
}
|
||||||
|
|
||||||
% Some characters . , ; ? ! / are not pygmentized.
|
% Some characters . , ; ? ! / are not pygmentized.
|
||||||
% This macro makes them "active" and they will insert potential linebreaks
|
% This macro makes them "active" and they will insert potential linebreaks
|
||||||
\newcommand*\Sphinxbreaksatpunct {%
|
\newcommand*\sphinxbreaksatpunct {%
|
||||||
\lccode`\~`\.\lowercase{\def~}{\discretionary{\char`\.}{\Sphinxafterbreak}{\char`\.}}%
|
\lccode`\~`\.\lowercase{\def~}{\discretionary{\char`\.}{\sphinxafterbreak}{\char`\.}}%
|
||||||
\lccode`\~`\,\lowercase{\def~}{\discretionary{\char`\,}{\Sphinxafterbreak}{\char`\,}}%
|
\lccode`\~`\,\lowercase{\def~}{\discretionary{\char`\,}{\sphinxafterbreak}{\char`\,}}%
|
||||||
\lccode`\~`\;\lowercase{\def~}{\discretionary{\char`\;}{\Sphinxafterbreak}{\char`\;}}%
|
\lccode`\~`\;\lowercase{\def~}{\discretionary{\char`\;}{\sphinxafterbreak}{\char`\;}}%
|
||||||
\lccode`\~`\:\lowercase{\def~}{\discretionary{\char`\:}{\Sphinxafterbreak}{\char`\:}}%
|
\lccode`\~`\:\lowercase{\def~}{\discretionary{\char`\:}{\sphinxafterbreak}{\char`\:}}%
|
||||||
\lccode`\~`\?\lowercase{\def~}{\discretionary{\char`\?}{\Sphinxafterbreak}{\char`\?}}%
|
\lccode`\~`\?\lowercase{\def~}{\discretionary{\char`\?}{\sphinxafterbreak}{\char`\?}}%
|
||||||
\lccode`\~`\!\lowercase{\def~}{\discretionary{\char`\!}{\Sphinxafterbreak}{\char`\!}}%
|
\lccode`\~`\!\lowercase{\def~}{\discretionary{\char`\!}{\sphinxafterbreak}{\char`\!}}%
|
||||||
\lccode`\~`\/\lowercase{\def~}{\discretionary{\char`\/}{\Sphinxafterbreak}{\char`\/}}%
|
\lccode`\~`\/\lowercase{\def~}{\discretionary{\char`\/}{\sphinxafterbreak}{\char`\/}}%
|
||||||
\catcode`\.\active
|
\catcode`\.\active
|
||||||
\catcode`\,\active
|
\catcode`\,\active
|
||||||
\catcode`\;\active
|
\catcode`\;\active
|
||||||
@ -297,25 +297,25 @@
|
|||||||
% list starts new par, but we don't want it to be set apart vertically
|
% list starts new par, but we don't want it to be set apart vertically
|
||||||
\parskip\z@skip
|
\parskip\z@skip
|
||||||
% first, let's check if there is a caption
|
% first, let's check if there is a caption
|
||||||
\ifx\SphinxVerbatimTitle\empty
|
\ifx\sphinxVerbatimTitle\empty
|
||||||
\addvspace\z@% counteract possible previous negative skip (French lists!)
|
\addvspace\z@% counteract possible previous negative skip (French lists!)
|
||||||
\smallskip
|
\smallskip
|
||||||
% there was no caption. Check if nevertheless a label was set.
|
% there was no caption. Check if nevertheless a label was set.
|
||||||
\ifx\SphinxLiteralBlockLabel\empty\else
|
\ifx\sphinxLiteralBlockLabel\empty\else
|
||||||
% we require some space to be sure hyperlink target from \phantomsection
|
% we require some space to be sure hyperlink target from \phantomsection
|
||||||
% will not be separated from upcoming verbatim by a page break
|
% will not be separated from upcoming verbatim by a page break
|
||||||
\needspace{\literalblockwithoutcaptionneedspace}%
|
\needspace{\sphinxliteralblockwithoutcaptionneedspace}%
|
||||||
\phantomsection\SphinxLiteralBlockLabel
|
\phantomsection\sphinxLiteralBlockLabel
|
||||||
\fi
|
\fi
|
||||||
\fi
|
\fi
|
||||||
% non-empty \SphinxVerbatimTitle has label inside it (in case there is one)
|
% non-empty \sphinxVerbatimTitle has label inside it (in case there is one)
|
||||||
% Customize framed.sty \MakeFramed to glue caption to literal block
|
% Customize framed.sty \MakeFramed to glue caption to literal block
|
||||||
\global\Sphinx@myfirstframedpasstrue
|
\global\spx@myfirstframedpasstrue
|
||||||
% via \Sphinx@fcolorbox, will use \Sphinx@VerbatimFBox which inserts title
|
% via \spx@fcolorbox, will use \spx@VerbatimFBox which inserts title
|
||||||
\def\FrameCommand {\Sphinx@colorbox\Sphinx@fcolorbox }%
|
\def\FrameCommand {\spx@colorbox\spx@fcolorbox }%
|
||||||
\let\FirstFrameCommand\FrameCommand
|
\let\FirstFrameCommand\FrameCommand
|
||||||
% for mid pages and last page portion of (long) split frame:
|
% for mid pages and last page portion of (long) split frame:
|
||||||
\def\MidFrameCommand{\Sphinx@colorbox\fcolorbox }%
|
\def\MidFrameCommand{\spx@colorbox\fcolorbox }%
|
||||||
\let\LastFrameCommand\MidFrameCommand
|
\let\LastFrameCommand\MidFrameCommand
|
||||||
% fancyvrb's Verbatim puts each input line in (unbreakable) horizontal boxes.
|
% fancyvrb's Verbatim puts each input line in (unbreakable) horizontal boxes.
|
||||||
% This customization wraps each line from the input in a \vtop, thus
|
% This customization wraps each line from the input in a \vtop, thus
|
||||||
@ -323,10 +323,10 @@
|
|||||||
% - The codeline counter will be increased only once.
|
% - The codeline counter will be increased only once.
|
||||||
% - The wrapped material will not break across pages, it is impossible
|
% - The wrapped material will not break across pages, it is impossible
|
||||||
% to achieve this without extensive rewrite of fancyvrb.
|
% to achieve this without extensive rewrite of fancyvrb.
|
||||||
% - The (not used in Sphinx) obeytabs option to Verbatim is
|
% - The (not used in sphinx) obeytabs option to Verbatim is
|
||||||
% broken by this change (showtabs and tabspace work).
|
% broken by this change (showtabs and tabspace work).
|
||||||
\sbox\Sphinxcontinuationbox {\Sphinxcontinuationsymbol}%
|
\sbox\sphinxcontinuationbox {\sphinxcontinuationsymbol}%
|
||||||
\sbox\Sphinxvisiblespacebox {\FV@SetupFont\Sphinxvisiblespace}%
|
\sbox\sphinxvisiblespacebox {\FV@SetupFont\sphinxvisiblespace}%
|
||||||
\def\FancyVerbFormatLine ##1{\hsize\linewidth
|
\def\FancyVerbFormatLine ##1{\hsize\linewidth
|
||||||
\vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
|
\vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
|
||||||
\doublehyphendemerits\z@\finalhyphendemerits\z@
|
\doublehyphendemerits\z@\finalhyphendemerits\z@
|
||||||
@ -337,7 +337,7 @@
|
|||||||
% Stretch/shrink are however usually zero for typewriter font.
|
% Stretch/shrink are however usually zero for typewriter font.
|
||||||
\def\FV@Space {%
|
\def\FV@Space {%
|
||||||
\nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font
|
\nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font
|
||||||
\discretionary{\copy\Sphinxvisiblespacebox}{\Sphinxafterbreak}
|
\discretionary{\copy\sphinxvisiblespacebox}{\sphinxafterbreak}
|
||||||
{\kern\fontdimen2\font}%
|
{\kern\fontdimen2\font}%
|
||||||
}%
|
}%
|
||||||
% go around fancyvrb's check of @currenvir (for case of minipage below)
|
% go around fancyvrb's check of @currenvir (for case of minipage below)
|
||||||
@ -345,7 +345,7 @@
|
|||||||
% go around fancyvrb's check of current list depth
|
% go around fancyvrb's check of current list depth
|
||||||
\def\@toodeep {\advance\@listdepth\@ne}%
|
\def\@toodeep {\advance\@listdepth\@ne}%
|
||||||
% Allow breaks at special characters using \PYG... macros.
|
% Allow breaks at special characters using \PYG... macros.
|
||||||
\Sphinxbreaksatspecials
|
\sphinxbreaksatspecials
|
||||||
% The list environment is needed to control perfectly the vertical space.
|
% The list environment is needed to control perfectly the vertical space.
|
||||||
% Note: \OuterFrameSep used by framed.sty is later set to \topsep hence 0pt.
|
% Note: \OuterFrameSep used by framed.sty is later set to \topsep hence 0pt.
|
||||||
% - if caption: vertical space above caption = (\abovecaptionskip + D) with
|
% - if caption: vertical space above caption = (\abovecaptionskip + D) with
|
||||||
@ -360,7 +360,7 @@
|
|||||||
\parindent \z@% becomes \itemindent. Default zero, but perhaps overwritten.
|
\parindent \z@% becomes \itemindent. Default zero, but perhaps overwritten.
|
||||||
\trivlist\item\relax
|
\trivlist\item\relax
|
||||||
% use a minipage if we are already inside a framed environment
|
% use a minipage if we are already inside a framed environment
|
||||||
\ifSphinx@inframed\noindent\begin{minipage}{\linewidth}\fi
|
\ifspx@inframed\noindent\begin{minipage}{\linewidth}\fi
|
||||||
\MakeFramed {% adapted over from framed.sty's snugshade environment
|
\MakeFramed {% adapted over from framed.sty's snugshade environment
|
||||||
\advance\hsize-\width\@totalleftmargin\z@\linewidth\hsize
|
\advance\hsize-\width\@totalleftmargin\z@\linewidth\hsize
|
||||||
\@setminipage }%
|
\@setminipage }%
|
||||||
@ -368,45 +368,45 @@
|
|||||||
% For grid placement from \strut's in \FancyVerbFormatLine
|
% For grid placement from \strut's in \FancyVerbFormatLine
|
||||||
\lineskip\z@skip
|
\lineskip\z@skip
|
||||||
% Breaks at punctuation characters . , ; ? ! and / need catcode=\active
|
% Breaks at punctuation characters . , ; ? ! and / need catcode=\active
|
||||||
\OriginalVerbatim[#1,codes*=\Sphinxbreaksatpunct]%
|
\OriginalVerbatim[#1,codes*=\sphinxbreaksatpunct]%
|
||||||
}
|
}
|
||||||
\renewcommand{\endVerbatim}{%
|
\renewcommand{\endVerbatim}{%
|
||||||
\endOriginalVerbatim
|
\endOriginalVerbatim
|
||||||
\par\unskip\@minipagefalse\endMakeFramed
|
\par\unskip\@minipagefalse\endMakeFramed
|
||||||
\ifSphinx@inframed\end{minipage}\fi
|
\ifspx@inframed\end{minipage}\fi
|
||||||
\endtrivlist
|
\endtrivlist
|
||||||
}
|
}
|
||||||
|
|
||||||
% define macro to frame contents and add shadow on right and bottom
|
% define macro to frame contents and add shadow on right and bottom
|
||||||
\def\Sphinx@shadowsep {5\p@} % \p@ means "pt "
|
\def\spx@shadowsep {5\p@} % \p@ means "pt "
|
||||||
\def\Sphinx@shadowsize {4\p@}
|
\def\spx@shadowsize {4\p@}
|
||||||
\def\Sphinx@shadowrule {\fboxrule}
|
\def\spx@shadowrule {\fboxrule}
|
||||||
\long\def\Sphinx@ShadowFBox#1{%
|
\long\def\spx@ShadowFBox#1{%
|
||||||
\leavevmode\begingroup
|
\leavevmode\begingroup
|
||||||
% first we frame the box #1
|
% first we frame the box #1
|
||||||
\setbox\@tempboxa
|
\setbox\@tempboxa
|
||||||
\hbox{\vrule\@width\Sphinx@shadowrule
|
\hbox{\vrule\@width\spx@shadowrule
|
||||||
\vbox{\hrule\@height\Sphinx@shadowrule
|
\vbox{\hrule\@height\spx@shadowrule
|
||||||
\kern\Sphinx@shadowsep
|
\kern\spx@shadowsep
|
||||||
\hbox{\kern\Sphinx@shadowsep #1\kern\Sphinx@shadowsep}%
|
\hbox{\kern\spx@shadowsep #1\kern\spx@shadowsep}%
|
||||||
\kern\Sphinx@shadowsep
|
\kern\spx@shadowsep
|
||||||
\hrule\@height\Sphinx@shadowrule}%
|
\hrule\@height\spx@shadowrule}%
|
||||||
\vrule\@width\Sphinx@shadowrule}%
|
\vrule\@width\spx@shadowrule}%
|
||||||
% Now we add the shadow, like \shadowbox from fancybox.sty would do
|
% Now we add the shadow, like \shadowbox from fancybox.sty would do
|
||||||
\dimen@\dimexpr.5\Sphinx@shadowrule+\Sphinx@shadowsize\relax
|
\dimen@\dimexpr.5\spx@shadowrule+\spx@shadowsize\relax
|
||||||
\hbox{\vbox{\offinterlineskip
|
\hbox{\vbox{\offinterlineskip
|
||||||
\hbox{\copy\@tempboxa\kern-.5\Sphinx@shadowrule
|
\hbox{\copy\@tempboxa\kern-.5\spx@shadowrule
|
||||||
% add shadow on right side
|
% add shadow on right side
|
||||||
\lower\Sphinx@shadowsize
|
\lower\spx@shadowsize
|
||||||
\hbox{\vrule\@height\ht\@tempboxa \@width\dimen@}%
|
\hbox{\vrule\@height\ht\@tempboxa \@width\dimen@}%
|
||||||
}%
|
}%
|
||||||
\kern-\dimen@ % shift back vertically to bottom of frame
|
\kern-\dimen@ % shift back vertically to bottom of frame
|
||||||
% and add shadow at bottom
|
% and add shadow at bottom
|
||||||
\moveright\Sphinx@shadowsize
|
\moveright\spx@shadowsize
|
||||||
\vbox{\hrule\@width\wd\@tempboxa \@height\dimen@}%
|
\vbox{\hrule\@width\wd\@tempboxa \@height\dimen@}%
|
||||||
}%
|
}%
|
||||||
% move left by the size of right shadow so shadow adds no width
|
% move left by the size of right shadow so shadow adds no width
|
||||||
\kern-\Sphinx@shadowsize
|
\kern-\spx@shadowsize
|
||||||
}%
|
}%
|
||||||
\endgroup
|
\endgroup
|
||||||
}
|
}
|
||||||
@ -415,8 +415,8 @@
|
|||||||
% works well inside Lists and Quote-like environments
|
% works well inside Lists and Quote-like environments
|
||||||
% produced by ``topic'' directive (or local contents)
|
% produced by ``topic'' directive (or local contents)
|
||||||
% could nest if LaTeX writer authorized it
|
% could nest if LaTeX writer authorized it
|
||||||
\newenvironment{SphinxShadowBox}
|
\newenvironment{sphinxShadowBox}
|
||||||
{\def\FrameCommand {\Sphinx@ShadowFBox }%
|
{\def\FrameCommand {\spx@ShadowFBox }%
|
||||||
% configure framed.sty not to add extra vertical spacing
|
% configure framed.sty not to add extra vertical spacing
|
||||||
\ifdefined\OuterFrameSep \OuterFrameSep\z@skip \fi
|
\ifdefined\OuterFrameSep \OuterFrameSep\z@skip \fi
|
||||||
% the \trivlist will add the vertical spacing on top and bottom which is
|
% the \trivlist will add the vertical spacing on top and bottom which is
|
||||||
@ -427,8 +427,8 @@
|
|||||||
\def\FrameHeightAdjust {\baselineskip}%
|
\def\FrameHeightAdjust {\baselineskip}%
|
||||||
\trivlist\item\noindent
|
\trivlist\item\noindent
|
||||||
% use a minipage if we are already inside a framed environment
|
% use a minipage if we are already inside a framed environment
|
||||||
\ifSphinx@inframed\begin{minipage}{\linewidth}\fi
|
\ifspx@inframed\begin{minipage}{\linewidth}\fi
|
||||||
\MakeFramed {\Sphinx@inframedtrue
|
\MakeFramed {\spx@inframedtrue
|
||||||
% framed.sty puts into "\width" the added width (=2shadowsep+2shadowrule)
|
% framed.sty puts into "\width" the added width (=2shadowsep+2shadowrule)
|
||||||
% adjust \hsize to what the contents must use
|
% adjust \hsize to what the contents must use
|
||||||
\advance\hsize-\width
|
\advance\hsize-\width
|
||||||
@ -454,7 +454,7 @@
|
|||||||
\fi
|
\fi
|
||||||
\@minipagefalse
|
\@minipagefalse
|
||||||
\endMakeFramed
|
\endMakeFramed
|
||||||
\ifSphinx@inframed\end{minipage}\fi
|
\ifspx@inframed\end{minipage}\fi
|
||||||
\endtrivlist
|
\endtrivlist
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,25 +495,25 @@
|
|||||||
}{\end{list}}
|
}{\end{list}}
|
||||||
|
|
||||||
% \optional is used for ``[, arg]``, i.e. desc_optional nodes.
|
% \optional is used for ``[, arg]``, i.e. desc_optional nodes.
|
||||||
\newcommand{\optional}[1]{%
|
\newcommand{\sphinxoptional}[1]{%
|
||||||
{\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
|
{\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
|
||||||
|
|
||||||
\newlength{\py@argswidth}
|
\newlength{\py@argswidth}
|
||||||
\newcommand{\py@sigparams}[2]{%
|
\newcommand{\py@sigparams}[2]{%
|
||||||
\parbox[t]{\py@argswidth}{#1\code{)}#2}}
|
\parbox[t]{\py@argswidth}{#1\sphinxcode{)}#2}}
|
||||||
\newcommand{\pysigline}[1]{\item[#1]\nopagebreak}
|
\newcommand{\pysigline}[1]{\item[#1]\nopagebreak}
|
||||||
\newcommand{\pysiglinewithargsret}[3]{%
|
\newcommand{\pysiglinewithargsret}[3]{%
|
||||||
\settowidth{\py@argswidth}{#1\code{(}}%
|
\settowidth{\py@argswidth}{#1\sphinxcode{(}}%
|
||||||
\addtolength{\py@argswidth}{-2\py@argswidth}%
|
\addtolength{\py@argswidth}{-2\py@argswidth}%
|
||||||
\addtolength{\py@argswidth}{\linewidth}%
|
\addtolength{\py@argswidth}{\linewidth}%
|
||||||
\item[#1\code{(}\py@sigparams{#2}{#3}]}
|
\item[#1\sphinxcode{(}\py@sigparams{#2}{#3}]}
|
||||||
|
|
||||||
% Production lists
|
% Production lists
|
||||||
%
|
%
|
||||||
\newenvironment{productionlist}{
|
\newenvironment{productionlist}{
|
||||||
% \def\optional##1{{\Large[}##1{\Large]}}
|
% \def\sphinxoptional##1{{\Large[}##1{\Large]}}
|
||||||
\def\production##1##2{\\\code{##1}&::=&\code{##2}}
|
\def\production##1##2{\\\sphinxcode{##1}&::=&\sphinxcode{##2}}
|
||||||
\def\productioncont##1{\\& &\code{##1}}
|
\def\productioncont##1{\\& &\sphinxcode{##1}}
|
||||||
\parindent=2em
|
\parindent=2em
|
||||||
\indent
|
\indent
|
||||||
\setlength{\LTpre}{0pt}
|
\setlength{\LTpre}{0pt}
|
||||||
@ -541,7 +541,7 @@
|
|||||||
\fboxsep\FrameSep \fboxrule\FrameRule\fbox{##1}%
|
\fboxsep\FrameSep \fboxrule\FrameRule\fbox{##1}%
|
||||||
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
|
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
|
||||||
% use a minipage if we are already inside a framed environment
|
% use a minipage if we are already inside a framed environment
|
||||||
\ifSphinx@inframed
|
\ifspx@inframed
|
||||||
\noindent\begin{minipage}{\linewidth}
|
\noindent\begin{minipage}{\linewidth}
|
||||||
\else
|
\else
|
||||||
% handle case where notice is first thing in a list item (or is quoted)
|
% handle case where notice is first thing in a list item (or is quoted)
|
||||||
@ -551,7 +551,7 @@
|
|||||||
\vspace{\parskip}
|
\vspace{\parskip}
|
||||||
\fi
|
\fi
|
||||||
\fi
|
\fi
|
||||||
\MakeFramed {\Sphinx@inframedtrue
|
\MakeFramed {\spx@inframedtrue
|
||||||
\advance\hsize-\width \@totalleftmargin\z@ \linewidth\hsize
|
\advance\hsize-\width \@totalleftmargin\z@ \linewidth\hsize
|
||||||
% minipage initialization copied from LaTeX source code.
|
% minipage initialization copied from LaTeX source code.
|
||||||
\@pboxswfalse
|
\@pboxswfalse
|
||||||
@ -570,7 +570,7 @@
|
|||||||
\fi
|
\fi
|
||||||
\@minipagefalse
|
\@minipagefalse
|
||||||
\endMakeFramed
|
\endMakeFramed
|
||||||
\ifSphinx@inframed\end{minipage}\fi
|
\ifspx@inframed\end{minipage}\fi
|
||||||
% arrange for similar spacing below frame as for "light" boxes.
|
% arrange for similar spacing below frame as for "light" boxes.
|
||||||
\vskip .4\baselineskip
|
\vskip .4\baselineskip
|
||||||
}
|
}
|
||||||
@ -614,7 +614,7 @@
|
|||||||
\newenvironment{notice}[2]{
|
\newenvironment{notice}[2]{
|
||||||
\def\py@noticetype{#1}
|
\def\py@noticetype{#1}
|
||||||
\csname py@noticestart@#1\endcsname
|
\csname py@noticestart@#1\endcsname
|
||||||
\strong{#2}
|
\sphinxstrong{#2} % <- legacy code creates a space after {#2}
|
||||||
}{\csname py@noticeend@\py@noticetype\endcsname}
|
}{\csname py@noticeend@\py@noticetype\endcsname}
|
||||||
|
|
||||||
% Allow the release number to be specified independently of the
|
% Allow the release number to be specified independently of the
|
||||||
@ -684,7 +684,7 @@
|
|||||||
|
|
||||||
% The following is stuff copied from docutils' latex writer.
|
% The following is stuff copied from docutils' latex writer.
|
||||||
%
|
%
|
||||||
\newcommand{\optionlistlabel}[1]{\bf #1 \hfill}
|
\newcommand{\optionlistlabel}[1]{\normalfont\bfseries #1 \hfill}% \bf deprecated
|
||||||
\newenvironment{optionlist}[1]
|
\newenvironment{optionlist}[1]
|
||||||
{\begin{list}{}
|
{\begin{list}{}
|
||||||
{\setlength{\labelwidth}{#1}
|
{\setlength{\labelwidth}{#1}
|
||||||
@ -853,17 +853,38 @@
|
|||||||
\RequirePackage{capt-of}
|
\RequirePackage{capt-of}
|
||||||
\RequirePackage{needspace}
|
\RequirePackage{needspace}
|
||||||
% if the left page space is less than \literalblockneedspace, insert page-break
|
% if the left page space is less than \literalblockneedspace, insert page-break
|
||||||
\newcommand{\literalblockneedspace}{5\baselineskip}
|
\newcommand{\sphinxliteralblockneedspace}{5\baselineskip}
|
||||||
\newcommand{\literalblockwithoutcaptionneedspace}{1.5\baselineskip}
|
\newcommand{\sphinxliteralblockwithoutcaptionneedspace}{1.5\baselineskip}
|
||||||
|
|
||||||
% figure in table
|
% figure in table
|
||||||
\newenvironment{figure-in-table}[1][\linewidth]{%
|
\newenvironment{sphinxfigure-in-table}[1][\linewidth]{%
|
||||||
\def\@captype{figure}%
|
\def\@captype{figure}%
|
||||||
\begin{minipage}{#1}%
|
\begin{minipage}{#1}%
|
||||||
}{\end{minipage}}
|
}{\end{minipage}}
|
||||||
% store original \caption macro for use with figures in longtable and tabulary
|
% store original \caption macro for use with figures in longtable and tabulary
|
||||||
\AtBeginDocument{\let\Sphinx@originalcaption\caption}
|
\AtBeginDocument{\let\spx@originalcaption\caption}
|
||||||
\newcommand*\figcaption
|
\newcommand*\sphinxfigcaption
|
||||||
{\ifx\equation$%$% this is trick to identify tabulary first pass
|
{\ifx\equation$%$% this is trick to identify tabulary first pass
|
||||||
\firstchoice@false\else\firstchoice@true\fi
|
\firstchoice@false\else\firstchoice@true\fi
|
||||||
\Sphinx@originalcaption }
|
\spx@originalcaption }
|
||||||
|
|
||||||
|
% by default, also define macros with the no-prefix names
|
||||||
|
\ifsphinxKeepOldNames
|
||||||
|
\typeout{** (sphinx) defining (legacy) text style macros without \string\sphinx\space prefix}
|
||||||
|
\typeout{** if clashes with packages, set latex_keep_old_macro_names=False in conf.py}
|
||||||
|
\@for\@tempa:=strong,bfcode,email,tablecontinued,titleref,%
|
||||||
|
menuselection,accelerator,crossref,termref,optional\do
|
||||||
|
{% first, check if command with no prefix already exists
|
||||||
|
\expandafter\newcommand\csname\@tempa\endcsname{}%
|
||||||
|
% if no error give it the meaning defined so far with \sphinx prefix
|
||||||
|
\expandafter\let\csname\@tempa\expandafter\endcsname
|
||||||
|
\csname sphinx\@tempa\endcsname
|
||||||
|
% redefine the \sphinx prefixed macro to expand to non-prefixed one
|
||||||
|
\expandafter\def\csname sphinx\@tempa\expandafter\endcsname
|
||||||
|
\expandafter{\csname\@tempa\endcsname}%
|
||||||
|
}
|
||||||
|
% robustified case needs special treatment
|
||||||
|
\newcommand\code{}\let\code\relax
|
||||||
|
\DeclareRobustCommand{\code}[1]{{\@noligs\scantokens{\texttt{#1}}}}
|
||||||
|
\def\sphinxcode{\code}%
|
||||||
|
\fi
|
||||||
|
@ -33,6 +33,7 @@ from sphinx.util.smartypants import educate_quotes_latex
|
|||||||
|
|
||||||
HEADER = r'''%% Generated by Sphinx.
|
HEADER = r'''%% Generated by Sphinx.
|
||||||
\def\sphinxdocclass{%(docclass)s}
|
\def\sphinxdocclass{%(docclass)s}
|
||||||
|
\newif\ifsphinxKeepOldNames %(keepoldnames)s
|
||||||
\documentclass[%(papersize)s,%(pointsize)s%(classoptions)s]{%(wrapperclass)s}
|
\documentclass[%(papersize)s,%(pointsize)s%(classoptions)s]{%(wrapperclass)s}
|
||||||
\usepackage{iftex}
|
\usepackage{iftex}
|
||||||
%(passoptionstopackages)s
|
%(passoptionstopackages)s
|
||||||
@ -391,6 +392,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
'preamble': builder.config.latex_preamble,
|
'preamble': builder.config.latex_preamble,
|
||||||
'indexname': _('Index'),
|
'indexname': _('Index'),
|
||||||
})
|
})
|
||||||
|
# set-up boolean for sphinx.sty
|
||||||
|
if builder.config.latex_keep_old_macro_names:
|
||||||
|
self.elements['keepoldnames'] = '\\sphinxKeepOldNamestrue'
|
||||||
|
else:
|
||||||
|
self.elements['keepoldnames'] = '\\sphinxKeepOldNamesfalse'
|
||||||
if document.settings.docclass == 'howto':
|
if document.settings.docclass == 'howto':
|
||||||
docclass = builder.config.latex_docclass.get('howto', 'article')
|
docclass = builder.config.latex_docclass.get('howto', 'article')
|
||||||
else:
|
else:
|
||||||
@ -732,11 +738,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
|
|
||||||
def visit_topic(self, node):
|
def visit_topic(self, node):
|
||||||
self.in_minipage = 1
|
self.in_minipage = 1
|
||||||
self.body.append('\n\\begin{SphinxShadowBox}\n')
|
self.body.append('\n\\begin{sphinxShadowBox}\n')
|
||||||
|
|
||||||
def depart_topic(self, node):
|
def depart_topic(self, node):
|
||||||
self.in_minipage = 0
|
self.in_minipage = 0
|
||||||
self.body.append('\\end{SphinxShadowBox}\n')
|
self.body.append('\\end{sphinxShadowBox}\n')
|
||||||
visit_sidebar = visit_topic
|
visit_sidebar = visit_topic
|
||||||
depart_sidebar = depart_topic
|
depart_sidebar = depart_topic
|
||||||
|
|
||||||
@ -867,7 +873,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.body.append('}')
|
self.body.append('}')
|
||||||
|
|
||||||
def visit_desc_addname(self, node):
|
def visit_desc_addname(self, node):
|
||||||
self.body.append(r'\code{')
|
self.body.append(r'\sphinxcode{')
|
||||||
self.literal_whitespace += 1
|
self.literal_whitespace += 1
|
||||||
|
|
||||||
def depart_desc_addname(self, node):
|
def depart_desc_addname(self, node):
|
||||||
@ -887,7 +893,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.body.append(r'}')
|
self.body.append(r'}')
|
||||||
|
|
||||||
def visit_desc_name(self, node):
|
def visit_desc_name(self, node):
|
||||||
self.body.append(r'\bfcode{')
|
self.body.append(r'\sphinxbfcode{')
|
||||||
self.no_contractions += 1
|
self.no_contractions += 1
|
||||||
self.literal_whitespace += 1
|
self.literal_whitespace += 1
|
||||||
|
|
||||||
@ -918,13 +924,13 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.body.append('}')
|
self.body.append('}')
|
||||||
|
|
||||||
def visit_desc_optional(self, node):
|
def visit_desc_optional(self, node):
|
||||||
self.body.append(r'\optional{')
|
self.body.append(r'\sphinxoptional{')
|
||||||
|
|
||||||
def depart_desc_optional(self, node):
|
def depart_desc_optional(self, node):
|
||||||
self.body.append('}')
|
self.body.append('}')
|
||||||
|
|
||||||
def visit_desc_annotation(self, node):
|
def visit_desc_annotation(self, node):
|
||||||
self.body.append(r'\strong{')
|
self.body.append(r'\sphinxstrong{')
|
||||||
|
|
||||||
def depart_desc_annotation(self, node):
|
def depart_desc_annotation(self, node):
|
||||||
self.body.append('}')
|
self.body.append('}')
|
||||||
@ -938,7 +944,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_seealso(self, node):
|
def visit_seealso(self, node):
|
||||||
self.body.append(u'\n\n\\strong{%s:}\n\n' % admonitionlabels['seealso'])
|
self.body.append(u'\n\n\\sphinxstrong{%s:}\n\n' % admonitionlabels['seealso'])
|
||||||
|
|
||||||
def depart_seealso(self, node):
|
def depart_seealso(self, node):
|
||||||
self.body.append("\n\n")
|
self.body.append("\n\n")
|
||||||
@ -1440,12 +1446,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
# TODO: support align option
|
# TODO: support align option
|
||||||
if 'width' in node:
|
if 'width' in node:
|
||||||
length = width_to_latex_length(node['width'])
|
length = width_to_latex_length(node['width'])
|
||||||
self.body.append('\\begin{figure-in-table}[%s]\n\\centering\n' % length)
|
self.body.append('\\begin{sphinxfigure-in-table}[%s]\n\\centering\n' % length)
|
||||||
else:
|
else:
|
||||||
self.body.append('\\begin{figure-in-table}\n\\centering\n')
|
self.body.append('\\begin{sphinxfigure-in-table}\n\\centering\n')
|
||||||
if any(isinstance(child, nodes.caption) for child in node):
|
if any(isinstance(child, nodes.caption) for child in node):
|
||||||
self.body.append('\\capstart')
|
self.body.append('\\capstart')
|
||||||
self.context.append(ids + '\\end{figure-in-table}\n')
|
self.context.append(ids + '\\end{sphinxfigure-in-table}\n')
|
||||||
elif node.get('align', '') in ('left', 'right'):
|
elif node.get('align', '') in ('left', 'right'):
|
||||||
if 'width' in node:
|
if 'width' in node:
|
||||||
length = width_to_latex_length(node['width'])
|
length = width_to_latex_length(node['width'])
|
||||||
@ -1487,11 +1493,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
def visit_caption(self, node):
|
def visit_caption(self, node):
|
||||||
self.in_caption += 1
|
self.in_caption += 1
|
||||||
if self.in_container_literal_block:
|
if self.in_container_literal_block:
|
||||||
self.body.append('\\SphinxSetupCaptionForVerbatim{literal-block}{')
|
self.body.append('\\sphinxSetupCaptionForVerbatim{literal-block}{')
|
||||||
elif self.in_minipage and isinstance(node.parent, nodes.figure):
|
elif self.in_minipage and isinstance(node.parent, nodes.figure):
|
||||||
self.body.append('\\captionof{figure}{')
|
self.body.append('\\captionof{figure}{')
|
||||||
elif self.table and node.parent.tagname == 'figure':
|
elif self.table and node.parent.tagname == 'figure':
|
||||||
self.body.append('\\figcaption{')
|
self.body.append('\\sphinxfigcaption{')
|
||||||
else:
|
else:
|
||||||
self.body.append('\\caption{')
|
self.body.append('\\caption{')
|
||||||
|
|
||||||
@ -1689,9 +1695,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
# don't add a pageref for glossary terms
|
# don't add a pageref for glossary terms
|
||||||
self.context.append('}}}')
|
self.context.append('}}}')
|
||||||
# mark up as termreference
|
# mark up as termreference
|
||||||
self.body.append(r'\termref{')
|
self.body.append(r'\sphinxtermref{')
|
||||||
else:
|
else:
|
||||||
self.body.append(r'\crossref{')
|
self.body.append(r'\sphinxcrossref{')
|
||||||
if self.builder.config.latex_show_pagerefs and not \
|
if self.builder.config.latex_show_pagerefs and not \
|
||||||
self.in_production_list:
|
self.in_production_list:
|
||||||
self.context.append('}}} (%s)' % self.hyperpageref(id))
|
self.context.append('}}} (%s)' % self.hyperpageref(id))
|
||||||
@ -1779,7 +1785,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
return self.depart_literal_emphasis(node)
|
return self.depart_literal_emphasis(node)
|
||||||
|
|
||||||
def visit_title_reference(self, node):
|
def visit_title_reference(self, node):
|
||||||
self.body.append(r'\titleref{')
|
self.body.append(r'\sphinxtitleref{')
|
||||||
|
|
||||||
def depart_title_reference(self, node):
|
def depart_title_reference(self, node):
|
||||||
self.body.append('}')
|
self.body.append('}')
|
||||||
@ -1807,7 +1813,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
if self.in_title:
|
if self.in_title:
|
||||||
self.body.append(r'\texttt{')
|
self.body.append(r'\texttt{')
|
||||||
else:
|
else:
|
||||||
self.body.append(r'\code{')
|
self.body.append(r'\sphinxcode{')
|
||||||
|
|
||||||
def depart_literal(self, node):
|
def depart_literal(self, node):
|
||||||
self.no_contractions -= 1
|
self.no_contractions -= 1
|
||||||
@ -1855,7 +1861,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
ids += self.hypertarget(node['ids'][0], anchor=False)
|
ids += self.hypertarget(node['ids'][0], anchor=False)
|
||||||
# LaTeX code will insert \phantomsection prior to \label
|
# LaTeX code will insert \phantomsection prior to \label
|
||||||
if ids:
|
if ids:
|
||||||
self.body.append('\n\\def\\SphinxLiteralBlockLabel{' + ids + '}')
|
self.body.append('\n\\def\\sphinxLiteralBlockLabel{' + ids + '}')
|
||||||
code = node.astext()
|
code = node.astext()
|
||||||
lang = self.hlsettingstack[-1][0]
|
lang = self.hlsettingstack[-1][0]
|
||||||
linenos = code.count('\n') >= self.hlsettingstack[-1][1] - 1
|
linenos = code.count('\n') >= self.hlsettingstack[-1][1] - 1
|
||||||
@ -1890,7 +1896,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.body.append('\n' + hlcode + '\\end{%sVerbatim}\n' %
|
self.body.append('\n' + hlcode + '\\end{%sVerbatim}\n' %
|
||||||
(self.table and 'Original' or ''))
|
(self.table and 'Original' or ''))
|
||||||
if ids:
|
if ids:
|
||||||
self.body.append('\\let\\SphinxLiteralBlockLabel\empty\n')
|
self.body.append('\\let\\sphinxLiteralBlockLabel\empty\n')
|
||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
|
|
||||||
def depart_literal_block(self, node):
|
def depart_literal_block(self, node):
|
||||||
@ -2016,10 +2022,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
def visit_inline(self, node):
|
def visit_inline(self, node):
|
||||||
classes = node.get('classes', [])
|
classes = node.get('classes', [])
|
||||||
if classes in [['menuselection'], ['guilabel']]:
|
if classes in [['menuselection'], ['guilabel']]:
|
||||||
self.body.append(r'\menuselection{')
|
self.body.append(r'\sphinxmenuselection{')
|
||||||
self.context.append('}')
|
self.context.append('}')
|
||||||
elif classes in [['accelerator']]:
|
elif classes in [['accelerator']]:
|
||||||
self.body.append(r'\accelerator{')
|
self.body.append(r'\sphinxaccelerator{')
|
||||||
self.context.append('}')
|
self.context.append('}')
|
||||||
elif classes and not self.in_title:
|
elif classes and not self.in_title:
|
||||||
self.body.append(r'\DUrole{%s}{' % ','.join(classes))
|
self.body.append(r'\DUrole{%s}{' % ','.join(classes))
|
||||||
@ -2053,13 +2059,13 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
ids += self.hypertarget(node['ids'][0], anchor=False)
|
ids += self.hypertarget(node['ids'][0], anchor=False)
|
||||||
# define label for use in caption.
|
# define label for use in caption.
|
||||||
if ids:
|
if ids:
|
||||||
self.body.append('\n\\def\\SphinxLiteralBlockLabel{' + ids + '}\n')
|
self.body.append('\n\\def\\sphinxLiteralBlockLabel{' + ids + '}\n')
|
||||||
|
|
||||||
def depart_container(self, node):
|
def depart_container(self, node):
|
||||||
if node.get('literal_block'):
|
if node.get('literal_block'):
|
||||||
self.in_container_literal_block -= 1
|
self.in_container_literal_block -= 1
|
||||||
self.body.append('\\let\\SphinxVerbatimTitle\\empty\n')
|
self.body.append('\\let\\sphinxVerbatimTitle\\empty\n')
|
||||||
self.body.append('\\let\\SphinxLiteralBlockLabel\\empty\n')
|
self.body.append('\\let\\sphinxLiteralBlockLabel\\empty\n')
|
||||||
|
|
||||||
def visit_decoration(self, node):
|
def visit_decoration(self, node):
|
||||||
pass
|
pass
|
||||||
|
@ -112,9 +112,9 @@ def test_writer(app, status, warning):
|
|||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
|
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
|
||||||
|
|
||||||
assert ('\\begin{figure-in-table}\n\\centering\n\\capstart\n'
|
assert ('\\begin{sphinxfigure-in-table}\n\\centering\n\\capstart\n'
|
||||||
'\\includegraphics{{img}.png}\n'
|
'\\includegraphics{{img}.png}\n\\sphinxfigcaption'
|
||||||
'\\figcaption{figure in table}\\label{markup:id7}\\end{figure-in-table}' in result)
|
'{figure in table}\\label{markup:id7}\\end{sphinxfigure-in-table}' in result)
|
||||||
|
|
||||||
assert ('\\begin{wrapfigure}{r}{0pt}\n\\centering\n'
|
assert ('\\begin{wrapfigure}{r}{0pt}\n\\centering\n'
|
||||||
'\\includegraphics{{rimg}.png}\n\\caption{figure with align option}'
|
'\\includegraphics{{rimg}.png}\n\\caption{figure with align option}'
|
||||||
@ -409,7 +409,7 @@ def test_footnote(app, status, warning):
|
|||||||
assert '\\footnote[1]{\sphinxAtStartFootnote%\nnumbered\n}' in result
|
assert '\\footnote[1]{\sphinxAtStartFootnote%\nnumbered\n}' in result
|
||||||
assert '\\footnote[2]{\sphinxAtStartFootnote%\nauto numbered\n}' in result
|
assert '\\footnote[2]{\sphinxAtStartFootnote%\nauto numbered\n}' in result
|
||||||
assert '\\footnote[3]{\sphinxAtStartFootnote%\nnamed\n}' in result
|
assert '\\footnote[3]{\sphinxAtStartFootnote%\nnamed\n}' in result
|
||||||
assert '{\\hyperref[footnote:bar]{\\crossref{{[}bar{]}}}}' in result
|
assert '{\\hyperref[footnote:bar]{\\sphinxcrossref{{[}bar{]}}}}' in result
|
||||||
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} ' in result
|
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} ' in result
|
||||||
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} \ncite' in result
|
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} \ncite' in result
|
||||||
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} \ncite\n}' in result
|
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} \ncite\n}' in result
|
||||||
@ -428,7 +428,7 @@ def test_reference_in_caption(app, status, warning):
|
|||||||
print(status.getvalue())
|
print(status.getvalue())
|
||||||
print(warning.getvalue())
|
print(warning.getvalue())
|
||||||
assert ('\\caption{This is the figure caption with a reference to \\label{index:id2}'
|
assert ('\\caption{This is the figure caption with a reference to \\label{index:id2}'
|
||||||
'{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}.}' in result)
|
'{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}.}' in result)
|
||||||
assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result
|
assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result
|
||||||
assert '\\caption{The table title with a reference to {[}AuthorYear{]}}' in result
|
assert '\\caption{The table title with a reference to {[}AuthorYear{]}}' in result
|
||||||
assert '\\paragraph{The rubric title with a reference to {[}AuthorYear{]}}' in result
|
assert '\\paragraph{The rubric title with a reference to {[}AuthorYear{]}}' in result
|
||||||
@ -462,11 +462,12 @@ def test_latex_show_urls_is_inline(app, status, warning):
|
|||||||
'footnote in baz\n} in baz.rst' in result)
|
'footnote in baz\n} in baz.rst' in result)
|
||||||
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
||||||
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
||||||
'{\\crossref{The section with a reference to \\phantomsection\\label{index:id1}'
|
'{\\sphinxcrossref{The section with a reference to '
|
||||||
'{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}}}}' in result)
|
'\\phantomsection\\label{index:id1}'
|
||||||
|
'{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}}}}' in result)
|
||||||
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
|
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
|
||||||
'\\string-with\\string-a\\string-reference\\string-to]'
|
'\\string-with\\string-a\\string-reference\\string-to]'
|
||||||
'{\\crossref{The section with a reference to }}}' in result)
|
'{\\sphinxcrossref{The section with a reference to }}}' in result)
|
||||||
assert 'First footnote: \\footnote[2]{\sphinxAtStartFootnote%\nFirst\n}' in result
|
assert 'First footnote: \\footnote[2]{\sphinxAtStartFootnote%\nFirst\n}' in result
|
||||||
assert 'Second footnote: \\footnote[1]{\sphinxAtStartFootnote%\nSecond\n}' in result
|
assert 'Second footnote: \\footnote[1]{\sphinxAtStartFootnote%\nSecond\n}' in result
|
||||||
assert '\\href{http://sphinx-doc.org/}{Sphinx} (http://sphinx-doc.org/)' in result
|
assert '\\href{http://sphinx-doc.org/}{Sphinx} (http://sphinx-doc.org/)' in result
|
||||||
@ -499,11 +500,12 @@ def test_latex_show_urls_is_footnote(app, status, warning):
|
|||||||
'footnote in baz\n} in baz.rst' in result)
|
'footnote in baz\n} in baz.rst' in result)
|
||||||
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
||||||
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
||||||
'{\\crossref{The section with a reference to \\phantomsection\\label{index:id1}'
|
'{\\sphinxcrossref{The section with a reference '
|
||||||
'{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}}}}' in result)
|
'to \\phantomsection\\label{index:id1}'
|
||||||
|
'{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}}}}' in result)
|
||||||
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
|
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
|
||||||
'\\string-with\\string-a\\string-reference\\string-to]'
|
'\\string-with\\string-a\\string-reference\\string-to]'
|
||||||
'{\\crossref{The section with a reference to }}}' in result)
|
'{\\sphinxcrossref{The section with a reference to }}}' in result)
|
||||||
assert 'First footnote: \\footnote[3]{\sphinxAtStartFootnote%\nFirst\n}' in result
|
assert 'First footnote: \\footnote[3]{\sphinxAtStartFootnote%\nFirst\n}' in result
|
||||||
assert 'Second footnote: \\footnote[1]{\sphinxAtStartFootnote%\nSecond\n}' in result
|
assert 'Second footnote: \\footnote[1]{\sphinxAtStartFootnote%\nSecond\n}' in result
|
||||||
assert ('\\href{http://sphinx-doc.org/}{Sphinx}'
|
assert ('\\href{http://sphinx-doc.org/}{Sphinx}'
|
||||||
@ -542,11 +544,12 @@ def test_latex_show_urls_is_no(app, status, warning):
|
|||||||
'footnote in baz\n} in baz.rst' in result)
|
'footnote in baz\n} in baz.rst' in result)
|
||||||
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
||||||
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
||||||
'{\\crossref{The section with a reference to \\phantomsection\\label{index:id1}'
|
'{\\sphinxcrossref{The section with a reference '
|
||||||
'{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}}}}' in result)
|
'to \\phantomsection\\label{index:id1}'
|
||||||
|
'{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}}}}' in result)
|
||||||
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
|
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
|
||||||
'\\string-with\\string-a\\string-reference\\string-to]'
|
'\\string-with\\string-a\\string-reference\\string-to]'
|
||||||
'{\\crossref{The section with a reference to }}}' in result)
|
'{\\sphinxcrossref{The section with a reference to }}}' in result)
|
||||||
assert 'First footnote: \\footnote[2]{\sphinxAtStartFootnote%\nFirst\n}' in result
|
assert 'First footnote: \\footnote[2]{\sphinxAtStartFootnote%\nFirst\n}' in result
|
||||||
assert 'Second footnote: \\footnote[1]{\sphinxAtStartFootnote%\nSecond\n}' in result
|
assert 'Second footnote: \\footnote[1]{\sphinxAtStartFootnote%\nSecond\n}' in result
|
||||||
assert '\\href{http://sphinx-doc.org/}{Sphinx}' in result
|
assert '\\href{http://sphinx-doc.org/}{Sphinx}' in result
|
||||||
|
@ -65,8 +65,8 @@ def test_code_block_caption_html(app, status, warning):
|
|||||||
def test_code_block_caption_latex(app, status, warning):
|
def test_code_block_caption_latex(app, status, warning):
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
||||||
caption = '\\SphinxSetupCaptionForVerbatim{literal-block}{caption \\emph{test} rb}'
|
caption = '\\sphinxSetupCaptionForVerbatim{literal-block}{caption \\emph{test} rb}'
|
||||||
label = '\\def\\SphinxLiteralBlockLabel{\\label{caption:caption-test-rb}}'
|
label = '\\def\\sphinxLiteralBlockLabel{\\label{caption:caption-test-rb}}'
|
||||||
link = '\hyperref[caption:caption-test-rb]' \
|
link = '\hyperref[caption:caption-test-rb]' \
|
||||||
'{Listing \\ref{caption:caption-test-rb}}'
|
'{Listing \\ref{caption:caption-test-rb}}'
|
||||||
assert caption in latex
|
assert caption in latex
|
||||||
@ -78,12 +78,12 @@ def test_code_block_caption_latex(app, status, warning):
|
|||||||
def test_code_block_namedlink_latex(app, status, warning):
|
def test_code_block_namedlink_latex(app, status, warning):
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
||||||
label1 = '\def\SphinxLiteralBlockLabel{\label{caption:name-test-rb}}'
|
label1 = '\def\sphinxLiteralBlockLabel{\label{caption:name-test-rb}}'
|
||||||
link1 = '\\hyperref[caption:name\\string-test\\string-rb]'\
|
link1 = '\\hyperref[caption:name\\string-test\\string-rb]'\
|
||||||
'{\\crossref{\\DUrole{std,std-ref}{Ruby}}'
|
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Ruby}}'
|
||||||
label2 = '\def\SphinxLiteralBlockLabel{\label{namedblocks:some-ruby-code}}'
|
label2 = '\def\sphinxLiteralBlockLabel{\label{namedblocks:some-ruby-code}}'
|
||||||
link2 = '\\hyperref[namedblocks:some\\string-ruby\\string-code]'\
|
link2 = '\\hyperref[namedblocks:some\\string-ruby\\string-code]'\
|
||||||
'{\\crossref{\\DUrole{std,std-ref}{the ruby code}}}'
|
'{\\sphinxcrossref{\\DUrole{std,std-ref}{the ruby code}}}'
|
||||||
assert label1 in latex
|
assert label1 in latex
|
||||||
assert link1 in latex
|
assert link1 in latex
|
||||||
assert label2 in latex
|
assert label2 in latex
|
||||||
@ -252,8 +252,8 @@ def test_literalinclude_caption_html(app, status, warning):
|
|||||||
def test_literalinclude_caption_latex(app, status, warning):
|
def test_literalinclude_caption_latex(app, status, warning):
|
||||||
app.builder.build('index')
|
app.builder.build('index')
|
||||||
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
||||||
caption = '\\SphinxSetupCaptionForVerbatim{literal-block}{caption \\textbf{test} py}'
|
caption = '\\sphinxSetupCaptionForVerbatim{literal-block}{caption \\textbf{test} py}'
|
||||||
label = '\\def\\SphinxLiteralBlockLabel{\\label{caption:caption-test-py}}'
|
label = '\\def\\sphinxLiteralBlockLabel{\\label{caption:caption-test-py}}'
|
||||||
link = '\hyperref[caption:caption-test-py]' \
|
link = '\hyperref[caption:caption-test-py]' \
|
||||||
'{Listing \\ref{caption:caption-test-py}}'
|
'{Listing \\ref{caption:caption-test-py}}'
|
||||||
assert caption in latex
|
assert caption in latex
|
||||||
@ -265,12 +265,12 @@ def test_literalinclude_caption_latex(app, status, warning):
|
|||||||
def test_literalinclude_namedlink_latex(app, status, warning):
|
def test_literalinclude_namedlink_latex(app, status, warning):
|
||||||
app.builder.build('index')
|
app.builder.build('index')
|
||||||
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
||||||
label1 = '\def\SphinxLiteralBlockLabel{\label{caption:name-test-py}}'
|
label1 = '\def\sphinxLiteralBlockLabel{\label{caption:name-test-py}}'
|
||||||
link1 = '\\hyperref[caption:name\\string-test\\string-py]'\
|
link1 = '\\hyperref[caption:name\\string-test\\string-py]'\
|
||||||
'{\\crossref{\\DUrole{std,std-ref}{Python}}'
|
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Python}}'
|
||||||
label2 = '\def\SphinxLiteralBlockLabel{\label{namedblocks:some-python-code}}'
|
label2 = '\def\sphinxLiteralBlockLabel{\label{namedblocks:some-python-code}}'
|
||||||
link2 = '\\hyperref[namedblocks:some\\string-python\\string-code]'\
|
link2 = '\\hyperref[namedblocks:some\\string-python\\string-code]'\
|
||||||
'{\\crossref{\\DUrole{std,std-ref}{the python code}}}'
|
'{\\sphinxcrossref{\\DUrole{std,std-ref}{the python code}}}'
|
||||||
assert label1 in latex
|
assert label1 in latex
|
||||||
assert link1 in latex
|
assert link1 in latex
|
||||||
assert label2 in latex
|
assert label2 in latex
|
||||||
|
@ -93,32 +93,32 @@ def test_inline():
|
|||||||
# correct interpretation of code with whitespace
|
# correct interpretation of code with whitespace
|
||||||
_html = ('<p><code class="(samp )?docutils literal"><span class="pre">'
|
_html = ('<p><code class="(samp )?docutils literal"><span class="pre">'
|
||||||
'code</span> <span class="pre">sample</span></code></p>')
|
'code</span> <span class="pre">sample</span></code></p>')
|
||||||
yield verify_re, '``code sample``', _html, r'\\code{code sample}'
|
yield verify_re, '``code sample``', _html, r'\\sphinxcode{code sample}'
|
||||||
yield verify_re, ':samp:`code sample`', _html, r'\\code{code sample}'
|
yield verify_re, ':samp:`code sample`', _html, r'\\sphinxcode{code sample}'
|
||||||
|
|
||||||
# interpolation of braces in samp and file roles (HTML only)
|
# interpolation of braces in samp and file roles (HTML only)
|
||||||
yield (verify, ':samp:`a{b}c`',
|
yield (verify, ':samp:`a{b}c`',
|
||||||
'<p><code class="samp docutils literal"><span class="pre">a</span>'
|
'<p><code class="samp docutils literal"><span class="pre">a</span>'
|
||||||
'<em><span class="pre">b</span></em>'
|
'<em><span class="pre">b</span></em>'
|
||||||
'<span class="pre">c</span></code></p>',
|
'<span class="pre">c</span></code></p>',
|
||||||
'\\code{a\\emph{b}c}')
|
'\\sphinxcode{a\\emph{b}c}')
|
||||||
|
|
||||||
# interpolation of arrows in menuselection
|
# interpolation of arrows in menuselection
|
||||||
yield (verify, ':menuselection:`a --> b`',
|
yield (verify, ':menuselection:`a --> b`',
|
||||||
u'<p><span class="menuselection">a \N{TRIANGULAR BULLET} b</span></p>',
|
u'<p><span class="menuselection">a \N{TRIANGULAR BULLET} b</span></p>',
|
||||||
'\\menuselection{a \\(\\rightarrow\\) b}')
|
'\\sphinxmenuselection{a \\(\\rightarrow\\) b}')
|
||||||
|
|
||||||
# interpolation of ampersands in guilabel/menuselection
|
# interpolation of ampersands in guilabel/menuselection
|
||||||
yield (verify, ':guilabel:`&Foo -&&- &Bar`',
|
yield (verify, ':guilabel:`&Foo -&&- &Bar`',
|
||||||
u'<p><span class="guilabel"><span class="accelerator">F</span>oo '
|
u'<p><span class="guilabel"><span class="accelerator">F</span>oo '
|
||||||
'-&- <span class="accelerator">B</span>ar</span></p>',
|
'-&- <span class="accelerator">B</span>ar</span></p>',
|
||||||
r'\menuselection{\accelerator{F}oo -\&- \accelerator{B}ar}')
|
r'\sphinxmenuselection{\sphinxaccelerator{F}oo -\&- \sphinxaccelerator{B}ar}')
|
||||||
|
|
||||||
# non-interpolation of dashes in option role
|
# non-interpolation of dashes in option role
|
||||||
yield (verify_re, ':option:`--with-option`',
|
yield (verify_re, ':option:`--with-option`',
|
||||||
'<p><code( class="xref std std-option docutils literal")?>'
|
'<p><code( class="xref std std-option docutils literal")?>'
|
||||||
'<span class="pre">--with-option</span></code></p>$',
|
'<span class="pre">--with-option</span></code></p>$',
|
||||||
r'\\code{-{-}with-option}$')
|
r'\\sphinxcode{-{-}with-option}$')
|
||||||
|
|
||||||
# verify smarty-pants quotes
|
# verify smarty-pants quotes
|
||||||
yield verify, '"John"', '<p>“John”</p>', "``John''"
|
yield verify, '"John"', '<p>“John”</p>', "``John''"
|
||||||
@ -126,7 +126,7 @@ def test_inline():
|
|||||||
yield (verify, '``"John"``',
|
yield (verify, '``"John"``',
|
||||||
'<p><code class="docutils literal"><span class="pre">'
|
'<p><code class="docutils literal"><span class="pre">'
|
||||||
'"John"</span></code></p>',
|
'"John"</span></code></p>',
|
||||||
'\\code{"John"}')
|
'\\sphinxcode{"John"}')
|
||||||
|
|
||||||
# verify classes for inline roles
|
# verify classes for inline roles
|
||||||
yield (verify, ':manpage:`mp(1)`',
|
yield (verify, ':manpage:`mp(1)`',
|
||||||
|
Loading…
Reference in New Issue
Block a user