[Jspro-cvs] jsPro/scripts jsDoc.pl,NONE,1.1
Brought to you by:
wigleys
|
From: <wi...@us...> - 2003-10-01 14:43:02
|
Update of /cvsroot/jspro/jsPro/scripts
In directory sc8-pr-cvs1:/tmp/cvs-serv28704
Added Files:
jsDoc.pl
Log Message:
A simple Perl script that can be used to generate the README file
--- NEW FILE: jsDoc.pl ---
#!/usr/bin/perl -w
use strict;
my $iNumArgs = $#ARGV + 1;
if ($iNumArgs != 1) {
print "ERROR: Expected 1 argument but got $iNumArgs argument(s)\n\n";
&HELP;
} else {
my $sDocType = $ARGV[0];
if ($sDocType eq "-r" || $sDocType eq "--readme") {
&README;
} else {
print "ERROR: Unknown command line argument: \"$sDocType\"\n\n";
&HELP;
}
}
exit;
#this subroutine generates the README file output
sub README {
&README_INTRO;
opendir(DIR, ".");
my $counter = 1;
my $sShortDesc;
while (my $filename = readdir(DIR)) {
if ($filename =~ m/\.js$/) {
open( FILE, "< $filename" ) or die "Can't open $filename : $!";
print "$filename\n";
print "-------------------------------------------------------------------------------\n";
#for each line of the file
while (<FILE>) {
chomp;
# get the @shortDesc value
if ($_ =~ m/\@summary(\s*)/) {
$sShortDesc = $';
}
# if the current line is a function definition
if ($_ =~ m/function\(/) {
#match the " =" on this line
/ \=/;
#print the output line
print $counter . ". " . $` . "(): " . $sShortDesc . "\n";
$counter++;
#reset the shortDescription value ready for the next iteration
$sShortDesc = "";
}
}
print "\n";
close FILE;
}
}
&FOOTER;
}
#this subroutine prints the standard README header
sub README_INTRO {
print
"*******************************************************************************
* This software is OSI Certified Open Source Software. *
* OSI Certified is a certification mark of the Open Source Initiative. *
*******************************************************************************
jsPro by Stuart Wigley and Randolph T. Fielding
-------------------------------------------------------------------------------
jsPro is a set of object-based libraries that extend JavaScript with rich new
functionality. jsPro provides methods that extend the core classes (ie String,
Array, Math, Date) and implements new classes such as Chemica, Debug and Point.
In addition jsPro is developed to a high coding standard that includes modified
Hungarian Notation, structured error handling and JavaDoc style commenting.
This ensures that all methods in jsPro are readable, logical and easy to debug.
A lot of the methods used in these libraries have been inspired by functions
already available in PHP and other programming languages.
The aim of the project is simply to make jsPro the benchmark for high quality,
object-based functionality in JavaScript.
All improvements, suggestions, new methods and bug reports are welcome.
The following is a list of what has been implemented so far:
";
}
#this subroutine inserts a standard footer
sub FOOTER {
my $localTime = localtime();
print
"
This file was generated automatically: $localTime\n
";
}
#this subroutine displays help on the script
sub HELP {
die
"Usage: jsDoc [OPTION]
Example: jsDoc -r\n
-r, --readme generate README file for all JavaScript files in current
directory\n";
}
|