ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/doc/genpdf
Revision: 1.1
Committed: Sat Jul 21 01:25:40 2007 UTC (19 years, 1 month ago) by pippijn
Branch: MAIN
Log Message:
reworked documentation system

File Contents

# User Rev Content
1 pippijn 1.1 #!/usr/bin/env perl
2    
3     use strict;
4     use warnings;
5     use utf8;
6    
7     BEGIN {
8     unshift @INC, "lib";
9     }
10    
11     use Pod::POM;
12    
13     use LaTeX;
14    
15     my $parser = new Pod::POM;
16     my $current;
17    
18     my @podfiles = <podhelp/*.pod>;
19    
20     sub latexise {
21     my ($data) = @_;
22     my $name = $current;
23     $name =~ s/serv/Serv/;
24     $name = ucfirst $name;
25     $$data =~ s/&nick&/$name/g;
26    
27     $$data =~ s/#/\\#/g;
28     $$data =~ s/_/\\_/g;
29     $$data =~ s/</\$<\$/g;
30     $$data =~ s/>/\$>\$/g;
31     $$data =~ s/\|/\$|\$/g;
32    
33     $$data
34     }
35    
36     sub delatexise {
37     my ($data) = @_;
38     my $result = "";
39     for (split /\n/, $$data) {
40     if (/^ /) {
41     $_ =~ s/\\#/#/g;
42     $_ =~ s/\\_/_/g;
43     $_ =~ s/\$<\$/</g;
44     $_ =~ s/\$>\$/>/g;
45     $_ =~ s/\$\|\$/|/g;
46     }
47     $result .= "$_\n";
48     }
49    
50     $$data = $result
51     }
52    
53     mkdir "latex";
54     mkdir "latex/podhelp";
55     mkdir "latex/poddoc";
56    
57     for my $file (@podfiles) {
58     ($current) = $file =~ /podhelp\/(.+)\.pod$/;
59     my $data = do { local $/; open my $fh, "<$file" or die "$file: $!"; <$fh> };
60     $data .= "\n" . do { local $/; open my $fh, "<help.pod" or die "help.pod: $!"; <$fh> };
61     my $pom = $parser->parse_text ($data)
62     or die $parser->error();
63     open my $fh, ">latex/podhelp/$current.tex";
64     print $fh $pom->present ("LaTeX::Help");
65     close $fh;
66     }
67    
68     @podfiles = <poddoc/*.pod>;
69    
70     for my $file (@podfiles) {
71     ($current) = $file =~ /poddoc\/(.+)\.pod$/;
72     my $data = do { local $/; open my $fh, "<$file" or die "$file: $!"; <$fh> };
73     my $pom = $parser->parse_text ($data)
74     or die $parser->error();
75     open my $fh, ">latex/poddoc/$current.tex";
76     print $fh $pom->present ("LaTeX::Doc");
77     close $fh;
78     }
79    
80     @podfiles = <podsvs/*.pod>;
81    
82     for my $file (@podfiles) {
83     ($current) = $file =~ /podsvs\/(.+)\.pod$/;
84     my $data = do { local $/; open my $fh, "<$file" or die "$file: $!"; <$fh> };
85     my $pom = $parser->parse_text ($data)
86     or die $parser->error();
87     open my $fh, ">latex/poddoc/$current.tex";
88     print $fh $pom->present ("LaTeX::Doc");
89     close $fh;
90     }