#! @PERL@ ## Convert R documentation into HTML, LaTeX and text format # Copyright (C) 1997 Friedrich Leisch # Copyright (C) 2000-8 The R Core Development Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # A copy of the GNU General Public License is available at # http://www.r-project.org/Licenses/ # Send any bug reports to r-bugs@r-project.org. use Getopt::Long; use R::Rdconv; use R::Utils; use R::Vars; my $revision = ' $Rev$ '; my $version; my $name; ## switch on autoflushing for STDOUT. We want this as we ## write to both STDERR (warnings) and STDOUT. $| = 1; $revision =~ / ([\d\.]*) /; $version = $1; ($name = $0) =~ s|.*/||; ## ## Used in Rdconv.pm and Rdlists.pm via $main::OSdir, and hence must not ## be lexical. Argh. $OSdir = $R::Vars::OSTYPE; ## my @knownoptions = ("debug|d", "type|t:s", "h|help", "v|version", "o|output:s", "os|OS=s" => \$OSdir, "encoding=s", "package=s"); GetOptions (@knownoptions) || &usage(); &R_version($name, $version) if $opt_v; &usage() if $opt_h; my $out = 0; if(defined $opt_o) { if(length($opt_o)) { $out = $opt_o; } else { $out = $ARGV[0]; $out =~ s/.Rd$//i; } } $out = 0 if $out eq "-"; my $enc = "unknown"; $enc = $opt_encoding if $opt_encoding; my $pkg = "unknown"; $pkg = $opt_package if $opt_package; my $ver = ""; $ver = $opt_version if $opt_version; my %types_and_exts = ("txt", "", "html", ".html", "latex", ".tex", "example", ".R"); my $opt_type_ok = 0; foreach my $type (keys(%types_and_exts)) { if($opt_type =~ /$type/i) { if(defined $opt_o && length($opt_o) == 0) { $out .= $types_and_exts{$type}; } Rdconv($ARGV[0], $opt_type, $opt_debug, $out, $pkg, $ver, $enc); $opt_type_ok = 1; last; } } if(!$opt_type_ok) { print STDERR "Unknown type: options are " . join(", ", sort(keys(%types_and_exts))) . ".\n"; } sub usage { print <. END exit 0; } ### Local Variables: *** ### mode: perl *** ### perl-indent-level: 4 *** ### End: ***