ca...@geeknest.com
unread,Sep 13, 2005, 10:21:47 AM9/13/05Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jsan-...@googlegroups.com
Revision: 465
Author: adam
Date: 2005-09-13 10:21:39 -0400 (Tue, 13 Sep 2005)
Log Message:
-----------
Adding as much of JavaScript::Pod as TorgoX completed. He's going to be more or less offline for a while, moving house and so on, so if we want JSPOD finished, we need to finish it.
But apparently this code should pretty much work.
Added Paths:
-----------
perl/JavaScript-Pod/
perl/JavaScript-Pod/branches/
perl/JavaScript-Pod/tags/
perl/JavaScript-Pod/trunk/
perl/JavaScript-Pod/trunk/lib/
perl/JavaScript-Pod/trunk/lib/JavaScript/
perl/JavaScript-Pod/trunk/lib/JavaScript/Pod.pm
Added: perl/JavaScript-Pod/trunk/lib/JavaScript/Pod.pm
===================================================================
--- perl/JavaScript-Pod/trunk/lib/JavaScript/Pod.pm 2005-09-09 00:01:12 UTC (rev 464)
+++ perl/JavaScript-Pod/trunk/lib/JavaScript/Pod.pm 2005-09-13 14:21:39 UTC (rev 465)
@@ -0,0 +1,101 @@
+require 5; # Time-stamp: "2005-07-04 00:31:45 ADT"
+use strict;
+package JavaScript::Pod;
+use vars qw($VERSION @ISA);
+# Pod for JavaScript, Java, and wherever else you can /*...*/ it in!
+
+$VERSION = "1.02";
+
+use Pod::Simple;
+die "No Blackbox?!"
+ unless "Pod::Simple::BlackBox" eq join '-', @Pod::Simple::ISA;
+
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+package Pod::Simple::HorrorBox;
+use vars qw($VERSION @ISA);
+@ISA = ('Pod::Simple::BlackBox');
+@Pod::Simple::ISA = (__PACKAGE__);
+
+sub _nonneg { ($_[0] < 0) ? 0 : $_[0] }
+sub _splice_in (\@\$;@) {
+ my $arrR = shift @_;
+ my $iR = shift @_;
+ if(@_ == 1) { $arrR->[ $$iR ] = $_[0]; return; }
+ if(@_ == 0) { splice @$arrR, $$iR, 1; --$$iR; return; }
+
+ splice @$arrR, $$iR, 1, @_;
+ $$iR += (@_ - 1);
+ return;
+}
+
+sub parse_lines {
+ my($this, @lines) = @_;
+
+ for(my $i = 0; $i < @lines; $i++) {
+ ++$this->{"JS_input_line_count"};
+ if(!defined $lines[$i]) {
+ # Pass thru!
+
+ } elsif( $lines[$i] =~ m(^\*/\s*$)s ) {
+ # End of commentblock, probably.
+ if( $this->{"JS_am_in_commentpod"} ) {
+ $this ->{"JS_am_in_commentpod"} = 0;
+ _splice_in( @lines, $i,
+ "\n",
+ "=pod\n",
+ "\n",
+ "=cut\n",
+ "\n"
+ );
+ # That =pod is to make sure that the =cut can't trigger an error
+ # for being superfluous.
+ } else {
+ # Harmless. Pass thru.
+ }
+
+ } elsif( $this->{"JS_comment_just_started"} ) {
+ $this ->{"JS_comment_just_started"} = 0;
+
+ if( $lines[$i] =~ m/\S/ ) {
+ #It's definitely not pod, so we'll skip processing this.
+ $lines[$i] = "\n";
+
+ } else {
+ # Pod starts on the next line.
+ $this->{"JS_am_in_commentpod"} = 1;
+ _splice_in( @lines, $i,
+ "#line "._nonneg($this->{"JS_input_line_count"}-1)."\n",
+ "=pod\n",
+ "\n"
+ );
+ }
+
+ } elsif( $this->{"JS_am_in_commentpod"} ) {
+ # Yay, it's a commentpod line. Pass it thru!
+
+ } elsif( $lines[$i] =~ m(^/\*\s*$)s ) {
+ # Starting a comment block, potentially a poddish one!
+ $this->{"JS_comment_just_started"} = 1;
+ $this->{"JS_am_in_commentpod"} = 0;
+ $lines[$i] = "\n";
+
+ } else {
+ # It's junk - either code, or non-pod comment. Toss it out.
+ $lines[$i] = "\n";
+ }
+ }
+
+ #print "Lines [", map("<$_>", @lines), "]\n\n";
+ return $this->SUPER::parse_lines(@lines);
+}
+
+1;
+__END__
+
+Simple jspod2html program:
+
+#!/usr/bin/perl
+use JavaScript::Pod;
+use Pod::Simple::HTML;
+Pod::Simple::HTML->filter(@ARGV);