8000 LaTeX: improve behavious of `\pysigline` and `\pysiglinewithargsret` in case of multi-line signature by jfbu · Pull Request #8997 · sphinx-doc/sphinx · GitHub
[go: up one dir, main page]

Skip to content

LaTeX: improve behavious of \pysigline and \pysiglinewithargsret in case of multi-line signature #8997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Bugs fixed
* #8915: html theme: The translation of sphinx_rtd_theme does not work
* #8342: Emit a warning if a unknown domain is given for directive or role (ex.
``:unknown:doc:``)
* #7241: LaTeX: No wrapping for ``cpp:enumerator``
* #8711: LaTeX: backticks in code-blocks trigger latexpdf build warning (and font
change) with late TeXLive 2019
* #8253: LaTeX: Figures with no size defined get overscaled (compared to images
Expand All @@ -101,6 +102,9 @@ Bugs fixed
Pygments style
* #8925: LaTeX: 3.5.0 ``verbatimmaxunderfull`` setting does not work as
expected
* #8980: LaTeX: missing line break in ``\pysigline``
* #8995: LaTeX: legacy ``\pysiglinewithargsret`` does not compute correctly
available horizontal space and should use a ragged right style
* #8911: C++: remove the longest matching prefix in
:confval:`cpp_index_common_prefix` instead of the first that matches.
* C, properly reject function declarations when a keyword is used
Expand Down
37 changes: 27 additions & 10 deletions sphinx/texinputs/sphinxlatexobjects.sty
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@

% {fulllineitems} is the main environment for object descriptions.
%
\newcommand{\py@itemnewline}[1]{%
\kern\labelsep
\@tempdima\linewidth
\advance\@tempdima \labelwidth\makebox[\@tempdima][l]{#1}%
\kern-\labelsep
% With 4.0.0 \pysigline (and \pysiglinewithargsret), used in a fulllineitems
% environment the #1 will already be of the width which is computed here, i.e.
% the available width on line, so the \makebox becomes a bit superfluous
\newcommand{\py@itemnewline}[1]{% macro used as \makelabel in fulllineitems
% Memo: this presupposes \itemindent is 0pt
\kern\labelsep % because \@labels core latex box does \hskip-\labelsep
\makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}%
\kern-\labelsep % because at end of \@labels box there is \hskip\labelsep
}

\newenvironment{fulllineitems}{%
Expand All @@ -76,13 +79,27 @@
%
\newlength{\py@argswidth}
\newcommand{\py@sigparams}[2]{%
\parbox[t]{\py@argswidth}{#1\sphinxcode{)}#2}}
\newcommand{\pysigline}[1]{\item[{#1}]}
% The \py@argswidth has been computed in \pysiglinewithargsret to make this
% occupy full available width on line.
\parbox[t]{\py@argswidth}{\raggedright #1\sphinxcode{)}#2\strut}%
% final strut is to help get correct vertical separation in case of multi-line
% box with the item contents.
}
\newcommand{\pysigline}[1]{%
% the \py@argswidth is available we use it despite its name (no "args" here)
% the \relax\relax is because \py@argswidth is a "skip" variable and the first
% \relax only ends its "dimen" part
\py@argswidth=\dimexpr\linewidth+\labelwidth\relax\relax
\item[{\parbox[t]{\py@argswidth}{\raggedright #1\strut}}]
% this strange incantation is because at its root LaTeX in fact did not
% imagine a multi-line label, it is always wrapped in a horizontal box at core
% LaTeX level and we have to find tricks to get correct interline distances.
\leavevmode\par\nobreak\vskip-\parskip\prevdepth\dp\strutbox}
\newcommand{\pysiglinewithargsret}[3]{%
\settowidth{\py@argswidth}{#1\sphinxcode{(}}%
\addtolength{\py@argswidth}{-2\py@argswidth}%
\addtolength{\py@argswidth}{\linewidth}%
\item[{#1\sphinxcode{(}\py@sigparams{#2}{#3}}]}
\py@argswidth=\dimexpr\linewidth+\labelwidth-\py@argswidth\relax\relax
\item[{#1\sphinxcode{(}\py@sigparams{#2}{#3}}]
\leavevmode\par\nobreak\vskip-\parskip\prevdepth\dp\strutbox}
\newcommand{\pysigstartmultiline}{%
\def\pysigstartmultiline{\vskip\smallskipamount\parskip\z@skip\itemsep\z@skip}%
\edef\pysigstopmultiline
Expand Down
0