#!/usr/bin/perl -w # # appleScriptDoc: Convert pasted class descriptions to HTML. # # 2008-11-11: Written by Steven J. DeRose, sderose@acm.org. # # To do: use strict; use Getopt::Long; my $version = "2008-11-11"; my $e = ""; # error-message prefix my $quiet = 0; my $verbose = 0; ################################################################################ Getopt::Long::Configure ("ignore_case"); my $result = GetOptions( "h|help" => sub { showUsage(); exit; }, "q!" => \$quiet, "v+" => \$verbose, "version" => sub { showLicense(); exit; } ); ($result) || die "Bad options.\n"; ############################################################################### # Set implied options, validate option values... my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; $mon++; if ($mon < 10) { $mon = "0$mon"; } my $date = ($year + 1900) . "-$mon-$mday" . "T$hour:$min:$sec"; my $lsquo = "Ô"; my $rsquo = "Õ"; my $ldquo = "Ò"; my $rdquo = "Ó"; my $blanks = 1; # Are we in a block of blank lines? my $buf = ""; # Accumulate links to classes printHeader(); my $lnum = 0; while (my $l = <>) { $lnum++; if (1) { if ($l eq "\n") { $blanks++; next; } if ($blanks > 0) { print "\n\n\n"; print "\n"; print "
\n";
$blanks = 0;
}
}
# contains/contained by headers
if ($l =~ m/^contain/) {
$l =~ s!^contains ([\w ]+)!contains $1!g;
my $orig;
do {
$orig = $l;
$l =~ s!^(contains .*, )([\w ]+)!$1$2!g;
} while ($orig ne $l);
$l =~ s!^contains!Contains:!;
$l =~ s!^contained by (.*, )([\w ]+)!contained by $1$2!g;
$l =~ s!^contained by!
Contained by:!;
$l =~ s!^(
!;
}
# element/property headers
$l =~ s!^elements!\n
Elements
!;
$l =~ s!^properties!\nProperties
!;
# property spec lines
$l =~ s!^([\w ]+)\s?(\(.*?\))\s*:\s(.*)$!$1 $2 $3!;
# class name header line
$l =~ s!\[inh. (\w+) > (\w+)![inh. $1 > $2!;
$l =~ s!\[inh. (\w+)![inh. $1!;
$l =~ s!([\[;] ?)see also ([\w ]+)!$1see also $2!;
# expect en-space 0x2002 before the "n"
$l =~ s!^(.*?)(\sn,?\s)!$1
\n$1$2!;
$l =~ s!^(.*?)(\sn,.*? : )!$1
\n$1$2!;
$l =~ s!\] : (.*$)!] : $1!;
# curly quotes
$l =~ s!$ldquo!!g;
$l =~ s!$rdquo!
!g;
$l =~ s!$lsquo!\‘!g;
$l =~ s!$rsquo!\’!g;
if ($l =~ m/.*$!!;
$name =~ s!\nClass list (move into table at top):
\n";
print "\n\n$buf
\n\n";
print "