#! @PERL@ # Extract R object INDEX information from Rd files. # Usage: R CMD Rdindex [options] files # The titles are nicely formatted between two columns (defaults are 25 # and 72, respectively). # Copyright (C) 1997-2002 The R Core Development Team # # This document 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 via WWW at # http://www.gnu.org/copyleft/gpl.html. You can also obtain it by # writing to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA. require 5.005; # for Text::Wrap::fill in formatDL use Getopt::Long; use R::Utils; use R::Vars; use R::Rd; my $revision = ' $Revision: 1.17 $ '; my $version; my $name; $revision =~ / ([\d\.]*) /; $version = $1; ($name = $0) =~ s|.*/||; ## Options my $opt_l = 25; # left target column for formatting my $opt_r = 72; # right target column for formatting my $opt_os = $R::Vars::OSTYPE; my @knownoptions = ("h|help", "v|version", "d|data", "l|left=i" => \$opt_l, "r|right=i" => \$opt_r, "os|OS=s" => \$opt_os); GetOptions(@knownoptions) || &usage(); &R_version($name, $version) if $opt_v; &usage() if $opt_h; my @Rdfiles; my $only_data_set_docs = 0; if($#ARGV == 0 && -d $ARGV[0]) { $only_data_set_docs = 1 if($opt_d); my $dir = $ARGV[0]; if(-d &file_path($dir, "man")) { $dir = &file_path($dir, "man"); } @Rdfiles = &list_files_with_exts($dir, "[Rr]d"); $dir = &file_path($dir, $opt_os); if(-d $dir) { @Rdfiles = (@Rdfiles, &list_files_with_exts($dir, "[Rr]d")); } } else { foreach my $arg (@ARGV) { @Rdfiles = (@Rdfiles, glob($arg)); } } foreach my $rdfile (sort @Rdfiles) { my $rdinfo = R::Rd->info($rdfile, $opt_os); next if($only_data_set_docs && grep(!/^datasets$/, @{$rdinfo->{"keywords"}})); print R::Utils::formatDL($rdinfo->{"name"}, $rdinfo->{"title"}, "table", $opt_r, $opt_l - 1), "\n"; } sub usage { print STDERR <. END exit 0; } ### Local Variables: *** ### mode: perl *** ### perl-indent-level: 4 *** ### End: ***