1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
#!/usr/bin/perl -w
use warnings;
use strict;
our $doxydocs;
use lib 'doxygen/perlmod';
use DoxyDocs;
my $startPtr = $doxydocs;
my $foundHash;
my $verbose = 0;
while(<STDIN>) {
next if (/\\newcommand\{\\ptex/);
if (/\\ptexPaste\{([^\}]+)\}/) {
my $x = $1;
my @temp=split/,/,$x;
die "$0: Syntax error for \\ptexPaste line $.\n" if ($#temp<0);
$foundHash=\$x;
my $ptr = $startPtr->{"classes"};
if ($temp[0]=~s/(^!)//) {
$ptr = $startPtr->{"files"};
}
findClassOrFile($ptr,$temp[0],\$foundHash);
(UNIVERSAL::isa( $foundHash, "HASH" )) or die "$0: Not found file or class $x at line $.\n";
if ($#temp>=1) {
my $nameOfKind = $temp[1];
my $kind = "variable";
if ($nameOfKind=~s/\(\)$//) {
$kind="function";
}
findKind($foundHash,$nameOfKind,\$foundHash,$kind);
(UNIVERSAL::isa( $foundHash, "HASH" ))
or die "$0: Not found function $x\n";
printHash($foundHash) if ($verbose);
}
$x = $temp[0];
my $substitution = getDetailed($foundHash);
$substitution =~ s/!PTEX_THISCLASS/$x/g;
s/\\ptexPaste\{([^\}]+)\}/$substitution/;
}
if (/\\ptexReadFile\{([^\}]+)\}/) {
print STDERR "Reading $1\n" if ($verbose);
readFile($1);
next;
}
print;
}
sub readFile
{
my ($file)=@_;
open(FILE, "<", $file) or die "Cannot open $file: $!\n";
while(<FILE>) {
print;
}
close(FILE);
}
sub getDetailed
{
my ($ptr)=@_;
my $x = $ptr->{"detailed"}->{"doc"};
my $buffer = "";
for my $item (@$x) {
$buffer .= procTextual($item);
}
return $buffer;
}
sub procTextual
{
my ($ptr)=@_;
my $type = $ptr->{"type"};
return "\n\n" if ($type eq "parbreak");
return "$type" unless ($type eq "text");
my $content = $ptr->{"content"};
defined($content) or $content="";
return $content;
}
sub printHash
{
my ($ptr)=@_;
for my $item (keys %$ptr) {
my $value = $ptr->{$item};
print STDERR "key=$item value=$value\n";
}
}
sub findClassOrFile
{
my ($ptr,$thisClassOrFile,$foundHash)=@_;
for my $item (@$ptr) {
if ($item->{"name"} eq $thisClassOrFile) {
$$foundHash = $item;
return;
}
}
}
sub findKind
{
my ($ptr,$thisFunc,$foundHash,$kind)=@_;
my ($lastKind,$lastName)=("","");
for my $item (keys %$ptr) {
print STDERR "key=$item\n" if ($verbose);
my $x = $ptr->{$item};
if (UNIVERSAL::isa( $x, "HASH" )) {
findKind($x,$thisFunc,$foundHash,$kind);
next;
} elsif (UNIVERSAL::isa( $x, "ARRAY" )) {
findKindA($x,$thisFunc,$foundHash,$kind);
next;
}
if ($item eq "kind") {
$lastKind = $x;
print STDERR "lastKind=$lastKind\n" if ($verbose);
}
if ($item eq "name") {
$lastName = $x;
print STDERR "lastName $lastName and thisFunc= $thisFunc\n" if ($verbose);
}
if ($lastName eq $thisFunc) {
next if (defined($kind) and !($lastKind eq $kind));
$$foundHash = $ptr;
print STDERR "Found for hash $$foundHash\n" if ($verbose);
return;
}
}
}
sub findKindA
{
my ($ptr,$thisFunc,$foundHash,$kind)=@_;
for my $item (@$ptr) {
print STDERR "findKindA key=$item\n" if ($verbose);
my $x = $item;
if (UNIVERSAL::isa( $x, "HASH" )) {
findKind($x,$thisFunc,$foundHash,$kind);
} elsif (UNIVERSAL::isa( $x, "ARRAY" )) {
findKindA($x,$thisFunc,$foundHash,$kind);
} else {
print STDERR "findKindA value=$x\n" if ($verbose);
}
}
}
|