-
Notifications
You must be signed in to change notification settings - Fork 1
/
makedocs.pl
executable file
·123 lines (91 loc) · 5.07 KB
/
makedocs.pl
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
#!/usr/bin/perl
# Copyright 2001-2003 Plain Black LLC
# Licensed under the GNU GPL - http://www.gnu.org/licenses/gpl.html
use Parse::PlainConfig;
use Getopt::Long;
use File::Find;
use File::Path;
use POSIX;
our $version = "";
our $buildDir = "/data/builds";
our $pod2html = "/usr/bin/pod2html";
GetOptions(
'version=s'=>\$version,
'buildDir=s'=>\$buildDir,
'pod2html=s'=>\$pod2html
);
if ($version ne "") {
buildFromDir();
} else {
print <<STOP;
Usage: $0 --version=0.0.0
Options:
--buildDir The base directory to create all builds in. Defaults to /data/builds.
--pod2html The path to the pod2html script. Defaults to /usr/bin/pod2html.
--version The build version. Used to create folders and filenames.
STOP
}
sub buildFromDir {
my $dir = $_[0];
my $basedir = $buildDir."/".$version."/WebGUI/lib/WebGUI";
opendir(DIR,$basedir."/".$dir);
my @files = readdir(DIR);
closedir(DIR);
@files = sort @files;
my $first = 1;
foreach my $file (@files) {
if ($file =~ /(.*?)\.pm$/ && $file ne "Operation.pm") {
if ($first) {
print "Making API docs directory: ".$buildDir."/".$version."/api/".$dir."\n";
system("mkdir -p ".$buildDir."/".$version."/api/".$dir);
$first = 0;
}
$outfile = $buildDir."/".$version."/api/".$dir."/".$1.".html";
print "Generating docs for ".$basedir."/".$dir."/".$file."\n";
system($pod2html." --quiet --css http://files.plainblack.com/downloads/builds/api.css --noindex ".$basedir."/".$dir."/".$file." > ".$outfile);
# filterContent($outfile);
} elsif ($file ne "." && $file ne "..") {
buildFromDir($dir."/".$file);
}
}
}
sub filterContent {
my $file = $_[0];
print "Filtering content for ".$file."\n";
open(FILE,"<".$file);
my $content;
while (<FILE>) {
$content .= $_;
}
close(FILE);
$content =~ s/NOTE:/<b>NOTE:<\/b>/ig;
$content =~ s/TIP:/<b>TIP:<\/b>/ig;
$content =~ s/<a .*?>//ig;
$content =~ s/<\/a>//ig;
$content =~ s/<hr>//ig;
$content =~ s/<head>(.*?)<\/head>//ixsg;
$pattern = 'INDEX BEGIN.*?INDEX END';
$content =~ s/$pattern//isg;
$content =~ s/SYNOPSIS/Synopsis/g;
$content =~ s/DESCRIPTION/Description/g;
$content =~ s/METHODS/Methods/g;
# $pattern = '<h1>DESCRIPTION<\/h1>
#<P>(.*?)<\/P>
#<P>';
# $content =~ s/$pattern/$1<p>/isg;
# $content =~ s/<h2>/<h4 style="font-family: Arial;font-size: 10pt;font-style: italic; font-weight: bold;">/ig;
# $content =~ s/<\/h2>/<\/h4>/ig;
# $pattern = '<h1>NAME<\/h1>
#<P>Package .*?::(.*?)<\/P>
#<P>';
# $content =~ s/$pattern/<br><br><h2 style="font-family: Arial;font-size: 18pt;">$1<\/h2>/isg;
# $content =~ s/<h1>/<h3 style="font-family: Arial;font-size: 14pt;">/ig;
# $content =~ s/<\/h1>/<\/h3>/ig;
$pattern = '<DT><STRONG>(.*?)<\/STRONG><BR>';
$content =~ s/$pattern/<dt><span style="font-family: Arial;font-style: italic;">$1<\/span>/ig;
$content =~ s/<pre>/<pre style="font-family: courier,courier new,fixed;">/ig;
$content =~ s/<\!-- -->//gi;
open(FILE,">".$file);
print FILE $content;
close(FILE);
}