Commit ad74b7d4 authored by Fred Drake's avatar Fred Drake

Abstract the creation of signature lines for callable things; the new

\py@sigline macro will wrap the argument list so it will not extend into
the right margin.
Substantially based on a contribution from Dave Cole.
This addresses one of the comments in SF bug #574742.
parent a98011c3
...@@ -40,6 +40,7 @@ Mauro Cicognini ...@@ -40,6 +40,7 @@ Mauro Cicognini
Gilles Civario Gilles Civario
Mike Clarkson Mike Clarkson
Steve Clift Steve Clift
Dave Cole
Matthew Cowles Matthew Cowles
Jeremy Craven Jeremy Craven
Andrew Dalke Andrew Dalke
......
...@@ -581,12 +581,23 @@ ...@@ -581,12 +581,23 @@
% something else. % something else.
\newcommand{\py@unspecified}{...} \newcommand{\py@unspecified}{...}
\newlength{\py@argswidth}
\newcommand{\py@sigparams}[1]{%
\parbox[t]{\py@argswidth}{\py@varvars{#1}\code{)}}}
\newcommand{\py@sigline}[2]{%
\settowidth{\py@argswidth}{#1\code{(}}%
\addtolength{\py@argswidth}{-2\py@argswidth}%
\addtolength{\py@argswidth}{\textwidth}%
\item[#1\code{(}\py@sigparams{#2}]}
% C functions ------------------------------------------------------------ % C functions ------------------------------------------------------------
% \begin{cfuncdesc}[refcount]{type}{name}{arglist} % \begin{cfuncdesc}[refcount]{type}{name}{arglist}
% Note that the [refcount] slot should only be filled in by % Note that the [refcount] slot should only be filled in by
% tools/anno-api.py; it pulls the value from the refcounts database. % tools/anno-api.py; it pulls the value from the refcounts database.
\newcommand{\cfuncline}[3]{ \newcommand{\cfuncline}[3]{
\item[\code{#1 \bfcode{#2}(\py@varvars{#3})}\index{#2@{\py@idxcode{#2()}}}] \py@sigline{\code{#1 \bfcode{#2}}}{#3}%
\index{#2@{\py@idxcode{#2()}}}
} }
\newenvironment{cfuncdesc}[4][\py@badkey]{ \newenvironment{cfuncdesc}[4][\py@badkey]{
\begin{fulllineitems} \begin{fulllineitems}
...@@ -645,7 +656,8 @@ ...@@ -645,7 +656,8 @@
}{\end{fulllineitems}} }{\end{fulllineitems}}
% similar to {funcdesc}, but doesn't add to the index % similar to {funcdesc}, but doesn't add to the index
\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\py@varvars{#2})}]} \newcommand{\funclineni}[2]{%
\py@sigline{\bfcode{#1}}{#2}}
\newenvironment{funcdescni}[2]{ \newenvironment{funcdescni}[2]{
\begin{fulllineitems} \begin{fulllineitems}
\funclineni{#1}{#2} \funclineni{#1}{#2}
...@@ -657,8 +669,8 @@ ...@@ -657,8 +669,8 @@
% Using \renewcommand doesn't work for this, for unknown reasons: % Using \renewcommand doesn't work for this, for unknown reasons:
\global\def\py@thisclass{#1} \global\def\py@thisclass{#1}
\begin{fulllineitems} \begin{fulllineitems}
\item[\strong{class }\code{\bfcode{#1}(\py@varvars{#2})}% \py@sigline{\strong{class }\bfcode{#1}}{#2}%
\index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}] \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}
}{\end{fulllineitems}} }{\end{fulllineitems}}
% \begin{classdesc*}{name} % \begin{classdesc*}{name}
...@@ -676,8 +688,8 @@ ...@@ -676,8 +688,8 @@
% Using \renewcommand doesn't work for this, for unknown reasons: % Using \renewcommand doesn't work for this, for unknown reasons:
\global\def\py@thisclass{#1} \global\def\py@thisclass{#1}
\begin{fulllineitems} \begin{fulllineitems}
\item[\strong{exception }\code{\bfcode{#1}(\py@varvars{#2})}% \py@sigline{\strong{exception }\bfcode{#1}}{#2}%
\index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}] \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}
}{\end{fulllineitems}} }{\end{fulllineitems}}
% There is no corresponding {excclassdesc*} environment. To describe % There is no corresponding {excclassdesc*} environment. To describe
...@@ -709,7 +721,7 @@ ...@@ -709,7 +721,7 @@
% similar to {methoddesc}, but doesn't add to the index % similar to {methoddesc}, but doesn't add to the index
% (never actually uses the optional argument) % (never actually uses the optional argument)
\newcommand{\methodlineni}[3][\py@classbadkey]{% \newcommand{\methodlineni}[3][\py@classbadkey]{%
\item[\code{\bfcode{#2}(\py@varvars{#3})}]} \py@sigline{\bfcode{#2}}{#3}}
\newenvironment{methoddescni}[3][\py@classbadkey]{ \newenvironment{methoddescni}[3][\py@classbadkey]{
\begin{fulllineitems} \begin{fulllineitems}
\methodlineni{#2}{#3} \methodlineni{#2}{#3}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment