Skip to content

Commit

Permalink
When a list item is immediately followed by a new list, condense the
Browse files Browse the repository at this point in the history
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 e293a9d
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion scripts/doxygen_space.pl
Expand Up @@ -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];
Expand Down Expand Up @@ -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";
Expand All @@ -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*(.*)$/ ){
Expand All @@ -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++;
Expand Down

0 comments on commit e293a9d

Please sign in to comment.