#!/usr/local/bin/perl -w # xs2pod - Max Baker $VERSION = 0.1; =head1 NAME xs2pod =head1 DESCRIPTION Creates POD documentation files out of .xs files =head1 PREREQUISITES This script requires the C module. =pod OSNAMES any =pod SCRIPT CATEGORIES CPAN =cut use File::Temp qw/:POSIX/; use Getopt::Long; # move options to begin block because use GLIB is a compile-time check, not run-time BEGIN { GetOptions(\%Args, 'h|help','debug','lib_dir=s','author=s','d|dir=s','save_temp'); $Lib_Dir = $Args{lib_dir} || "$ENV{HOME}/lib/site_perl"; if (-d $Lib_Dir) { eval "use lib \"$Lib_Dir\";"; } } if ($Args{h} or !scalar @ARGV) { die &usage; } use Glib::ParseXSDoc; use Glib::GenPod; $Glib::GenPod::AUTHORS = $Args{lib_dir} || 'The Gaim Team'; $Glib::ParseXSDoc::verbose = $Args{debug}; $Dir = $Args{d}; # Glib::ParseXSDoc outputs to stdout :-/, redirect to temp file $tmp_file = tmpnam(); Debug("Temp File : $tmp_file"); open (T, ">$tmp_file") or die "Can't open $tmp_file. $!\n"; my $old_fh = select T; # Parse all .xs files given on command line to data structures xsdocparse(@ARGV); select $old_fh; close T or die "Disk Full? $!\n"; # Parse data structres into Pod - Output to Directory given xsdoc2pod($tmp_file, $Dir); unlink $tmp_file unless $Args{save_temp}; exit(0); sub usage { return <<"end_usage"; $0 - Convert XS to Pod documentation (ver:$VERSION) Usage : xs2pod file1.xs [file2.xs] ... [fileN.xs] Requires : Glib module from CPAN, Two-step process Using the modules listed below. Options : --debug --save_temp - Save Temp File used in parse step --lib_dir dir - lib dir to use for non-root installs --author "string" - Used to generate footer --dir dir - Output directory for .pod Default ./blib/lib/* More Information : perldoc Glib::ParseXSDoc perldoc Glib::GenPod end_usage } sub Debug { return unless $Args{debug}; print @_, "\n"; }