Skip to content

Commit bc51bba

Browse files
committed
[sipify] transform \param xxx to :param xxx:
1 parent 8fef9e9 commit bc51bba

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

scripts/sipify.pl

+15-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
my $PYTHON_SIGNATURE = '';
4646

4747
my $COMMENT = '';
48+
my $COMMENT_PARAM_LIST = 0;
4849
my $GLOB_IFDEF_NESTING_IDX = 0;
4950
my @GLOB_BRACKET_NESTING_IDX = (0);
5051
my $PRIVATE_SECTION_LINE = '';
@@ -125,7 +126,17 @@ sub processDoxygenLine {
125126
# replace nullptr with None (nullptr means nothing to Python devs)
126127
$line =~ s/\bnullptr\b/None/g;
127128
# replace \returns with :return:
128-
$line =~ s/\\return(s)?/\n :return:/g;
129+
$line =~ s/\\return(s)?/\n :return:/;
130+
131+
if ( $line =~ m/\\param / ){
132+
if ( $COMMENT_PARAM_LIST == 0 )
133+
{
134+
$line = "\n$line";
135+
}
136+
$COMMENT_PARAM_LIST = 1;
137+
$line =~ s/\\param (\w+)\b/ :param $1:/g;
138+
}
139+
129140

130141
if ( $line =~ m/[\\@](ingroup|class)/ ) {
131142
return ""
@@ -283,6 +294,7 @@ sub fix_annotations {
283294
sub detect_comment_block{
284295
my %args = ( strict_mode => STRICT, @_ );
285296
# dbg_info("detect comment strict:" . $args{strict_mode} );
297+
$COMMENT_PARAM_LIST = 0;
286298
if ( $LINE =~ m/^\s*\/\*/ || $args{strict_mode} == UNSTRICT && $LINE =~ m/\/\*/ ){
287299
dbg_info("found comment block");
288300
do {no warnings 'uninitialized';
@@ -684,6 +696,7 @@ sub detect_comment_block{
684696
if ( $SIP_RUN == 0 ){
685697
if ( $LINE =~ m/^\s*\/\// ){
686698
if ($LINE =~ m/^\s*\/\/\!\s*(.*?)\n?$/){
699+
$COMMENT_PARAM_LIST = 0;
687700
$COMMENT = processDoxygenLine( $1 );
688701
$COMMENT =~ s/\n+$//;
689702
}
@@ -950,7 +963,7 @@ sub detect_comment_block{
950963
}
951964
}
952965
if ( $RETURN_TYPE ne '' ){
953-
write_output("CM3", " :rtype: $RETURN_TYPE\n");
966+
write_output("CM3", "\n :rtype: $RETURN_TYPE\n");
954967
}
955968
write_output("CM4", "%End\n");
956969
}

0 commit comments

Comments
 (0)