| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Quiq::Sdoc::Producer - Sdoc-Generator | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | L<Quiq::Hash> | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Ein Objekt der Klasse repräsentiert einen Sdoc-Generator. Die | ||||||||||||||||||||||||||||
| 16 | Methoden der Klasse erzeugen die Konstrukte, aus denen ein | ||||||||||||||||||||||||||||
| 17 | Sdoc-Dokument aufgebaut ist. | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =over 4 | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =item indentation => $n (Default: 4) | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | Einrücktiefe bei der Codegenerierung | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =back | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | package Quiq::Sdoc::Producer; | ||||||||||||||||||||||||||||
| 34 | 1 | ▶ | use base qw/Quiq::Hash/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 1 | our $VERSION = '1.240'; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | ▶ | use Quiq::Unindent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | 1 | ▶ | use Quiq::Hash; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | use Quiq::Table; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 METHODS | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head2 Konstruktor | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head3 new() - Konstruktor | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | $gen = $class->new(@keyVal); | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =head4 Description | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | Instantiiere einen Sdoc-Generator mit den Eigenschaften @keyVal | ||||||||||||||||||||||||||||
| 61 | (s. Abschnitt L<Attributes|"ATTRIBUTES">) und liefere eine Referenz auf dieses | ||||||||||||||||||||||||||||
| 62 | Objekt zurück. | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head4 Example | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | Generiere Sdoc mit Einrückung 2: | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | $gen = Quiq::Sdoc::Producer->new( | ||||||||||||||||||||||||||||
| 69 | indentation => 2, | ||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =cut | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 13 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | 13 | my $class = shift; | |||||||||||||||||||||||||||
| 78 | # @_: @keyVal | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 13 | my $self = $class->SUPER::new( | |||||||||||||||||||||||||||
| 81 | indentation => 4, | ||||||||||||||||||||||||||||
| 82 | linkA => [], | ||||||||||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||||||||||
| 84 | 13 | $self->set(@_); | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 13 | return $self; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =head2 Objektmethoden | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =head3 code() - Code-Abschnitt | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | $str = $gen->code($text,@keyVal); | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =head4 Arguments | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =over 4 | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =item $text | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | Text des Code-Abschnitts. | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | =item @keyVal | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | Eigenschaften des Code-Abschnitts. | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =back | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =head4 Description | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | Erzeuge einen Code-Abschnitt mit Text $text und liefere den | ||||||||||||||||||||||||||||
| 116 | resultierenden Sdoc-Code zurück. | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =head4 Example | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | $gen->code("Dies ist\nein Test\n"); | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | erzeugt | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | | Dies ist\n | ||||||||||||||||||||||||||||
| 125 | | ein Test.\n | ||||||||||||||||||||||||||||
| 126 | |\n | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =cut | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 2 | ▶ | sub code { | ||||||||||||||||||||||||||
|
Subroutine
code: called CC=4 SCAR=16.5
Pod
documented
| |||||||||||||||||||||||||||||
| 133 | 2 | my ($self,$text) = splice@_,0,2; | |||||||||||||||||||||||||||
| 134 | # @_: @keyVal | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 2 | $text = Quiq::Unindent->trim($text); | |||||||||||||||||||||||||||
| 137 | 2 | ▶ | if ($text eq '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 1 | return ''; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 1 | my $ind = ' ' x $self->indentation; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 1 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 0 | my $str = "%Code:\n"; | |||||||||||||||||||||||||||
| 145 | 0 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | $str .= sprintf qq|%s%s="%s"\n|,$ind,shift,shift; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | 0 | $str .= "$text\n.\n\n"; | |||||||||||||||||||||||||||
| 149 | 0 | return $str; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 1 | $text =~ s/^/$ind/mg; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 1 | return "$text\n\n"; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | =head3 comment() - Kommentar | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | $str = $gen->comment($text); | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | =head4 Description | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | Erzeuge einen Kommentar mit dem Text $text und liefere den | ||||||||||||||||||||||||||||
| 168 | resultierenden Sdoc-Code zurück. | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | =head4 Example | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | $gen->comment("Dies ist\nein Test\n"); | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | erzeugt | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | # Dies ist\n | ||||||||||||||||||||||||||||
| 177 | # ein Test.\n | ||||||||||||||||||||||||||||
| 178 | \n | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | =cut | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 2 | ▶ | sub comment { | ||||||||||||||||||||||||||
|
Subroutine
comment: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 185 | 2 | my ($self,$text) = @_; | |||||||||||||||||||||||||||
| 186 | 2 | $text =~ s/\s+$//; | |||||||||||||||||||||||||||
| 187 | 2 | $text =~ s/^/# /mg; | |||||||||||||||||||||||||||
| 188 | 2 | return "$text\n\n"; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | =head3 document() - Dokument-Definition | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | $str = $gen->document(@keyVal); | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | =head4 Description | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | Erzeuge eine Dokument-Definition mit den Eigenschaften @keyVal und | ||||||||||||||||||||||||||||
| 202 | liefere den resultierenden Sdoc-Code zurück. | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | =cut | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 1 | ▶ | sub document { | ||||||||||||||||||||||||||
|
Subroutine
document: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 209 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 210 | # @_: @keyVal | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 1 | my $ind = ' ' x $self->indentation; | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 1 | my $str = "%Document:\n"; | |||||||||||||||||||||||||||
| 215 | 1 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 2 | $str .= sprintf qq|%s%s="%s"\n|,$ind,shift,shift; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | 1 | $str .= "\n"; | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 1 | return $str; | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | =head3 format() - Format-Abschnitt | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | $str = $gen->format( | ||||||||||||||||||||||||||||
| 230 | $format => $code, | ||||||||||||||||||||||||||||
| 231 | ... | ||||||||||||||||||||||||||||
| 232 | ); | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | =head4 Description | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | Erzeuge einen Format-Abschnitt für die angegebenen Format/Code-Paare und | ||||||||||||||||||||||||||||
| 237 | liefere den resultierenden Sdoc-Code zurück. | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | =cut | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 1 | ▶ | sub format { | ||||||||||||||||||||||||||
|
Subroutine
format: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||
| 244 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 245 | # @_: @formatCode | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 1 | my $str = "%Format:\n"; | |||||||||||||||||||||||||||
| 248 | 1 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 2 | my $format = shift; | |||||||||||||||||||||||||||
| 250 | 2 | my $code = shift; | |||||||||||||||||||||||||||
| 251 | 2 | ▶ | if ($code ne '' && substr($code,-1,1) ne "\n") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$code ne "" and substr($code, -1, 1) ne "\n"
MC/DC0%0/2
$code ne "" and substr($code, -1, 1) ne "\n"
$code ne ""
substr($code, -1, 1) ne "\n"
Truth table33%1/3
A and B
A= $code ne ""B= substr($code, -1, 1) ne "\n"
| |||||||||||||||||||||||||||||
| 252 | 2 | $code .= "\n"; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | 2 | $str .= sprintf "\@\@%s\@\@\n%s",$format,$code; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | 1 | $str .= ".\n\n"; | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 1 | return $str; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | =head3 link() - Link | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | $str = $gen->link($name, | ||||||||||||||||||||||||||||
| 268 | url => $url, | ||||||||||||||||||||||||||||
| 269 | ... | ||||||||||||||||||||||||||||
| 270 | ); | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | =head4 Description | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | Erzeuge ein Link-Segment. Intern wird die Link-Defínition gespeichert, | ||||||||||||||||||||||||||||
| 275 | die später mit allen anderen Link-Definitionen per $gen->linkDefs() | ||||||||||||||||||||||||||||
| 276 | abgerufen werden kann. | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | =cut | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 1 | ▶ | sub link { | ||||||||||||||||||||||||||
|
Subroutine
link: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 283 | 1 | my ($self,$name) = splice @_,0,2; | |||||||||||||||||||||||||||
| 284 | # @_: @keyVal | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 1 | my $linkA = $self->linkA; | |||||||||||||||||||||||||||
| 287 | 1 | push @$linkA,Quiq::Hash->new({@_}, | |||||||||||||||||||||||||||
| 288 | name => $name, | ||||||||||||||||||||||||||||
| 289 | url => undef, | ||||||||||||||||||||||||||||
| 290 | target => undef, | ||||||||||||||||||||||||||||
| 291 | ); | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 1 | return "L{$name}"; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | =head3 linkDefs() - Link-Definitionen | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | $str = $gen->linkDefs; | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | =head4 Description | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | Generiere Link-Definitionen zu den Link-Segmenten des Dokuments | ||||||||||||||||||||||||||||
| 307 | und liefere diese zurück. Die Methode wird typischerweise am Ende | ||||||||||||||||||||||||||||
| 308 | des Dokuments gerufen. | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | =cut | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 0 | ▶ | sub linkDefs { | ||||||||||||||||||||||||||
|
Subroutine
linkDefs: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 315 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 0 | my $ind = ' ' x $self->indentation; | |||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | 0 | my $str = ''; | |||||||||||||||||||||||||||
| 320 | 0 | for my $l (@{$self->linkA}) { | |||||||||||||||||||||||||||
| 321 | 0 | $str .= "%Link:\n"; | |||||||||||||||||||||||||||
| 322 | 0 | for my $key (qw/name url target/) { | |||||||||||||||||||||||||||
| 323 | 0 | ▶ | if (defined $l->{$key}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | 0 | $str .= qq~$ind$key="$l->{$key}"\n~; | |||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | 0 | $str .= "\n"; | |||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 0 | return $str; | |||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | =head3 paragraph() - Paragraph | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | $str = $gen->paragraph($text); | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | =head4 Description | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | Erzeuge einen Paragraph mit Text $text und liefere den | ||||||||||||||||||||||||||||
| 344 | resultierenden Sdoc-Code zurück. | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | =head4 Example | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | $gen->paragraph("Dies ist\nein Test\n"); | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | erzeugt | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | |Dies ist\n | ||||||||||||||||||||||||||||
| 353 | |ein Test.\n | ||||||||||||||||||||||||||||
| 354 | |\n | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | =cut | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 2 | ▶ | sub paragraph { | ||||||||||||||||||||||||||
|
Subroutine
paragraph: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 361 | 2 | my ($self,$text) = @_; | |||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | 2 | $text = Quiq::Unindent->trim($text); | |||||||||||||||||||||||||||
| 364 | 2 | ▶ | if ($text eq '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | 1 | return $text; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 1 | return "$text\n\n"; | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | =head3 segment() - Segment | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | $str = $gen->segment($name, | ||||||||||||||||||||||||||||
| 378 | html => $htmlCode, | ||||||||||||||||||||||||||||
| 379 | latex => $latexCode, | ||||||||||||||||||||||||||||
| 380 | mediawiki => $mediawikiCode, | ||||||||||||||||||||||||||||
| 381 | ); | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | =head4 Description | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | Definiere ein Segment mit dem Bezeichner $name und den HTML-, LaTeX-, | ||||||||||||||||||||||||||||
| 386 | MediaWiki-Definitionen $htmlCode, $latexCode, $mediawikiCode und | ||||||||||||||||||||||||||||
| 387 | liefere den resultierenden Sdoc-Code zurück. | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | =head4 Example | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | $gen->segment('red', | ||||||||||||||||||||||||||||
| 392 | html => '<span style="color: red">%s</span>', | ||||||||||||||||||||||||||||
| 393 | latex => '{\color{red}%s}', | ||||||||||||||||||||||||||||
| 394 | mediawiki => '<span style="color: red">%s</span>', | ||||||||||||||||||||||||||||
| 395 | ); | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | erzeugt | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | %Segment: | ||||||||||||||||||||||||||||
| 400 | name=red | ||||||||||||||||||||||||||||
| 401 | html='<span style="color: red">%s</span>' | ||||||||||||||||||||||||||||
| 402 | latex='{\color{red}%s}' | ||||||||||||||||||||||||||||
| 403 | mediawiki='<span style="color: red">%s</span>' | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | =cut | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | 1 | ▶ | sub segment { | ||||||||||||||||||||||||||
|
Subroutine
segment: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 410 | 1 | my ($self,$name) = splice @_,0,2; | |||||||||||||||||||||||||||
| 411 | # @_: @keyVal | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 1 | my $ind = ' ' x $self->indentation; | |||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | 1 | my $str = qq~%Segment:\n${ind}name=$name\n~; | |||||||||||||||||||||||||||
| 416 | 1 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 417 | 3 | my ($key,$val) = splice @_,0,2; | |||||||||||||||||||||||||||
| 418 | 3 | $str .= qq~${ind}$key='$val'\n~; | |||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | 1 | return "$str\n"; | |||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | =head3 table() - Tabelle | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | $str = $gen->table(\@titles,\@rows,@keyVal); # mit Titelzeile | ||||||||||||||||||||||||||||
| 431 | $str = $gen->table($width,\@rows,@keyVal); # ohne Titelzeile | ||||||||||||||||||||||||||||
| 432 | $str = $gen->table($text,@keyVal); | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | =head4 Arguments | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | =over 4 | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | =item @titles | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | (Array of Strings) Liste der Kolumnentitel | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | =item @rows | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | (Array of Arrays of Strings) Liste der Zeilen | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | =item $width | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | (Integer) Anzahl der Kolumnen | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | =item $text | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | (String) Tabellen-Body als Text | ||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | =item @keyVal | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | (Pairs of Strings) Liste von Tabellen-Eigenschaften | ||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | =back | ||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | =head4 Returns | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | (String) Sdoc-Code | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | =head4 Description | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | Erzeuge eine Tabelle mit den Titeln @titles und den Zeilen @rows bzw. | ||||||||||||||||||||||||||||
| 467 | dem Tabellen-Body $text sowie den Eigenschaften @keyVal und liefere den | ||||||||||||||||||||||||||||
| 468 | resultierenden Sdoc-Code zurück. | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | =head4 Example | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | $str = $gen->table(['Integer','String','Float'],[ | ||||||||||||||||||||||||||||
| 473 | [1, 'A', 76.253], | ||||||||||||||||||||||||||||
| 474 | [12, 'AB', 1.7 ], | ||||||||||||||||||||||||||||
| 475 | [123,'ABC',9999 ], | ||||||||||||||||||||||||||||
| 476 | ]); | ||||||||||||||||||||||||||||
| 477 | ==> | ||||||||||||||||||||||||||||
| 478 | %Table: | ||||||||||||||||||||||||||||
| 479 | Integer String Float | ||||||||||||||||||||||||||||
| 480 | ------- ------ -------- | ||||||||||||||||||||||||||||
| 481 | 1 A 76.253 | ||||||||||||||||||||||||||||
| 482 | 12 AB 1.700 | ||||||||||||||||||||||||||||
| 483 | 123 ABC 9999.000 | ||||||||||||||||||||||||||||
| 484 | . | ||||||||||||||||||||||||||||
| 485 | \n | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | =cut | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | 4 | ▶ | sub table { | ||||||||||||||||||||||||||
|
Subroutine
table: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||
| 492 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 493 | # @_: \@titles,\@rows,@keyVal -or- $text,@keyVal | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | 4 | ▶ | if (!defined($_[0]) || $_[0] eq '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $_[0] or $_[0] eq ""
MC/DC100%2/2
not defined $_[0] or $_[0] eq ""
not defined $_[0]
$_[0] eq ""
Truth table100%3/3
not(A) or B
A= not defined $_[0]B= $_[0] eq ""
| |||||||||||||||||||||||||||||
| 496 | 2 | return ''; | |||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | 2 | my $body; | |||||||||||||||||||||||||||
| 500 | 2 | ▶ | if (ref($_[0]) || $_[0] =~ /^\d+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_[0] or $_[0] =~ /^\d+$/
MC/DC50%1/2
ref $_[0] or $_[0] =~ /^\d+$/
ref $_[0]
$_[0] =~ /^\d+$/
Truth table66%2/3
A or B
A= ref $_[0]B= $_[0] =~ /^\d+$/
| |||||||||||||||||||||||||||||
| 501 | 1 | my $arg1 = shift; # $titleA -or- $width | |||||||||||||||||||||||||||
| 502 | 1 | my $rowsA = shift; | |||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | 1 | $body = Quiq::Table->new($arg1,$rowsA)->asAsciiTable; | |||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | else { | ||||||||||||||||||||||||||||
| 507 | 1 | $body = Quiq::Unindent->trimNl(shift); | |||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | 2 | my $str = "%Table:\n"; | |||||||||||||||||||||||||||
| 511 | 2 | my $ind = ' ' x $self->indentation; | |||||||||||||||||||||||||||
| 512 | 2 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 513 | 0 | $str .= sprintf qq|%s%s="%s"\n|,$ind,shift,shift; | |||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||
| 515 | 2 | $str .= "$body.\n\n"; | |||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 2 | return $str; | |||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | =head3 tableOfContents() - Inhaltsverzeichnis-Definition | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | $str = $gen->tableOfContents(@keyVal); | ||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | =head4 Description | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | Erzeuge eine Inhaltsverzeichnis-Definition mit den Eigenschaften | ||||||||||||||||||||||||||||
| 531 | @keyVal und liefere den resultierenden Sdoc-Code zurück. | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | =cut | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | 1 | ▶ | sub tableOfContents { | ||||||||||||||||||||||||||
|
Subroutine
tableOfContents: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 538 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 539 | # @_: @keyVal | ||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | 1 | my $ind = ' ' x $self->indentation; | |||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | 1 | my $str = "%TableOfContents:\n"; | |||||||||||||||||||||||||||
| 544 | 1 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 545 | 1 | $str .= sprintf qq|%s%s="%s"\n|,$ind,shift,shift; | |||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||
| 547 | 1 | $str .= "\n"; | |||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | 1 | return $str; | |||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | =head3 section() - Abschnitt | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | $str = $gen->section($level,$title,@keyVal); | ||||||||||||||||||||||||||||
| 559 | $str = $gen->section($level,$title,@keyVal,$body); | ||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | =head4 Description | ||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | Erzeuge einen Abschnitt der Tiefe $level mit dem Titel $title und | ||||||||||||||||||||||||||||
| 564 | dem Abschnitts-Körper $body und liefere den resultierenden | ||||||||||||||||||||||||||||
| 565 | Sdoc-Code zurück. | ||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||
| 567 | =head4 Example | ||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||
| 569 | $gen->section(2,'Test',"Dies ist\nein Test."); | ||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | erzeugt | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | == Test\n | ||||||||||||||||||||||||||||
| 574 | \n | ||||||||||||||||||||||||||||
| 575 | Dies ist\n | ||||||||||||||||||||||||||||
| 576 | ein Test.\n | ||||||||||||||||||||||||||||
| 577 | \n | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | =cut | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | 2 | ▶ | sub section { | ||||||||||||||||||||||||||
|
Subroutine
section: called CC=9 SCAR=22.7
Pod
documented
| |||||||||||||||||||||||||||||
| 584 | 2 | my ($self,$level,$title) = splice @_,0,3; | |||||||||||||||||||||||||||
| 585 | # @_: @keyval -or- @keyVal,$body | ||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | 2 | my $body; | |||||||||||||||||||||||||||
| 588 | 2 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 589 | 2 | ▶ | if (@_%2) { # ungerade Anzahl | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 590 | 2 | $body = pop; | |||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | 2 | my ($str,$withKeyVal); | |||||||||||||||||||||||||||
| 595 | 2 | ▶ | if (@_) { # @keyVal | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 596 | 1 | $withKeyVal = 1; | |||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||
| 598 | 1 | my $ind = ' ' x $self->indentation; | |||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | 1 | $str = "%Section:\n"; | |||||||||||||||||||||||||||
| 601 | 1 | $str .= sprintf qq|%slevel="%s"\n|,$ind,$level; | |||||||||||||||||||||||||||
| 602 | 1 | $str .= sprintf qq|%stitle="%s"\n|,$ind,$title; | |||||||||||||||||||||||||||
| 603 | 1 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 604 | 1 | $str .= sprintf qq|%s%s="%s"\n|,$ind,shift,shift; | |||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||
| 606 | 1 | $str .= "\n"; | |||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||
| 608 | else { | ||||||||||||||||||||||||||||
| 609 | 1 | ▶ | if ($level == -1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 610 | 0 | $str = sprintf "=- %s\n\n",$title; | |||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||
| 612 | elsif ($level == 0) { | ||||||||||||||||||||||||||||
| 613 | 0 | $str = sprintf "==- %s\n\n",$title; | |||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||
| 615 | else { | ||||||||||||||||||||||||||||
| 616 | 1 | $str = sprintf "%s %s\n\n",('=' x $level),$title; | |||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | 2 | ▶ | if (defined $body) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 621 | 2 | $body =~ s/\s+$//; | |||||||||||||||||||||||||||
| 622 | 2 | ▶ | if ($body ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 623 | 2 | $str .= "$body\n\n"; | |||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||
| 627 | 2 | return $str; | |||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||
| 630 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | =head3 definitionList() - Definitions-Liste | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | $str = $gen->definitionList(\@items); | ||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||
| 638 | =head4 Description | ||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||
| 640 | Erzeuge eine Definitions-Liste mit den Elementen @items (Array von | ||||||||||||||||||||||||||||
| 641 | Schlüssel/Wert-Paaren oder von zweielementigen Sub-Arrays) und | ||||||||||||||||||||||||||||
| 642 | liefere den resultierenden Sdoc-Code zurück. | ||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||
| 644 | =head4 Examples | ||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||
| 646 | Die Aufrufe | ||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | $gen->definitionList([A=>'Eins',B=>'Zwei']); | ||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||
| 650 | oder | ||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||
| 652 | $gen->definitionList([['A','Eins'],['B','Zwei']]); | ||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||
| 654 | erzeugen | ||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||
| 656 | [A]:\n | ||||||||||||||||||||||||||||
| 657 | Eins\n | ||||||||||||||||||||||||||||
| 658 | \n | ||||||||||||||||||||||||||||
| 659 | [B]:\n | ||||||||||||||||||||||||||||
| 660 | Zwei\n | ||||||||||||||||||||||||||||
| 661 | \n | ||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||
| 663 | Endet der Schlüssel mit einem Doppelpunkt, wie bei den Aufrufen | ||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||
| 665 | $gen->definitionList(['A:'=>'Eins','B:'=>'Zwei']); | ||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | oder | ||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||
| 669 | $gen->definitionList([['A:','Eins'],['B:','Zwei']]); | ||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||
| 671 | steht der Doppelpunkt I<in> der Klammer | ||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||
| 673 | [A:]\n | ||||||||||||||||||||||||||||
| 674 | Eins\n | ||||||||||||||||||||||||||||
| 675 | \n | ||||||||||||||||||||||||||||
| 676 | [B:]\n | ||||||||||||||||||||||||||||
| 677 | Zwei\n | ||||||||||||||||||||||||||||
| 678 | \n | ||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||
| 680 | was bedeutet, dass dieser mit gesetzt wird. | ||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||
| 682 | =cut | ||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||
| 684 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||
| 686 | 4 | ▶ | sub definitionList { | ||||||||||||||||||||||||||
|
Subroutine
definitionList: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 687 | 4 | my ($self,$itemA) = @_; | |||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||
| 689 | 4 | my $step = 2; | |||||||||||||||||||||||||||
| 690 | 4 | ▶ | if (ref $itemA->[0]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 691 | 2 | $step = 1; # zweielementige Listen | |||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||
| 694 | 4 | my $str = ''; | |||||||||||||||||||||||||||
| 695 | 4 | my $ind = ' ' x $self->indentation; | |||||||||||||||||||||||||||
| 696 | 4 | ▶ | for (my $i = 0; $i < @$itemA; $i += $step) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 697 | 8 | ▶ | my ($key,$val) = $step == 1? @{$itemA->[$i]}: @$itemA[$i,$i+1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 698 | 8 | $val =~ s/^\n+//; | |||||||||||||||||||||||||||
| 699 | 8 | $val =~ s/\s+$//; | |||||||||||||||||||||||||||
| 700 | 8 | $val =~ s/^/$ind/mg; | |||||||||||||||||||||||||||
| 701 | 8 | ▶ | my $colon = substr($key,-1) eq ':'? '': ':'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 702 | 8 | $str .= "[$key]$colon\n$val\n\n"; | |||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||
| 705 | 4 | return $str; | |||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||
| 708 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||
| 710 | =head3 eof() - EOF-Kommentar | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||
| 714 | $str = $gen->eof; | ||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||
| 716 | =head4 Description | ||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||
| 718 | Erzeuge einen EOF-Kommentar und liefere den resultierenden | ||||||||||||||||||||||||||||
| 719 | Sdoc-Code zurück. | ||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||
| 721 | =head4 Example | ||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||
| 723 | $gen->eof; | ||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||
| 725 | erzeugt | ||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||
| 727 | # eof\n | ||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||
| 729 | =cut | ||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||
| 731 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||
| 733 | 1 | ▶ | sub eof { | ||||||||||||||||||||||||||
|
Subroutine
eof: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 734 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 735 | 1 | return "# eof\n"; | |||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||
| 738 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||
| 740 | =head1 VERSION | ||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||
| 742 | 1.240 | ||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||
| 744 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||
| 746 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||
| 748 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||
| 750 | Copyright (C) 2026 Frank Seitz | ||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||
| 752 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||
| 754 | This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 755 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | =cut | ||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||
| 759 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||
| 761 | 1 | 1; | |||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||
| 763 | # eof | ||||||||||||||||||||||||||||