|
18 | 18 | use constant MULTILINE_METHOD => 21;
|
19 | 19 | use constant MULTILINE_CONDITIONAL_STATEMENT => 22;
|
20 | 20 |
|
| 21 | +use constant CODE_SNIPPET => 30; |
| 22 | +use constant CODE_SNIPPET_CPP => 31; |
| 23 | + |
21 | 24 | # read arguments
|
22 | 25 | my $debug = 0;
|
23 | 26 | die("usage: $0 [-debug] headerfile\n") unless GetOptions ("debug" => \$debug) && @ARGV == 1;
|
@@ -121,19 +124,26 @@ sub write_header_footer {
|
121 | 124 | sub processDoxygenLine {
|
122 | 125 | my $line = $_[0];
|
123 | 126 |
|
124 |
| - # detect code snipped |
125 |
| - if ( $line =~ m/\\code\{\.(\w+)\}/ ) { |
126 |
| - my $codelang = $1; |
| 127 | + # detect code snippet |
| 128 | + if ( $line =~ m/\\code(\{\.(\w+)\})?/ ) { |
| 129 | + my $codelang = ""; |
| 130 | + $codelang = " $2" if (defined $2); |
| 131 | + $CODE_SNIPPET = CODE_SNIPPET; |
| 132 | + $CODE_SNIPPET = CODE_SNIPPET_CPP if ($codelang =~ m/cpp/ ); |
127 | 133 | $codelang =~ s/py/python/;
|
128 |
| - $CODE_SNIPPET=1; |
129 |
| - return ".. code-block:: $codelang\n\n"; |
| 134 | + return "\n" if ( $CODE_SNIPPET == CODE_SNIPPET_CPP ); |
| 135 | + return ".. code-block::$codelang\n\n"; |
130 | 136 | }
|
131 | 137 | if ( $line =~ m/\\endcode/ ) {
|
132 | 138 | $CODE_SNIPPET = 0;
|
133 | 139 | return "\n";
|
134 | 140 | }
|
135 |
| - if ($CODE_SNIPPET == 1){ |
136 |
| - return " $line\n"; |
| 141 | + if ($CODE_SNIPPET != 0){ |
| 142 | + if ( $CODE_SNIPPET == CODE_SNIPPET_CPP ){ |
| 143 | + return ""; |
| 144 | + } else { |
| 145 | + return " $line\n"; |
| 146 | + } |
137 | 147 | }
|
138 | 148 |
|
139 | 149 | # remove prepending spaces
|
@@ -181,7 +191,7 @@ sub processDoxygenLine {
|
181 | 191 | }
|
182 | 192 | # create links in plain text too (less performant)
|
183 | 193 | if ( $line =~ m/\b(Qgs[A-Z]\w+)\b(\.?$|[^\w]{2})/) {
|
184 |
| - if ( $1 !~ $ACTUAL_CLASS ) { |
| 194 | + if ( defined $ACTUAL_CLASS && $1 !~ $ACTUAL_CLASS ) { |
185 | 195 | $line =~ s/\b(Qgs[A-Z]\w+)\b(\.?$|[^\w]{2})/:py:class:`$1`$2/g;
|
186 | 196 | }
|
187 | 197 | }
|
|
0 commit comments