2 # Upload all Webmin API docs in TWiki format to doxfer.com
6 $doxfer_host = "doxfer.com";
7 $doxfer_dir = "/home/doxfer/public_html/twiki/data/Webmin";
8 $temp_pod_dir = "/tmp/doxfer-wiki";
10 if ($0 =~ /^(.*\/)[^\/]+$/) {
15 # Build list of modules
16 @mods = ( [ "WebminCore", ".",
17 [ "web-lib-funcs.pl", "web-lib.pl", "ui-lib.pl" ],
18 "Core Webmin API" ] );
19 foreach my $mi (glob("*/module.info")) {
21 ($mod = $mi) =~ s/\/module.info//;
23 my $midata = `cat $mi`;
25 if ($midata =~ /library=(.*)/) {
26 @modlibs = split(/\s+/, $1);
29 @modlibs = ( $mod."-lib.pl" );
31 my $desc = $midata =~ /desc=(.*)/ ? $1 : $mod;
34 foreach my $f (@modlibs) {
36 my $data = `cat $mod/$f`;
37 if ($data =~ /=head1/) {
43 push(@mods, [ "Module $mod", $mod, \@podlibs, $desc ]);
47 # For each, run Pod to Wiki conversion
48 system("rm -rf $temp_pod_dir ; mkdir $temp_pod_dir");
50 print STDERR "Doing module $m->[0]\n";
51 my $wikiname = $m->[1] eq "." ? "ApiWebminCore"
52 : "Api".join("", map { ucfirst($_) }
53 split(/\-/, $m->[1]));
55 my $infile = "/tmp/pod2twiki.in";
56 open(INFILE, ">$infile");
57 foreach $f (@{$m->[2]}) {
58 # Replace un-decorated =item with =item *
59 # This is kosher according to the POD docs, but Pod2wiki doesn't
61 print STDERR "Doing file $f\n";
62 open(ORIGFILE, "$m->[1]/$f");
64 if (/^=item\s+([^\*].*)/) {
65 print INFILE "=item * $1\n";
76 my $outfile = "$temp_pod_dir/$wikiname.txt";
77 open(OUTFILE, ">$outfile");
78 print OUTFILE "%TOC%\n\n";
80 print OUTFILE "---+ Core Webmin API\n\n";
83 print OUTFILE "---+ Functions from module $m->[1]\n\n";
85 open(INFILE, $infile);
86 my $parser = Pod::Simple::Wiki->new('twiki');
87 $parser->output_fh(*OUTFILE);
88 $parser->parse_file(*INFILE);
96 open(OUT, ">$outfile");
98 foreach my $l (@lines) {
99 last if ($l =~ /POD\s+ERRORS/);
100 if ($l =~ /<verbatim>/) {
103 elsif ($l =~ /<\/verbatim>/) {
107 $l = &html_escape($l);
114 # Create summary page
115 open(SUMM, ">$temp_pod_dir/TheWebminAPI.txt");
116 print SUMM "---+ The Webmin API\n\n";
118 The Webmin API has a set of core functions that are available to all modules,
119 and functions exported by other modules that yours can optionally use. The APIs
120 for which documentation is available are linked to below :
123 foreach my $m (@mods) {
124 print SUMM " * [[$m->[4]][$m->[3]]]\n";
129 print STDERR "Uploading to $doxfer_host\n";
130 system("scp $temp_pod_dir/*.txt doxfer\@$doxfer_host:/home/doxfer/public_html/twiki/data/Webmin/");
131 print STDERR "done\n";
139 $tmp =~ s/\"/"/g;
140 $tmp =~ s/\'/'/g;