[svn:parrot] r37663 - in trunk: . docs/resources lib/Parrot/Docs
coke at svn.parrot.org
coke at svn.parrot.org
Tue Mar 24 02:57:29 UTC 2009
Author: coke
Date: Tue Mar 24 02:57:29 2009
New Revision: 37663
URL: https://trac.parrot.org/parrot/changeset/37663
Log:
[docs] TT #477 - generate HTML for PASM/PIR targets in POD.
Patch courtesy rg, plus a small tweak to the CSS to generate nice looking code blocks.
Modified:
trunk/CREDITS
trunk/docs/resources/parrot.css
trunk/lib/Parrot/Docs/POD2HTML.pm
Modified: trunk/CREDITS
==============================================================================
--- trunk/CREDITS Tue Mar 24 02:29:12 2009 (r37662)
+++ trunk/CREDITS Tue Mar 24 02:57:29 2009 (r37663)
@@ -749,6 +749,9 @@
E: pdcawley at bofh.org.uk
W: http://www.bofh.org.uk:8080/
+U: rg
+D: fixes to pod2html generator
+
N: Reini Urban
U: rurban
E: rurban at cpan.org
Modified: trunk/docs/resources/parrot.css
==============================================================================
--- trunk/docs/resources/parrot.css Tue Mar 24 02:29:12 2009 (r37662)
+++ trunk/docs/resources/parrot.css Tue Mar 24 02:57:29 2009 (r37663)
@@ -93,3 +93,11 @@
padding-top: 0.5em;
padding-bottom: 1em;
}
+
+pre {
+ border: 1px dashed #3b5b91;
+ padding: 5px;
+ color: black;
+ background: #BFCa7d;
+ overflow: auto;
+}
Modified: trunk/lib/Parrot/Docs/POD2HTML.pm
==============================================================================
--- trunk/lib/Parrot/Docs/POD2HTML.pm Tue Mar 24 02:29:12 2009 (r37662)
+++ trunk/lib/Parrot/Docs/POD2HTML.pm Tue Mar 24 02:57:29 2009 (r37663)
@@ -33,6 +33,23 @@
our $VERSION = '1.0';
use Parrot::Docs::HTMLPage;
+use Parrot::Distribution;
+
+=item C<new()>
+
+Extend C<Pod::Simple::HTML> method to accept PIR and PASM sections that
+contain example code, which will be put into a <pre> HTML element.
+
+=cut
+
+sub new {
+ my $new = shift->SUPER::new(@_);
+
+ $new->accept_targets('PIR', 'PASM');
+ delete(@{$new->{'Tagmap'}}{'Data','/Data'});
+
+ return $new;
+}
=item C<do_beginning()>
@@ -125,6 +142,9 @@
elsif ( $tagname eq 'Data' ) {
$self->process_data_start_token($token);
}
+ elsif ( $tagname eq 'for' ) {
+ $self->process_for_start_token($token);
+ }
else {
$self->process_other_start_token($token);
}
@@ -309,7 +329,29 @@
return;
}
- printf { $self->{'output_fh'} } "\n" . $next->text . "\n";
+ if ($self->{IN_CODE_BLOCK}) {
+ print { $self->{'output_fh'} } $next->text;
+ }
+ else {
+ print { $self->{'output_fh'} } "\n" . $next->text . "\n";
+ }
+}
+
+=item C<process_for_start_token($token)>
+
+Processes a for start token.
+
+=cut
+
+sub process_for_start_token {
+ my $self = shift;
+ my $token = shift;
+ my $target = $token->attr("target");
+
+ if ($target eq "PIR" || $target eq "PASM") {
+ print { $self->{'output_fh'} } '<pre>';
+ $self->{IN_CODE_BLOCK} = 1;
+ }
}
=item C<process_other_start_token($token)>
@@ -365,6 +407,10 @@
elsif ( $tagname eq 'item-text' ) {
$self->{IN_ITEM_TEXT} = 0;
}
+ elsif ( $tagname eq 'for' ) {
+ print { $self->{'output_fh'} } '</pre>' if $self->{IN_CODE_BLOCK};
+ $self->{IN_CODE_BLOCK} = 0;
+ }
print { $self->{'output_fh'} } $self->{'Tagmap'}{"/$tagname"} || return;
More information about the parrot-commits
mailing list