| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | # $Id: gen_help.pl,v 2.2 2004-12-09 08:41:13 pajas Exp $ | ||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Text::Wrap qw(wrap); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | if ($ARGV[0]=~'^(-h|--help)?\$') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 10 | 0 | print <<EOF; | |||||||||||||||||||||||||||||||
| 11 | Generates help module from RecDescentXML source. | ||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | Usage: $0 <source.xml> | ||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | EOF | ||||||||||||||||||||||||||||||||
| 16 | 0 | exit; | |||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | 1 | my $parser=XML::LibXML->new(); | |||||||||||||||||||||||||||||||
| 20 | 1 | $parser->load_ext_dtd(1); | |||||||||||||||||||||||||||||||
| 21 | 1 | $parser->validation(1); | |||||||||||||||||||||||||||||||
| 22 | 1 | $parser->keep_blanks(1); | |||||||||||||||||||||||||||||||
| 23 | 1 | my $doc=$parser->parse_file($ARGV[0]); | |||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 1 | my $dom=$doc->getDocumentElement(); | |||||||||||||||||||||||||||||||
| 26 | 1 | my ($rules)=$dom->findnodes('./rules'); | |||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 1 | my $ruledoc; | |||||||||||||||||||||||||||||||
| 29 | my $title; | ||||||||||||||||||||||||||||||||
| 30 | 1 | my @aliases; | |||||||||||||||||||||||||||||||
| 31 | 1 | my @seealso; | |||||||||||||||||||||||||||||||
| 32 | 1 | my @usage; | |||||||||||||||||||||||||||||||
| 33 | 1 | my $desc; | |||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 1 | print "# This file was automatically generated from $ARGV[0] on \n# ",scalar(localtime),"\n"; | |||||||||||||||||||||||||||||||
| 37 | 1 | print <<'PREAMB'; | |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | package XML::XSH2::Help; | ||||||||||||||||||||||||||||||||
| 40 | use strict; | ||||||||||||||||||||||||||||||||
| 41 | use vars qw($HELP %HELP $Apropos); | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | PREAMB | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 1 | print "\$HELP=<<'END';\n"; | |||||||||||||||||||||||||||||||
| 47 | 1 | print "\n Welcome to XSH help\n"; | |||||||||||||||||||||||||||||||
| 48 | 1 | print " -------------------\n\n"; | |||||||||||||||||||||||||||||||
| 49 | 1 | print " In this help:\n [topic] is a cross reference that can be followed using 'help topic'\n\n"; | |||||||||||||||||||||||||||||||
| 50 | 1 | ($desc)=$dom->findnodes('./doc/description'); | |||||||||||||||||||||||||||||||
| 51 | 1 | ▶ | print_description($desc," "," ") if ($desc); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 52 | 1 | print "\n\n Within the interactive shell, press <TAB> for auto-completion.\n"; | |||||||||||||||||||||||||||||||
| 53 | 1 | print "END\n\n"; | |||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 1 | print "\$HELP{'toc'}=[<<'END'];\n"; | |||||||||||||||||||||||||||||||
| 56 | 1 | print "\nHelp items:\n"; | |||||||||||||||||||||||||||||||
| 57 | 1 | print "-----------\n\n"; | |||||||||||||||||||||||||||||||
| 58 | 1 | print " toc - this page\n\n"; | |||||||||||||||||||||||||||||||
| 59 | 1 | print " XSH Language Topics:\n\n"; | |||||||||||||||||||||||||||||||
| 60 | 1 | foreach (sort { $a->getAttribute('id') cmp | |||||||||||||||||||||||||||||||
| 61 | $b->getAttribute('id') } | ||||||||||||||||||||||||||||||||
| 62 | $dom->findnodes("/recdescent-xml/doc/section")) { | ||||||||||||||||||||||||||||||||
| 63 | 13 | print " ",$_->getAttribute('id')," - "; | |||||||||||||||||||||||||||||||
| 64 | 13 | print wrap(""," ", | |||||||||||||||||||||||||||||||
| 65 | get_text($_->findnodes("title"))), | ||||||||||||||||||||||||||||||||
| 66 | "\n"; | ||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | 1 | print "\n XSH Commands:\n\n"; | |||||||||||||||||||||||||||||||
| 69 | print wrap(" "," ", | ||||||||||||||||||||||||||||||||
| 70 | 117 | join ", ", sort map { get_name($_) } | |||||||||||||||||||||||||||||||
| 71 | 1 | grep {defined($_)} | |||||||||||||||||||||||||||||||
| 72 | $dom->findnodes("//rules/rule[\@type='command']")), | ||||||||||||||||||||||||||||||||
| 73 | "\n\n"; | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 1 | print " XSH Argument Types:\n\n"; | |||||||||||||||||||||||||||||||
| 76 | print wrap(" "," ", | ||||||||||||||||||||||||||||||||
| 77 | 13 | join ", ", sort map { get_name($_) } | |||||||||||||||||||||||||||||||
| 78 | 1 | grep {defined($_)} | |||||||||||||||||||||||||||||||
| 79 | $dom->findnodes("//rules/rule[\@type='argtype']")), | ||||||||||||||||||||||||||||||||
| 80 | "\n\n"; | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | 1 | print " XPath Extension Functions:\n\n"; | |||||||||||||||||||||||||||||||
| 83 | print wrap(" "," ", | ||||||||||||||||||||||||||||||||
| 84 | 48 | join ", ", sort map { get_name($_) } | |||||||||||||||||||||||||||||||
| 85 | 1 | grep {defined($_)} | |||||||||||||||||||||||||||||||
| 86 | $dom->findnodes("//rules/rule[\@type='function']")), | ||||||||||||||||||||||||||||||||
| 87 | "\n\n"; | ||||||||||||||||||||||||||||||||
| 88 | 1 | print "END\n\n"; | |||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | 1 | my %apropos; | |||||||||||||||||||||||||||||||
| 92 | 1 | foreach my $r ($rules->findnodes('./rule')) { | |||||||||||||||||||||||||||||||
| 93 | 223 | ▶ | next unless $r; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 94 | 223 | my ($ruledoc)=$r->findnodes('./documentation'); | |||||||||||||||||||||||||||||||
| 95 | 223 | ▶ | next unless $ruledoc; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | 179 | my $name=get_name($r); | |||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | 179 | my ($shortdesc)=$ruledoc->findnodes('./shortdesc'); | |||||||||||||||||||||||||||||||
| 99 | 179 | ▶ | $apropos{$name} = get_text($shortdesc) if ($shortdesc); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 100 | 179 | $apropos{$name} =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | 179 | print "\$HELP{'$name'}=[<<'END'];\n"; | |||||||||||||||||||||||||||||||
| 103 | 179 | ($title)=$ruledoc->findnodes('./title'); | |||||||||||||||||||||||||||||||
| 104 | 179 | ▶ | print get_text($title),"\n\n" if ($title); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | 179 | @usage=$ruledoc->findnodes('./usage'); | |||||||||||||||||||||||||||||||
| 107 | 179 | ▶ | if (@usage) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 108 | 165 | print "usage: "; | |||||||||||||||||||||||||||||||
| 109 | 165 | foreach (@usage) { | |||||||||||||||||||||||||||||||
| 110 | 180 | my $usage=get_text($_); | |||||||||||||||||||||||||||||||
| 111 | 180 | $usage=~s/\s+/ /; | |||||||||||||||||||||||||||||||
| 112 | 180 | print $usage,"\n "; | |||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||
| 114 | 165 | print "\n"; | |||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||
| 116 | 179 | @aliases=grep {defined($_)} $r->findnodes('./aliases/alias'); | |||||||||||||||||||||||||||||||
| 117 | 179 | ▶ | if (@aliases) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 118 | 49 | print "aliases: ",join " ",map { get_name($_) } @aliases; | |||||||||||||||||||||||||||||||
| 119 | 49 | print "\n\n"; | |||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||
| 121 | 179 | ($desc)=$ruledoc->findnodes('./description'); | |||||||||||||||||||||||||||||||
| 122 | 179 | ▶ | if ($desc) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 123 | 179 | print "description:\n"; | |||||||||||||||||||||||||||||||
| 124 | 179 | print_description($desc," "x(13)," "x(13)); | |||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||
| 126 | 179 | @seealso=grep {defined($_)} $ruledoc->findnodes('./see-also/ruleref'); | |||||||||||||||||||||||||||||||
| 127 | 179 | ▶ | if (@seealso) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 128 | 173 | print "see also: ",join " ", map { get_name($_) }# grep {defined($_)} | |||||||||||||||||||||||||||||||
| 129 | 79 | map { $_->findnodes('id(@ref)') } @seealso; | |||||||||||||||||||||||||||||||
| 130 | 79 | print "\n\n"; | |||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | 179 | print "END\n\n"; | |||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | 179 | foreach (@aliases) { | |||||||||||||||||||||||||||||||
| 136 | 69 | print "\$HELP{'",get_name($_),"'}=\$HELP{'$name'};\n"; | |||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||
| 138 | 179 | print "\n"; | |||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 1 | foreach my $sec ($dom->findnodes('/recdescent-xml/doc/section')) { | |||||||||||||||||||||||||||||||
| 143 | 13 | my $name=$sec->getAttribute('id'); | |||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | 13 | print "\$HELP{'$name'}=[<<'END'];\n"; | |||||||||||||||||||||||||||||||
| 146 | 13 | ($title)=$sec->findnodes('./title'); | |||||||||||||||||||||||||||||||
| 147 | 13 | ▶ | if ($title) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 148 | 13 | my $t=get_text($title); | |||||||||||||||||||||||||||||||
| 149 | 13 | print $t,"\n"; | |||||||||||||||||||||||||||||||
| 150 | 13 | print '-' x length($t),"\n\n"; | |||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | 13 | print_description($sec," "x(2)," "x(2)); | |||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||
| 155 | 13 | my @commands=$dom->findnodes("//rules/rule[\@type='command' and ". | |||||||||||||||||||||||||||||||
| 156 | "documentation[contains(\@sections,'$name')]]"); | ||||||||||||||||||||||||||||||||
| 157 | 13 | ▶ | if (@commands) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 158 | 9 | print "\nRelated help items:\n"; | |||||||||||||||||||||||||||||||
| 159 | print wrap(" "," ", | ||||||||||||||||||||||||||||||||
| 160 | 9 | join ", ", sort map { get_name($_) } | |||||||||||||||||||||||||||||||
| 161 | @commands), | ||||||||||||||||||||||||||||||||
| 162 | "\n\n"; | ||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||
| 164 | 13 | print "END\n\n"; | |||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | 1 | print "\$HELP{'commands'}=\$HELP{'command'};\n"; | |||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 170 | 1 | print Data::Dumper->Dump([\%apropos],[qw(Apropos)]); | |||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||
| 172 | 1 | print "\n1;\n__END__\n\n"; | |||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||
| 174 | 1 | exit; | |||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||
| 176 | ## ================================================ | ||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | sub strip_space { | ||||||||||||||||||||||||||||||||
| 179 | 1214 | ▶ | my ($text)=@_; | ||||||||||||||||||||||||||||||
|
Subroutine
strip_space: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 180 | 1214 | $text=~s/^\s*//; | |||||||||||||||||||||||||||||||
| 181 | 1214 | $text=~s/\s*$//; | |||||||||||||||||||||||||||||||
| 182 | 1214 | return $text; | |||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||
| 185 | sub get_name { | ||||||||||||||||||||||||||||||||
| 186 | 1489 | ▶ | my ($r)=@_; | ||||||||||||||||||||||||||||||
|
Subroutine
get_name: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 187 | 1489 | ▶ | return $r->getAttribute('name') ne "" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 188 | ? $r->getAttribute('name') | ||||||||||||||||||||||||||||||||
| 189 | : $r->getAttribute('id'); | ||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||
| 192 | sub get_text { | ||||||||||||||||||||||||||||||||
| 193 | 1919 | ▶ | my ($node,$no_strip)=@_; | ||||||||||||||||||||||||||||||
|
Subroutine
get_text: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||||
| 194 | 1919 | my $text=""; | |||||||||||||||||||||||||||||||
| 195 | 1919 | foreach my $n ($node->childNodes()) { | |||||||||||||||||||||||||||||||
| 196 | 5169 | ▶ | if ($n->nodeType() == XML::LibXML::XML_TEXT_NODE || | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$n->nodeType == 3 or $n->nodeType == 4
MC/DC50%1/2
$n->nodeType == 3 or $n->nodeType == 4
$n->nodeType == 3
$n->nodeType == 4
Truth table66%2/3
A or B
A= $n->nodeType == 3B= $n->nodeType == 4
| |||||||||||||||||||||||||||||||||
| 197 | $n->nodeType() == XML::LibXML::XML_CDATA_SECTION_NODE) { | ||||||||||||||||||||||||||||||||
| 198 | 3439 | my $data=$n->getData(); | |||||||||||||||||||||||||||||||
| 199 | 3439 | $data=~s/\t/ /g; | |||||||||||||||||||||||||||||||
| 200 | 3439 | $text.=$data; | |||||||||||||||||||||||||||||||
| 201 | } elsif ($n->nodeType() == XML::LibXML::XML_ELEMENT_NODE) { | ||||||||||||||||||||||||||||||||
| 202 | 1594 | ▶ | if ($n->nodeName() eq 'link') { | ||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||
| 203 | 18 | $text.="[".get_text($n,1)."]"; | |||||||||||||||||||||||||||||||
| 204 | } elsif ($n->nodeName() eq 'xref') { | ||||||||||||||||||||||||||||||||
| 205 | 499 | $text.="["; | |||||||||||||||||||||||||||||||
| 206 | 499 | my ($ref)=$node->findnodes("id('".$n->getAttribute('linkend')."')"); | |||||||||||||||||||||||||||||||
| 207 | 499 | ▶ | if ($ref) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 208 | 499 | $text.=get_name($ref); | |||||||||||||||||||||||||||||||
| 209 | } else { | ||||||||||||||||||||||||||||||||
| 210 | 0 | print STDERR "Reference to undefined identifier: ",$n->getAttribute('linkend'),"\n"; | |||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||
| 212 | 499 | $text.="]"; | |||||||||||||||||||||||||||||||
| 213 | } elsif ($n->nodeName() eq 'typeref') { | ||||||||||||||||||||||||||||||||
| 214 | 3 | foreach (split /\s/,$n->getAttribute('types')) { | |||||||||||||||||||||||||||||||
| 215 | 3 | $text.=join ", ", sort map { get_name($_) } grep {defined($_)} $node->findnodes("//rules/rule[\@type='$_']"); | |||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||
| 217 | } elsif ($n->nodeName() eq 'tab') { | ||||||||||||||||||||||||||||||||
| 218 | 256 | $text.="\t" x $n->getAttribute('count'); | |||||||||||||||||||||||||||||||
| 219 | } elsif ($n->nodeName() eq 'literal') { | ||||||||||||||||||||||||||||||||
| 220 | 687 | $text.="'".get_text($n,1)."'"; | |||||||||||||||||||||||||||||||
| 221 | } else { | ||||||||||||||||||||||||||||||||
| 222 | 131 | $text.=get_text($n); | |||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||
| 226 | 1919 | ▶ | return $no_strip ? $text : strip_space($text); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | 66 | ▶ | sub max { ($_[0] > $_[1]) ? $_[0] : $_[1] } | ||||||||||||||||||||||||||||||
|
Subroutine
max: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||
| 231 | sub print_description { | ||||||||||||||||||||||||||||||||
| 232 | 311 | ▶ | my ($desc,$indent,$bigindent)=@_; | ||||||||||||||||||||||||||||||
|
Subroutine
print_description: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||
| 233 | 311 | foreach my $c ($desc->childNodes()) { | |||||||||||||||||||||||||||||||
| 234 | 2007 | ▶ | if ($c->nodeType == XML::LibXML::XML_ELEMENT_NODE) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 235 | 848 | ▶ | if ($c->nodeName eq 'para') { | ||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||
| 236 | 507 | my $t=get_text($c); | |||||||||||||||||||||||||||||||
| 237 | 507 | $t=~s/\s+/ /g; | |||||||||||||||||||||||||||||||
| 238 | 507 | print wrap($indent,$bigindent,$t),"\n\n"; | |||||||||||||||||||||||||||||||
| 239 | 507 | $indent=$bigindent; | |||||||||||||||||||||||||||||||
| 240 | } elsif ($c->nodeName eq 'section') { | ||||||||||||||||||||||||||||||||
| 241 | 7 | my ($title)=$c->findnodes('./title'); | |||||||||||||||||||||||||||||||
| 242 | 7 | ▶ | if ($title) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 243 | 7 | my $t=get_text($title); | |||||||||||||||||||||||||||||||
| 244 | 7 | print $bigindent.$t,"\n"; | |||||||||||||||||||||||||||||||
| 245 | 7 | print $bigindent.'-' x length($t),"\n\n"; | |||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||
| 247 | 7 | print_description($c,$indent." ",$bigindent." "); | |||||||||||||||||||||||||||||||
| 248 | } elsif ($c->nodeName eq 'enumerate') { | ||||||||||||||||||||||||||||||||
| 249 | 3 | my $n=1; | |||||||||||||||||||||||||||||||
| 250 | 3 | foreach my $item ($c->findnodes('listitem')) { | |||||||||||||||||||||||||||||||
| 251 | 20 | print_description($item,$indent." ".($n++).". ",$bigindent." "); | |||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||
| 253 | } elsif ($c->nodeName eq 'code') { | ||||||||||||||||||||||||||||||||
| 254 | 154 | local $_ = get_text($c); | |||||||||||||||||||||||||||||||
| 255 | 154 | s/\n[ ]*/\n$bigindent/mg; | |||||||||||||||||||||||||||||||
| 256 | 154 | s/\\\n/\\\n$bigindent /g; | |||||||||||||||||||||||||||||||
| 257 | 154 | s/\t/ /g; | |||||||||||||||||||||||||||||||
| 258 | 154 | print "$bigindent$_\n"; | |||||||||||||||||||||||||||||||
| 259 | } elsif ($c->nodeName eq 'example') { | ||||||||||||||||||||||||||||||||
| 260 | 91 | foreach (map { get_text($_) } $c->findnodes('./title')) { | |||||||||||||||||||||||||||||||
| 261 | 66 | s/\s+/ /g; | |||||||||||||||||||||||||||||||
| 262 | 66 | print wrap("",$bigindent,"Example:"." "x(max(1,length($bigindent)-8))."$_\n"); | |||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||
| 264 | 91 | ▶ | unless ($c->findnodes('./title')) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 265 | 25 | print "Example:"; | |||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||
| 267 | 91 | print "\n"; | |||||||||||||||||||||||||||||||
| 268 | 91 | print_description($c,$indent,$bigindent); | |||||||||||||||||||||||||||||||
| 269 | 91 | print "\n"; | |||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||