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

Skip to content

Commit f6e9027

Browse files
committed
Refactor the generation of signature lines for funcdesc, methoddesc,
and friends. This was part of the changes to the presentation of signature lines, but does not include any of the aspects that people questioned.
1 parent a96b0df commit f6e9027

1 file changed

Lines changed: 22 additions & 27 deletions

File tree

Doc/perl/python.perl

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ sub do_cmd_optional{
172172
# output files for users that read them over the network rather than
173173
# from local repositories.
174174

175-
# \file and \samp are at the end of this file since they screw up fontlock.
176-
177175
sub do_cmd_pytype{ return @_[0]; }
178176
sub do_cmd_makevar{
179177
return use_wrappers(@_[0], '<span class="makevar">', '</span>'); }
@@ -905,7 +903,7 @@ ($$)
905903

906904

907905
$TLSTART = '<span class="typelabel">';
908-
$TLEND = '</span>';
906+
$TLEND = '</span>&nbsp;';
909907

910908
sub cfuncline_helper($$$){
911909
my($type, $name, $args) = @_;
@@ -1017,6 +1015,12 @@ ($)
10171015
return translate_commands($_);
10181016
}
10191017

1018+
sub funcline_helper($$$){
1019+
my($first, $idxitem, $arglist) = @_;
1020+
return (($first ? '<dl>' : '')
1021+
. "<dt><b>$idxitem</b>(<var>$arglist</var>)\n<dd>");
1022+
}
1023+
10201024
sub do_env_funcdesc{
10211025
local($_) = @_;
10221026
my $function_name = next_argument();
@@ -1026,18 +1030,15 @@ sub do_env_funcdesc{
10261030
. get_indexsubitem());
10271031
$idx =~ s/ \(.*\)//;
10281032
$idx =~ s/\(\)<\/tt>/<\/tt>/;
1029-
return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
1033+
return funcline_helper(1, $idx, $arg_list) . $_ . '</dl>';
10301034
}
10311035

10321036
sub do_env_funcdescni{
10331037
local($_) = @_;
10341038
my $function_name = next_argument();
10351039
my $arg_list = convert_args(next_argument());
1036-
return "<dl><dt><b><tt class=\"function\">$function_name</tt></b>"
1037-
. "(<var>$arg_list</var>)\n"
1038-
. '<dd>'
1039-
. $_
1040-
. '</dl>';
1040+
my $prefix = "<tt class=\"function\">$function_name</tt>";
1041+
return funcline_helper(1, $prefix, $arg_list) . $_ . '</dl>';
10411042
}
10421043

10431044
sub do_cmd_funcline{
@@ -1048,7 +1049,7 @@ sub do_cmd_funcline{
10481049
my $idx = make_str_index_entry($prefix . get_indexsubitem());
10491050
$prefix =~ s/\(\)//;
10501051

1051-
return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
1052+
return funcline_helper(0, $prefix, $arg_list) . $_;
10521053
}
10531054

10541055
sub do_cmd_funclineni{
@@ -1057,7 +1058,7 @@ sub do_cmd_funclineni{
10571058
my $arg_list = convert_args(next_argument());
10581059
my $prefix = "<tt class=\"function\">$function_name</tt>";
10591060

1060-
return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
1061+
return funcline_helper(0, $prefix, $arg_list) . $_;
10611062
}
10621063

10631064
# Change this flag to index the opcode entries. I don't think it's very
@@ -1123,7 +1124,7 @@ sub do_env_excdesc{
11231124
local($_) = @_;
11241125
my $excname = next_argument();
11251126
my $idx = make_str_index_entry("<tt class=\"exception\">$excname</tt>");
1126-
return ("<dl><dt><b>${TLSTART}exception$TLEND $idx</b>"
1127+
return ("<dl><dt><b>${TLSTART}exception$TLEND$idx</b>"
11271128
. "\n<dd>"
11281129
. $_
11291130
. '</dl>');
@@ -1139,10 +1140,8 @@ ($$)
11391140
$idx = make_str_index_entry(
11401141
"<tt class=\"$what\">$THIS_CLASS</tt> ($what in $THIS_MODULE)" );
11411142
$idx =~ s/ \(.*\)//;
1142-
return ("<dl><dt><b>$TLSTART$what$TLEND $idx</b>"
1143-
. "(<var>$arg_list</var>)\n<dd>"
1144-
. $_
1145-
. '</dl>');
1143+
my $prefix = "$TLSTART$what$TLEND$idx";
1144+
return funcline_helper(1, $prefix, $arg_list) . $_ . '</dl>';
11461145
}
11471146

11481147
sub do_env_classdesc{
@@ -1155,9 +1154,9 @@ sub do_env_classdescstar{
11551154
$idx = make_str_index_entry(
11561155
"<tt class=\"class\">$THIS_CLASS</tt> (class in $THIS_MODULE)");
11571156
$idx =~ s/ \(.*\)//;
1158-
return ("<dl><dt><b>${TLSTART}class$TLEND $idx</b>\n<dd>"
1159-
. $_
1160-
. '</dl>');
1157+
my $prefix = "${TLSTART}class$TLEND$idx";
1158+
# Can't use funcline_helper() since there is no args list.
1159+
return "<dl><dt><b>$prefix</b>\n<dd>" . $_ . '</dl>';
11611160
}
11621161

11631162
sub do_env_excclassdesc{
@@ -1180,7 +1179,7 @@ sub do_env_methoddesc{
11801179
"<tt class=\"method\">$method()</tt>$extra");
11811180
$idx =~ s/ \(.*\)//;
11821181
$idx =~ s/\(\)//;
1183-
return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
1182+
return funcline_helper(1, $idx, $arg_list) . $_ . '</dl>';
11841183
}
11851184

11861185

@@ -1199,8 +1198,7 @@ sub do_cmd_methodline{
11991198
"<tt class=\"method\">$method()</tt>$extra");
12001199
$idx =~ s/ \(.*\)//;
12011200
$idx =~ s/\(\)//;
1202-
return "<dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>"
1203-
. $_;
1201+
return funcline_helper(0, $idx, $arg_list) . $_;
12041202
}
12051203

12061204

@@ -1209,18 +1207,15 @@ sub do_cmd_methodlineni{
12091207
next_optional_argument();
12101208
my $method = next_argument();
12111209
my $arg_list = convert_args(next_argument());
1212-
return "<dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
1213-
. $_;
1210+
return funcline_helper(0, $method, $arg_list) . $_;
12141211
}
12151212

12161213
sub do_env_methoddescni{
12171214
local($_) = @_;
12181215
next_optional_argument();
12191216
my $method = next_argument();
12201217
my $arg_list = convert_args(next_argument());
1221-
return "<dl><dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
1222-
. $_
1223-
. '</dl>';
1218+
return funcline_helper(1, $method, $arg_list) . $_ . '</dl>';
12241219
}
12251220

12261221

0 commit comments

Comments
 (0)