1*7f2fe78bSCy Schubert%% MODULE RELEASE DATA AND OBJECT DESCRIPTIONS 2*7f2fe78bSCy Schubert% 3*7f2fe78bSCy Schubert% change this info string if making any custom modification 4*7f2fe78bSCy Schubert\ProvidesFile{sphinxlatexobjects.sty}[2021/01/27 documentation environments] 5*7f2fe78bSCy Schubert 6*7f2fe78bSCy Schubert% Provides support for this output mark-up from Sphinx latex writer: 7*7f2fe78bSCy Schubert% 8*7f2fe78bSCy Schubert% - environments 9*7f2fe78bSCy Schubert% 10*7f2fe78bSCy Schubert% - fulllineitems 11*7f2fe78bSCy Schubert% - productionlist 12*7f2fe78bSCy Schubert% - optionlist 13*7f2fe78bSCy Schubert% - DUlineblock (also "lineblock") 14*7f2fe78bSCy Schubert% 15*7f2fe78bSCy Schubert% - macros 16*7f2fe78bSCy Schubert% 17*7f2fe78bSCy Schubert% - \DUrole 18*7f2fe78bSCy Schubert% - various legacy support macros related to author and release 19*7f2fe78bSCy Schubert% data of documented objects and modules. 20*7f2fe78bSCy Schubert 21*7f2fe78bSCy Schubert% \moduleauthor{name}{email} 22*7f2fe78bSCy Schubert\newcommand{\moduleauthor}[2]{} 23*7f2fe78bSCy Schubert 24*7f2fe78bSCy Schubert% \sectionauthor{name}{email} 25*7f2fe78bSCy Schubert\newcommand{\sectionauthor}[2]{} 26*7f2fe78bSCy Schubert 27*7f2fe78bSCy Schubert% Allow the release number to be specified independently of the 28*7f2fe78bSCy Schubert% \date{}. This allows the date to reflect the document's date and 29*7f2fe78bSCy Schubert% release to specify the release that is documented. 30*7f2fe78bSCy Schubert% 31*7f2fe78bSCy Schubert\newcommand{\py@release}{\releasename\space\version} 32*7f2fe78bSCy Schubert\newcommand{\version}{}% part of \py@release, used by title page and headers 33*7f2fe78bSCy Schubert% \releaseinfo is used on titlepage (sphinxmanual.cls, sphinxhowto.cls) 34*7f2fe78bSCy Schubert\newcommand{\releaseinfo}{} 35*7f2fe78bSCy Schubert\newcommand{\setreleaseinfo}[1]{\renewcommand{\releaseinfo}{#1}} 36*7f2fe78bSCy Schubert% this is inserted via template and #1=release config variable 37*7f2fe78bSCy Schubert\newcommand{\release}[1]{\renewcommand{\version}{#1}} 38*7f2fe78bSCy Schubert% this is defined by template to 'releasename' latex_elements key 39*7f2fe78bSCy Schubert\newcommand{\releasename}{} 40*7f2fe78bSCy Schubert% Fix issue in case release and releasename deliberately left blank 41*7f2fe78bSCy Schubert\newcommand{\sphinxheadercomma}{, }% used in fancyhdr header definition 42*7f2fe78bSCy Schubert\newcommand{\sphinxifemptyorblank}[1]{% 43*7f2fe78bSCy Schubert% test after one expansion of macro #1 if contents is empty or spaces 44*7f2fe78bSCy Schubert \if&\expandafter\@firstofone\detokenize\expandafter{#1}&% 45*7f2fe78bSCy Schubert \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}% 46*7f2fe78bSCy Schubert\AtBeginDocument {% 47*7f2fe78bSCy Schubert \sphinxifemptyorblank{\releasename} 48*7f2fe78bSCy Schubert {\sphinxifemptyorblank{\version}{\let\sphinxheadercomma\empty}{}} 49*7f2fe78bSCy Schubert {}% 50*7f2fe78bSCy Schubert}% 51*7f2fe78bSCy Schubert 52*7f2fe78bSCy Schubert% Allow specification of the author's address separately from the 53*7f2fe78bSCy Schubert% author's name. This can be used to format them differently, which 54*7f2fe78bSCy Schubert% is a good thing. 55*7f2fe78bSCy Schubert% 56*7f2fe78bSCy Schubert\newcommand{\py@authoraddress}{} 57*7f2fe78bSCy Schubert\newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}} 58*7f2fe78bSCy Schubert 59*7f2fe78bSCy Schubert% {fulllineitems} is the main environment for object descriptions. 60*7f2fe78bSCy Schubert% 61*7f2fe78bSCy Schubert% With 4.0.0 \pysigline (and \pysiglinewithargsret), used in a fulllineitems 62*7f2fe78bSCy Schubert% environment the #1 will already be of the width which is computed here, i.e. 63*7f2fe78bSCy Schubert% the available width on line, so the \makebox becomes a bit superfluous 64*7f2fe78bSCy Schubert\newcommand{\py@itemnewline}[1]{% macro used as \makelabel in fulllineitems 65*7f2fe78bSCy Schubert% Memo: this presupposes \itemindent is 0pt 66*7f2fe78bSCy Schubert \kern\labelsep % because \@labels core latex box does \hskip-\labelsep 67*7f2fe78bSCy Schubert \makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}% 68*7f2fe78bSCy Schubert \kern-\labelsep % because at end of \@labels box there is \hskip\labelsep 69*7f2fe78bSCy Schubert} 70*7f2fe78bSCy Schubert 71*7f2fe78bSCy Schubert\newenvironment{fulllineitems}{% 72*7f2fe78bSCy Schubert \begin{list}{}{\labelwidth \leftmargin 73*7f2fe78bSCy Schubert \rightmargin \z@ \topsep -\parskip \partopsep \parskip 74*7f2fe78bSCy Schubert \itemsep -\parsep 75*7f2fe78bSCy Schubert \let\makelabel=\py@itemnewline}% 76*7f2fe78bSCy Schubert}{\end{list}} 77*7f2fe78bSCy Schubert 78*7f2fe78bSCy Schubert% Signatures, possibly multi-line 79*7f2fe78bSCy Schubert% 80*7f2fe78bSCy Schubert\newlength{\py@argswidth} 81*7f2fe78bSCy Schubert\newcommand{\py@sigparams}[2]{% 82*7f2fe78bSCy Schubert % The \py@argswidth has been computed in \pysiglinewithargsret to make this 83*7f2fe78bSCy Schubert % occupy full available width on line. 84*7f2fe78bSCy Schubert \parbox[t]{\py@argswidth}{\raggedright #1\sphinxcode{)}#2\strut}% 85*7f2fe78bSCy Schubert % final strut is to help get correct vertical separation in case of multi-line 86*7f2fe78bSCy Schubert % box with the item contents. 87*7f2fe78bSCy Schubert} 88*7f2fe78bSCy Schubert\newcommand{\pysigline}[1]{% 89*7f2fe78bSCy Schubert% the \py@argswidth is available we use it despite its name (no "args" here) 90*7f2fe78bSCy Schubert% the \relax\relax is because \py@argswidth is a "skip" variable and the first 91*7f2fe78bSCy Schubert% \relax only ends its "dimen" part 92*7f2fe78bSCy Schubert \py@argswidth=\dimexpr\linewidth+\labelwidth\relax\relax 93*7f2fe78bSCy Schubert \item[{\parbox[t]{\py@argswidth}{\raggedright #1\strut}}] 94*7f2fe78bSCy Schubert% contrarily to \pysiglinewithargsret, we do not do this: 95*7f2fe78bSCy Schubert% \leavevmode\par\nobreak\vskip-\parskip\prevdepth\dp\strutbox 96*7f2fe78bSCy Schubert% which would give exact vertical spacing if item parbox is multi-line, 97*7f2fe78bSCy Schubert% as it affects negatively more common situation of \pysigline 98*7f2fe78bSCy Schubert% used twice or more in a row for labels sharing common description, 99*7f2fe78bSCy Schubert% due to bad interaction with the \phantomsection in the mark-up 100*7f2fe78bSCy Schubert} 101*7f2fe78bSCy Schubert\newcommand{\pysiglinewithargsret}[3]{% 102*7f2fe78bSCy Schubert \settowidth{\py@argswidth}{#1\sphinxcode{(}}% 103*7f2fe78bSCy Schubert \py@argswidth=\dimexpr\linewidth+\labelwidth-\py@argswidth\relax\relax 104*7f2fe78bSCy Schubert \item[{#1\sphinxcode{(}\py@sigparams{#2}{#3}}] 105*7f2fe78bSCy Schubert% this strange incantation is because at its root LaTeX in fact did not 106*7f2fe78bSCy Schubert% imagine a multi-line label, it is always wrapped in a horizontal box at core 107*7f2fe78bSCy Schubert% LaTeX level and we have to find tricks to get correct interline distances. 108*7f2fe78bSCy Schubert \leavevmode\par\nobreak\vskip-\parskip\prevdepth\dp\strutbox} 109*7f2fe78bSCy Schubert\newcommand{\pysigstartmultiline}{% 110*7f2fe78bSCy Schubert \def\pysigstartmultiline{\vskip\smallskipamount\parskip\z@skip\itemsep\z@skip}% 111*7f2fe78bSCy Schubert \edef\pysigstopmultiline 112*7f2fe78bSCy Schubert {\noexpand\leavevmode\parskip\the\parskip\relax\itemsep\the\itemsep\relax}% 113*7f2fe78bSCy Schubert \parskip\z@skip\itemsep\z@skip 114*7f2fe78bSCy Schubert} 115*7f2fe78bSCy Schubert 116*7f2fe78bSCy Schubert% Production lists 117*7f2fe78bSCy Schubert% 118*7f2fe78bSCy Schubert\newenvironment{productionlist}{% 119*7f2fe78bSCy Schubert% \def\sphinxoptional##1{{\Large[}##1{\Large]}} 120*7f2fe78bSCy Schubert \def\production##1##2{\\\sphinxcode{\sphinxupquote{##1}}&::=&\sphinxcode{\sphinxupquote{##2}}}% 121*7f2fe78bSCy Schubert \def\productioncont##1{\\& &\sphinxcode{\sphinxupquote{##1}}}% 122*7f2fe78bSCy Schubert \parindent=2em 123*7f2fe78bSCy Schubert \indent 124*7f2fe78bSCy Schubert \setlength{\LTpre}{0pt}% 125*7f2fe78bSCy Schubert \setlength{\LTpost}{0pt}% 126*7f2fe78bSCy Schubert \begin{longtable}[l]{lcl} 127*7f2fe78bSCy Schubert}{% 128*7f2fe78bSCy Schubert \end{longtable} 129*7f2fe78bSCy Schubert} 130*7f2fe78bSCy Schubert 131*7f2fe78bSCy Schubert% Definition lists; requested by AMK for HOWTO documents. Probably useful 132*7f2fe78bSCy Schubert% elsewhere as well, so keep in in the general style support. 133*7f2fe78bSCy Schubert% 134*7f2fe78bSCy Schubert\newenvironment{definitions}{% 135*7f2fe78bSCy Schubert \begin{description}% 136*7f2fe78bSCy Schubert \def\term##1{\item[{##1}]\mbox{}\\*[0mm]}% 137*7f2fe78bSCy Schubert}{% 138*7f2fe78bSCy Schubert \end{description}% 139*7f2fe78bSCy Schubert} 140*7f2fe78bSCy Schubert 141*7f2fe78bSCy Schubert%% FROM DOCTUTILS LATEX WRITER 142*7f2fe78bSCy Schubert% 143*7f2fe78bSCy Schubert% The following is stuff copied from docutils' latex writer. 144*7f2fe78bSCy Schubert% 145*7f2fe78bSCy Schubert\newcommand{\optionlistlabel}[1]{\normalfont\bfseries #1 \hfill}% \bf deprecated 146*7f2fe78bSCy Schubert\newenvironment{optionlist}[1] 147*7f2fe78bSCy Schubert{\begin{list}{} 148*7f2fe78bSCy Schubert {\setlength{\labelwidth}{#1} 149*7f2fe78bSCy Schubert \setlength{\rightmargin}{1cm} 150*7f2fe78bSCy Schubert \setlength{\leftmargin}{\rightmargin} 151*7f2fe78bSCy Schubert \addtolength{\leftmargin}{\labelwidth} 152*7f2fe78bSCy Schubert \addtolength{\leftmargin}{\labelsep} 153*7f2fe78bSCy Schubert \renewcommand{\makelabel}{\optionlistlabel}} 154*7f2fe78bSCy Schubert}{\end{list}} 155*7f2fe78bSCy Schubert 156*7f2fe78bSCy Schubert\newlength{\lineblockindentation} 157*7f2fe78bSCy Schubert\setlength{\lineblockindentation}{2.5em} 158*7f2fe78bSCy Schubert\newenvironment{lineblock}[1] 159*7f2fe78bSCy Schubert{\begin{list}{} 160*7f2fe78bSCy Schubert {\setlength{\partopsep}{\parskip} 161*7f2fe78bSCy Schubert \addtolength{\partopsep}{\baselineskip} 162*7f2fe78bSCy Schubert \topsep0pt\itemsep0.15\baselineskip\parsep0pt 163*7f2fe78bSCy Schubert \leftmargin#1\relax} 164*7f2fe78bSCy Schubert \raggedright} 165*7f2fe78bSCy Schubert{\end{list}} 166*7f2fe78bSCy Schubert 167*7f2fe78bSCy Schubert% From docutils.writers.latex2e 168*7f2fe78bSCy Schubert% inline markup (custom roles) 169*7f2fe78bSCy Schubert% \DUrole{#1}{#2} tries \DUrole#1{#2} 170*7f2fe78bSCy Schubert\providecommand*{\DUrole}[2]{% 171*7f2fe78bSCy Schubert \ifcsname DUrole\detokenize{#1}\endcsname 172*7f2fe78bSCy Schubert \csname DUrole\detokenize{#1}\endcsname{#2}% 173*7f2fe78bSCy Schubert \else% backwards compatibility: try \docutilsrole#1{#2} 174*7f2fe78bSCy Schubert \ifcsname docutilsrole\detokenize{#1}\endcsname 175*7f2fe78bSCy Schubert \csname docutilsrole\detokenize{#1}\endcsname{#2}% 176*7f2fe78bSCy Schubert \else 177*7f2fe78bSCy Schubert #2% 178*7f2fe78bSCy Schubert \fi 179*7f2fe78bSCy Schubert \fi 180*7f2fe78bSCy Schubert} 181*7f2fe78bSCy Schubert 182*7f2fe78bSCy Schubert\providecommand*{\DUprovidelength}[2]{% 183*7f2fe78bSCy Schubert \ifdefined#1\else\newlength{#1}\setlength{#1}{#2}\fi 184*7f2fe78bSCy Schubert} 185*7f2fe78bSCy Schubert 186*7f2fe78bSCy Schubert\DUprovidelength{\DUlineblockindent}{2.5em} 187*7f2fe78bSCy Schubert\ifdefined\DUlineblock\else 188*7f2fe78bSCy Schubert \newenvironment{DUlineblock}[1]{% 189*7f2fe78bSCy Schubert \list{}{\setlength{\partopsep}{\parskip} 190*7f2fe78bSCy Schubert \addtolength{\partopsep}{\baselineskip} 191*7f2fe78bSCy Schubert \setlength{\topsep}{0pt} 192*7f2fe78bSCy Schubert \setlength{\itemsep}{0.15\baselineskip} 193*7f2fe78bSCy Schubert \setlength{\parsep}{0pt} 194*7f2fe78bSCy Schubert \setlength{\leftmargin}{#1}} 195*7f2fe78bSCy Schubert \raggedright 196*7f2fe78bSCy Schubert } 197*7f2fe78bSCy Schubert {\endlist} 198*7f2fe78bSCy Schubert\fi 199*7f2fe78bSCy Schubert 200*7f2fe78bSCy Schubert\endinput 201