Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make prepare_commit automatically place an empty line before lists
in doxygen blocks

Fixes display of lists in the PyQGIS dox

Fixes #37114
  • Loading branch information
nyalldawson committed Jun 11, 2020
1 parent 7120e5d commit 83dc3a5
Showing 1 changed file with 52 additions and 15 deletions.
67 changes: 52 additions & 15 deletions scripts/doxygen_space.pl
Expand Up @@ -39,6 +39,9 @@
open(my $out_handle, ">", $file) || die "Couldn't open '".$file."' for writing because: ".$!;

my $PREVIOUS_WAS_BLANKLINE = 0;
my $INSIDE_DOX_BLOCK = 0;
my $INSIDE_DOX_LIST = 0;
my $PREVIOUS_WAS_DOX_BLANKLINE = 0;

while ($LINE_IDX < $LINE_COUNT){
my $new_line = $INPUT_LINES[$LINE_IDX];
Expand Down Expand Up @@ -71,23 +74,57 @@
print $out_handle $new_line."\n";
}
}
else {
if ( $new_line =~ m/^(\s*)\/\*\*(?!\*)\s*(.*)$/ ){
# Space around doxygen start blocks (force blank line before /**)
if ( !$PREVIOUS_WAS_BLANKLINE ){
print $out_handle "\n";
}
if ( $2 ne '' ){
# new line after /** begin block
print $out_handle "$1\/**\n$1 * $2\n";
}
else {
print $out_handle $new_line."\n";
}
elsif ( $INSIDE_DOX_BLOCK ){
if ( $new_line =~ m/^\s*\*\s*$/ ){
print $out_handle $new_line."\n";
$PREVIOUS_WAS_DOX_BLANKLINE = 1;
if ( $INSIDE_DOX_LIST ) {
$INSIDE_DOX_LIST = 0;
# print $out_handle "end list\n";
}
else {
print $out_handle $new_line."\n";
}
elsif ( $new_line =~ m/^(\s*)\*\s*\-(?![-\d>])(?: )*(.*)/ ){
if ( !$INSIDE_DOX_LIST && !$PREVIOUS_WAS_DOX_BLANKLINE ){
print $out_handle "$1*\n";
}
print $out_handle "$1* - $2\n";
$INSIDE_DOX_LIST = 1;
}
elsif ($INSIDE_DOX_LIST && $new_line =~ m/^(\s*)\*(?!\/)/ ){
$INSIDE_DOX_LIST = 0;
# print $out_handle "end list without line break\n";
print $out_handle "$1*\n";
print $out_handle $new_line."\n";
}
elsif ( $new_line =~ m/^(\s*)\*\/\s*$/ ){
$INSIDE_DOX_BLOCK = 0;
$INSIDE_DOX_LIST = 0;
print $out_handle $new_line."\n";
# print $out_handle "end_block\n";
}
else {
print $out_handle $new_line."\n";
# print $out_handle "normal dox\n";
$PREVIOUS_WAS_DOX_BLANKLINE = 0;
}
}
elsif ( $new_line =~ m/^(\s*)\/\*\*(?!\*)\s*(.*)$/ ){
# Space around doxygen start blocks (force blank line before /**)
if ( !$PREVIOUS_WAS_BLANKLINE ){
print $out_handle "\n";
}
if ( $2 ne '' ){
# new line after /** begin block
print $out_handle "$1\/**\n$1 * $2\n";
}
else {
print $out_handle $new_line."\n";
}
$INSIDE_DOX_BLOCK = 1;
# print $out_handle "start_block\n";
}
else {
print $out_handle $new_line."\n";
}
$LINE_IDX++;
$PREVIOUS_WAS_BLANKLINE = $is_blank_line;
Expand Down

0 comments on commit 83dc3a5

Please sign in to comment.