File: builddoc

package info (click to toggle)
spong 2.7.7-19
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,880 kB
  • ctags: 1,224
  • sloc: perl: 6,640; sh: 2,247; makefile: 237
file content (94 lines) | stat: -rwxr-xr-x 2,580 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl

# builddoc - build Spong documentation in various formatted
#
# This utility is designed to build the Spong documentation from all of
# the POD document sources. It will build various formats: html, text and man
#

# $Id: builddoc,v 1.2 2001/01/06 06:36:13 sljohnson Exp $

use File::Basename;
use Getopt::Long;

@suffixlist = ('.pm','.pl','.pod');

Getopt::Long::Configure("pass_through");

if (! GetOptions("dir:s" => \$dstdir, "type:s" =>$doctype )) {
   print STDERR "Incorrect Usage\n";
   usage();
}

if (! defined $doctype && ! defined $ARGV[0] ) { 
   print STDERR "You have to specify documentation type: html, text, man , etc\n\n";
   usage();
}

$doctype = $ARGV[0] unless defined $doctype;

if ($doctype eq "html" || $doctype eq "dist" ) { $suffix = ".html"; }
elsif ($doctype eq  "text") { $suffix = ".txt"; }
elsif ($doctype eq "man") { $suffix = ".man"; }
else {
   print STDERR "Invalid documentation type. Must be: html, text, man\n";
   usage();
}

$files = `find ../ -type f -print \| egrep '*.pod\$\|*.pm\$\|plugins' \| grep -v CVS`;
@files = split /\s+/,$files;

system "rm -f pod2html-*" if $doctype eq "html";

# Don't try this at home. I use this option to build the documentation for
# Spong distributions. I have some customized programs which do this.
# Write me at sjohnson@monsters.org if you want to know what I use.
if ($doctype eq "dist") {
   # Make sure that CWD is in a known sane place
   chomp($cwd = `pwd`);
   $mydir = dirname($cwd . "/" . $0);
   chdir $mydir;

   $files =~ s/\s+/ /g;  # Make the whitepace into spaces

   $cmd = "mpod2html -dir ../www/docs/ -tocname spongtoc -idxname spongindex" 
            . " $files >/tmp/pod.out 2>&1";
   system $cmd;
   exit 0;
}

foreach $file ( @files ) {

   print "$file\n";

   $basename = basename($file,@suffixlist);

   $outfile = $basename . $suffix;
   $outfile = $dstdir . "/" . $outfile if $dstdir;

   if ($doctype eq "html") { 
      $cmd = "pod2html --recurse --podroot=../ --podpath=pod:src " . 
                "--infile=$file --outfile=$outfile 2>/dev/null"; 
   } elsif ($doctype eq "text") {
      $cmd = "pod2text <$file >$outfile 2>/dev/null";
   } elsif ($doctype eq "man") {
      $cmd = "pod2man --center 'Spong 2.7' --release '2.7' $file >$outfile " .
                "2>/dev/null";  
   }
 
   system $cmd;
}

sub usage {

   print <<EOF;
Usage: builddoc [--dir dstdir] --type doctype | doctype

Where:
   --dir   dstdir           Directory in which to create output files
   --type  html|text|man    Type of documentation to create.

EOF

   exit 0;
}