Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 34adb8a

Browse files
committed
Separate out a \cfuncline macro from the cfuncdesc environment.
This matches many other of the *desc environments, and is useful when multiple functions share a description.
1 parent 1251b0e commit 34adb8a

2 files changed

Lines changed: 25 additions & 9 deletions

File tree

Doc/perl/python.perl

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -907,16 +907,29 @@ sub get_refcount{
907907
$TLSTART = '<span class="typelabel">';
908908
$TLEND = '</span>';
909909

910-
sub do_env_cfuncdesc{
911-
local($_) = @_;
912-
my $return_type = next_argument();
913-
my $function_name = next_argument();
914-
my $arg_list = next_argument();
910+
sub cfuncline_helper{
911+
my ($type, $name, $args) = @_;
915912
my $idx = make_str_index_entry(
916-
"<tt class=\"cfunction\">$function_name()</tt>" . get_indexsubitem());
913+
"<tt class=\"cfunction\">$name()</tt>" . get_indexsubitem());
917914
$idx =~ s/ \(.*\)//;
918915
$idx =~ s/\(\)//; # ???? - why both of these?
919-
my $result_rc = get_refcount($function_name, '');
916+
return "$type <b>$idx</b>(<var>$args</var>)";
917+
}
918+
sub do_cmd_cfuncline{
919+
local($_) = @_;
920+
my $type = next_argument();
921+
my $name = next_argument();
922+
my $args = next_argument();
923+
my $siginfo = cfuncline_helper($type, $name, $args);
924+
return "<dt>$siginfo\n<dd>" . $_;
925+
}
926+
sub do_env_cfuncdesc{
927+
local($_) = @_;
928+
my $type = next_argument();
929+
my $name = next_argument();
930+
my $args = next_argument();
931+
my $siginfo = cfuncline_helper($type, $name, $args);
932+
my $result_rc = get_refcount($name, '');
920933
my $rcinfo = '';
921934
if ($result_rc eq '+1') {
922935
$rcinfo = 'New reference';
@@ -933,7 +946,7 @@ sub do_env_cfuncdesc{
933946
. "\n <span class=\"value\">$rcinfo.</span>"
934947
. "\n</div>");
935948
}
936-
return "<dl><dt>$return_type <b>$idx</b>(<var>$arg_list</var>)\n<dd>"
949+
return "<dl><dt>$siginfo\n<dd>"
937950
. $rcinfo
938951
. $_
939952
. '</dl>';

Doc/texinputs/python.sty

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,12 @@
585585
% \begin{cfuncdesc}[refcount]{type}{name}{arglist}
586586
% Note that the [refcount] slot should only be filled in by
587587
% tools/anno-api.py; it pulls the value from the refcounts database.
588+
\newcommand{\cfuncline}[3]{
589+
\item[\code{#1 \bfcode{#2}(\py@varvars{#3})}\index{#2@{\py@idxcode{#2()}}}]
590+
}
588591
\newenvironment{cfuncdesc}[4][\py@badkey]{
589592
\begin{fulllineitems}
590-
\item[\code{#2 \bfcode{#3}(\py@varvars{#4})}\index{#3@{\py@idxcode{#3()}}}]
593+
\cfuncline{#2}{#3}{#4}
591594
\ifx#1\@undefined\else%
592595
\emph{Return value: \textbf{#1}.}\\
593596
\fi

0 commit comments

Comments
 (0)