mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-23 00:02:38 -05:00
* Use portable /usr/bin/env/{perl,python} instead of /usr/bin/{perl,python} * fix perl;add bash * Fix indentation using modified scripts * Revert "fix perl;add bash" This reverts commit be8b9113c25f7c2fb9c8c9bad556fbca2f0c0ba2. * python3 everywhere * more bash * rebase change perl * Linux perl; missing from last PR * fix doxygen_space * Use portable /usr/bin/env/{perl,python} instead of /usr/bin/{perl,python} * fix perl;add bash * Fix indentation using modified scripts * Revert "fix perl;add bash" This reverts commit be8b9113c25f7c2fb9c8c9bad556fbca2f0c0ba2. * python3 everywhere * more bash * rebase change perl * fix doxygen_space
96 lines
3.1 KiB
Perl
Executable File
96 lines
3.1 KiB
Perl
Executable File
#!/usr/bin/env perl
|
|
###########################################################################
|
|
# doxygen_space.pl
|
|
# ---------------------
|
|
# begin : October 2016
|
|
# copyright : (C) 2016 by Nyall Dawson
|
|
# email : nyall dot dawson at gmail dot com
|
|
#
|
|
###########################################################################
|
|
# #
|
|
# This program is free software; you can redistribute it and/or modify #
|
|
# it under the terms of the GNU General Public License as published by #
|
|
# the Free Software Foundation; either version 2 of the License, or #
|
|
# (at your option) any later version. #
|
|
# #
|
|
###########################################################################
|
|
|
|
# adapted from scripts/sort_includes.sh
|
|
|
|
# this is slurped in whole-file mode, as opposed to unify_includes.pl
|
|
# which slurps in per-line mode
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
my $file = $ARGV[0];
|
|
|
|
# read file
|
|
open(my $handle, "<", $file) || die "Couldn't open '".$file."' for reading because: ".$!;
|
|
chomp(my @INPUT_LINES = <$handle>);
|
|
close $handle;
|
|
|
|
|
|
my $LINE_IDX = 0;
|
|
my $LINE;
|
|
my @OUTPUT = ();
|
|
my $LINE_COUNT = @INPUT_LINES;
|
|
|
|
open(my $out_handle, ">", $file) || die "Couldn't open '".$file."' for writing because: ".$!;
|
|
|
|
my $PREVIOUS_WAS_BLANKLINE = 0;
|
|
|
|
while ($LINE_IDX < $LINE_COUNT){
|
|
my $new_line = $INPUT_LINES[$LINE_IDX];
|
|
my $is_blank_line = ( $new_line =~ m/^\s*$/ ) ? 1 : 0;
|
|
|
|
if ( $new_line =~ m/^(\s*)\/\/!\s*(.*?)$/ ){
|
|
#found a //! comment
|
|
my $indentation = $1;
|
|
my $comment = $2;
|
|
#check next line to see if it begins with //!
|
|
if ( $INPUT_LINES[$LINE_IDX+1] =~ m/\s*\/\/!\s*(.*?)$/){
|
|
#we are in a multiline //! comment block, convert to /** block
|
|
if ( !$PREVIOUS_WAS_BLANKLINE ){
|
|
print $out_handle "\n";
|
|
}
|
|
print $out_handle $indentation."/**\n";
|
|
print $out_handle $indentation." * ".$comment."\n";
|
|
while ( $INPUT_LINES[$LINE_IDX+1] =~ m/\s*\/\/!\s*(.*?)$/ ){
|
|
if ($1 ne ''){
|
|
print $out_handle $indentation." * ".$1."\n";
|
|
}
|
|
else {
|
|
print $out_handle $indentation." *\n";
|
|
}
|
|
$LINE_IDX++;
|
|
}
|
|
print $out_handle $indentation." */\n";
|
|
}
|
|
else {
|
|
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";
|
|
}
|
|
}
|
|
else {
|
|
print $out_handle $new_line."\n";
|
|
}
|
|
}
|
|
$LINE_IDX++;
|
|
$PREVIOUS_WAS_BLANKLINE = $is_blank_line;
|
|
}
|
|
close $out_handle;
|