<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#! /usr/bin/perl -w

use strict;
use Rdoc;
use FileHandle;
use Getopt::Long;

my $dir;
GetOptions( "dir=s" =&gt; \$dir );
if ( $dir ) {
  chdir( $dir ) || die "unable to cd to $dir: $!";
}

if ( $#ARGV &gt;= 0 ) {
  for ( @ARGV ) {
    &amp;doFile ( $_ );
  }
} else {
  opendir DIR, "." or die "can't open cwd - strange: $!";
  for ( sort ( grep /\.Rd$/, readdir DIR ) ) {
    &amp;doFile( $_ );
  }
}

				# table for mapping internal tags
sub doFile {
  my $SdInternal = {
		    "link" =&gt; [  "",  "" ], # "\link{foo}" becomes "foo"
		    "code" =&gt; [ "`", "'" ], # "\code{foo}" becomes "`foo'"
		    "eqn"  =&gt; [  "",  "" ], # "\eqn{x}" becomes "x"
		   };
  my $file = shift;
  print "==================\nFile:\t$file\n=====================\n";
  my $rd = Rdoc-&gt;new( $file );
#   print scalar( @{ $SdInternal-&gt;{'code'} } ), "\n";
#   print $SdInternal-&gt;{'code'}[0], "\n";
#   print scalar( @{ $SdInternal-&gt;{'link'} } ), "\n";
#   print $SdInternal-&gt;{'link'}[0], "\n";
#  print scalar( @{ $SdInternal-&gt;{'foo'} } ), "\n";
#  exit 0;
  for ( @{ $rd-&gt;{ '.order' } } ) {
    &amp;printSections( $_, $rd-&gt;{ 'section' } ), next if /^section:/io;
    &amp;printArray( $_, $rd-&gt;{ $_ } ), next if /^(alias|keyword)$/io;
    print $_, ":\n";
    &amp;printIndent( Rdoc::transform( $rd-&gt;{$_}, $SdInternal ) );
  }
}


sub printIndent {
  my $lines = shift;
  for ( split( "\n", $lines ) ) {
    print "  ", $_, "\n";
  }
}
    
sub printArray {
  my $name = shift;
  my $arry = shift;
  print $name, ":\n";
  print "  ", join( ', ', @{ $arry } ), "\n";
}

sub printSections {
  my $secname = shift;
  $secname =~ s/^section://io;
  my $sechash = shift;
  print "section - ", $secname, ":\n";
  printIndent( $sechash-&gt;{ $secname } );
}
</pre></body></html>