Skip to content
Permalink
Browse files

When a list item is immediately followed by a new list, condense the

two -- it's likely that there's extraneous newlines in the middle of
the list
  • Loading branch information
nyalldawson committed Jun 11, 2020
1 parent 481ece3 commit e293a9da8f90e1637306d6a9f64c216260becd6d
Showing with 29 additions and 1 deletion.
  1. +29 −1 scripts/doxygen_space.pl
@@ -42,6 +42,8 @@
my $INSIDE_DOX_BLOCK = 0;
my $INSIDE_DOX_LIST = 0;
my $PREVIOUS_WAS_DOX_BLANKLINE = 0;
my $JUST_FINISHED_A_LIST = 0;
my $BUFFERED_LINE;

while ($LINE_IDX < $LINE_COUNT){
my $new_line = $INPUT_LINES[$LINE_IDX];
@@ -76,19 +78,30 @@
}
elsif ( $INSIDE_DOX_BLOCK ){
if ( $new_line =~ m/^\s*\*\s*$/ ){
print $out_handle $new_line."\n";
# print $out_handle "blank line!\n";
$PREVIOUS_WAS_DOX_BLANKLINE = 1;
if ( $INSIDE_DOX_LIST ) {
$INSIDE_DOX_LIST = 0;
$JUST_FINISHED_A_LIST = 1;
$BUFFERED_LINE = $new_line;
# 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";
}
if ($JUST_FINISHED_A_LIST ){
# print $out_handle "just finished a list, continuing the same one!!\n";
$BUFFERED_LINE = "";
}
# print $out_handle "start list\n";
print $out_handle "$1* - $2\n";
$INSIDE_DOX_LIST = 1;
$JUST_FINISHED_A_LIST = 0;
}
elsif ($INSIDE_DOX_LIST && $new_line =~ m/^(\s*)\*\s{2,}(.*)$/ ){
# print $out_handle "list continuation\n";
@@ -99,17 +112,28 @@
# print $out_handle "end list without line break\n";
print $out_handle "$1*\n";
print $out_handle $new_line."\n";
$JUST_FINISHED_A_LIST = 1;
}
elsif ( $new_line =~ m/^(\s*)\*\/\s*$/ ){
$INSIDE_DOX_BLOCK = 0;
$INSIDE_DOX_LIST = 0;
$JUST_FINISHED_A_LIST = 0;
if ( $BUFFERED_LINE ) {
print $out_handle $BUFFERED_LINE."\n";
$BUFFERED_LINE = "";
}
print $out_handle $new_line."\n";
# print $out_handle "end_block\n";
}
else {
if ( $BUFFERED_LINE ) {
print $out_handle $BUFFERED_LINE."\n";
$BUFFERED_LINE = "";
}
print $out_handle $new_line."\n";
# print $out_handle "normal dox\n";
$PREVIOUS_WAS_DOX_BLANKLINE = 0;
$JUST_FINISHED_A_LIST = 0;
}
}
elsif ( $new_line =~ m/^(\s*)\/\*\*(?!\*)\s*(.*)$/ ){
@@ -128,6 +152,10 @@
# print $out_handle "start_block\n";
}
else {
if ( $BUFFERED_LINE ) {
print $out_handle $BUFFERED_LINE."\n";
$BUFFERED_LINE = "";
}
print $out_handle $new_line."\n";
}
$LINE_IDX++;

0 comments on commit e293a9d

Please sign in to comment.
You can’t perform that action at this time.