[svn:parrot] r47925 - in branches/html_cleanup: lib/Parrot/Docs tools/docs
coke at svn.parrot.org
coke at svn.parrot.org
Wed Jun 30 01:07:12 UTC 2010
Author: coke
Date: Wed Jun 30 01:07:12 2010
New Revision: 47925
URL: https://trac.parrot.org/parrot/changeset/47925
Log:
Actually generate some HTML output again.
Begin to decouple our pod2html converter from Distribution.pm; Leave it in
a very ugly state for now.
if you run tools/docs/make_html_docs.l you can see we have several dynpmcs
that have no POD documentation. This should probably be fixed in trunk.
Added:
branches/html_cleanup/lib/Parrot/Docs/PodToHtml.pm
- copied, changed from r47685, branches/html_cleanup/lib/Parrot/Docs/POD2HTML.pm
Modified:
branches/html_cleanup/tools/docs/make_html_docs.pl
Copied and modified: branches/html_cleanup/lib/Parrot/Docs/PodToHtml.pm (from r47685, branches/html_cleanup/lib/Parrot/Docs/POD2HTML.pm)
==============================================================================
--- branches/html_cleanup/lib/Parrot/Docs/POD2HTML.pm Fri Jun 18 05:22:31 2010 (r47685, copy source)
+++ branches/html_cleanup/lib/Parrot/Docs/PodToHtml.pm Wed Jun 30 01:07:12 2010 (r47925)
@@ -3,18 +3,16 @@
=head1 NAME
-Parrot::Docs::POD2HTML - POD to HTML formatter
+Parrot::Docs::PodToHtml - POD to HTML converter
=head1 SYNOPSIS
- use Parrot::Docs::POD2HTML;
+We subclass L<Pod::Simple::HTML>; see that module for details.
=head1 DESCRIPTION
-C<Parrot::Docs::POD2HTML> subclasses C<Pod::Simple::HTML> to provide
-various Parrot-specific formatting features, such as linking
-C<CE<lt>Parrot::I<Module>E<gt>> and C<FE<lt>I<file>E<gt>>, and using the
-Parrot house-style provided by C<Parrot::HTMLPage>.
+Subclass C<Pod::Simple::HTML> to override behavior for various Parrot-specific
+formatting features, and to use our own style.
=head2 Instance Methods
@@ -22,7 +20,7 @@
=cut
-package Parrot::Docs::POD2HTML;
+package Parrot::Docs::PodToHtml;
use strict;
use warnings;
@@ -33,7 +31,7 @@
our $VERSION = '1.0';
use Parrot::Docs::HTMLPage;
-use Parrot::Distribution;
+#use Parrot::Distribution;
=item C<new()>
@@ -135,9 +133,9 @@
if ( $tagname eq 'L' ) {
$self->process_link_start_token($token);
}
- elsif ( $tagname eq 'F' ) {
- $self->process_file_start_token($token);
- }
+ #elsif ( $tagname eq 'F' ) {
+ #$self->process_file_start_token($token);
+ #}
elsif ( $tagname eq 'C' ) {
$self->process_code_start_token($token);
}
@@ -206,20 +204,20 @@
my $text = $next->text;
- if ( $text =~ /^Parrot::/o ) {
+ #if ( $text =~ /^Parrot::/o ) {
- my $href = $self->href_for_perl_module($text);
+ #my $href = $self->href_for_perl_module($text);
- esc($text);
+ #esc($text);
- if ($href) {
- $text = "<a href='$href'>$text</a>";
- }
- }
- else {
+ #if ($href) {
+ #$text = "<a href='$href'>$text</a>";
+ #}
+ #}
+ #else {
esc($text);
- }
+ #}
print { $self->{'output_fh'} } $text;
}
@@ -231,41 +229,45 @@
documentation file.
=cut
+##
+##sub process_file_start_token {
+ ##my $self = shift;
+ ##my $token = shift;
+ ##my $tagname = $token->tagname;
+ ##my $next = $self->get_token;
+##
+##
+ ##if ( $next->type eq 'text' ) {
+ ##my $text = $next->text;
+ ##my $dist = Parrot::Distribution->new;
+##
+####warn "Token is $token; tagname is $tagname, next is $next, text is $text\n";
+ ### Only link to files that will have HTML pages.
-sub process_file_start_token {
- my $self = shift;
- my $token = shift;
- my $tagname = $token->tagname;
- my $next = $self->get_token;
-
- if ( $next->type eq 'text' ) {
- my $text = $next->text;
- my $dist = Parrot::Distribution->new;
-
- # Only link to files that will have HTML pages.
-
- if (
- $dist->relative_path_is_file($text)
+ ##if (
+ ##$dist->relative_path_is_file($text)
# A little bit of a hack to avoid config template files.
- and $text !~ /\.in$/o and $dist->file_with_relative_path($text)->contains_pod
- )
- {
- my $path = $self->append_html_suffix($text);
- my $file = $self->{TARGET}->file_with_relative_path($path);
-
- print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname}
- . $self->html_link( $self->{DOCS_FILE}->parent->relative_path($file), esc($text) );
- }
- else {
- print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname} . esc($text);
- }
- }
- else {
- $self->unget_token($next);
- print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname};
- }
-}
+ ##and $text !~ /\.in$/o and $dist->file_with_relative_path($text)->contains_pod
+ ##)
+ ##{
+ ##my $path = $self->append_html_suffix($text);
+##warn "HEY MY PATH IS $path\n";
+ ##my $file = $self->{TARGET}->file_with_relative_path($path);
+##warn "HEY I GOT THIS FAR\n";
+
+ ##print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname}
+ ##. $self->html_link( $self->{DOCS_FILE}->parent->relative_path($file), esc($text) );
+ ##}
+ ##else {
+ ##print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname} . esc($text);
+ ##}
+ ##}
+ ##else {
+ ##$self->unget_token($next);
+ ##print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname};
+ ##}
+##}
=item C<process_item_text_or_head_start_token($token)>
@@ -506,16 +508,16 @@
my $to = shift;
my $section = shift;
- if ( $to =~ /^Parrot::/o ) {
- my $href = $self->href_for_perl_module($to);
+ #if ( $to =~ /^Parrot::/o ) {
+ #my $href = $self->href_for_perl_module($to);
# This gets corrupted somewhere down the line, with
# Parrot/PackFile/ConstTable.pm.html being turned into
# Parrot/PackFile%2FConstTable.pm.html and thus breaking
# the CSS and images somehow.
- return $href if defined $href;
- }
+ #return $href if defined $href;
+ #}
return 'TODO';
}
@@ -548,12 +550,12 @@
my $path = $self->append_html_suffix( $dist->relative_path($file) );
# This is the docs file for the module.
- $file = $self->{TARGET}->file_with_relative_path($path);
+ ## $file = $self->{TARGET}->file_with_relative_path($path);
# There's no point in linking to the file you are already in.
- return if $file == $self->{DOCS_FILE};
+ ##return if $file == $self->{DOCS_FILE};
- return $self->href_path( $self->{DOCS_FILE}->parent->relative_path($file) );
+ ##return $self->href_path( $self->{DOCS_FILE}->parent->relative_path($file) );
}
=item C<do_end()>
@@ -595,39 +597,39 @@
=cut
-sub write_html {
- my $self = shift;
- my $source = shift;
- my $target = shift;
- my $rel_path = shift;
- my $item = shift;
- my $file = $source->file_with_relative_path($rel_path);
-
- return unless $file->contains_pod;
-
- $self->{TARGET} = $target;
-
- # Use our own method for consistency.
- $self->{'Title'} = $file->title;
-
- $rel_path = $self->append_html_suffix($rel_path);
-
- my $docs_file = $target->file_with_relative_path($rel_path);
-
- $self->{DOCS_FILE} = $docs_file;
-
- $rel_path = $self->href_path( $docs_file->parent->relative_path( $target->parent_path ) );
-
- my $name = $target->name;
-
- # This is a cheat because we know that all top-level sections
- # have their indexes in the root directory - but it works.
-
- $self->{NAV_BAR} = $item->html_navigation("$rel_path/$name");
- $self->{RESOURCES_URL} = "$rel_path/resources";
-
- $docs_file->write( $self->html_for_file($file) );
-}
+## sub write_html {
+ ## my $self = shift;
+ ## my $source = shift;
+ ## my $target = shift;
+ ## my $rel_path = shift;
+ ## my $item = shift;
+ ## my $file = $source->file_with_relative_path($rel_path);
+##
+ ## return unless $file->contains_pod;
+##
+ ## $self->{TARGET} = $target;
+##
+ ## # Use our own method for consistency.
+ ## $self->{'Title'} = $file->title;
+##
+ ## $rel_path = $self->append_html_suffix($rel_path);
+##
+ ## my $docs_file = $target->file_with_relative_path($rel_path);
+##
+ ## $self->{DOCS_FILE} = $docs_file;
+##
+ ## $rel_path = $self->href_path( $docs_file->parent->relative_path( $target->parent_path ) );
+##
+ ## my $name = $target->name;
+##
+ ## # This is a cheat because we know that all top-level sections
+ ## # have their indexes in the root directory - but it works.
+##
+ ## $self->{NAV_BAR} = $item->html_navigation("$rel_path/$name");
+ ## $self->{RESOURCES_URL} = "$rel_path/resources";
+##
+ ## $docs_file->write( $self->html_for_file($file) );
+## }
=item C<append_html_suffix($path)>
Modified: branches/html_cleanup/tools/docs/make_html_docs.pl
==============================================================================
--- branches/html_cleanup/tools/docs/make_html_docs.pl Wed Jun 30 01:01:42 2010 (r47924)
+++ branches/html_cleanup/tools/docs/make_html_docs.pl Wed Jun 30 01:07:12 2010 (r47925)
@@ -16,16 +16,18 @@
=cut
-use strict;
+use 5.12.0;
+
use warnings;
use lib 'lib';
-
-use Cwd;
use Fatal qw/open close/;
+
+use File::Basename qw/basename dirname/;
+use File::Path qw/make_path/;
use File::Spec;
use Getopt::Long;
use JSON;
-use Parrot::Docs::Item;
+use Parrot::Docs::PodToHtml;
my ( $version );
@@ -33,6 +35,8 @@
die "Usage: $0 --version\n" unless $version;
+my $target_dir = 'docs/html2';
+
my $json = JSON->new();
# Transform the json
@@ -73,11 +77,6 @@
$pages{lc $section->{page}} = $section;
}
-# Generate all the raw pages we'll need.
-my $target_dir = 'docs/html2';
-
-## print Dumper(\%pages); use Data::Dumper;
-
foreach my $page (keys %pages) {
$page = $pages{$page};
foreach my $section (@{$page->{content}}) {
@@ -103,13 +102,20 @@
die "$input not found or not a regular file\n" .
"You might need to restrict your glob specification.";
}
- my $path = File::Spec->catfile(cwd() , $input);
- my $docfile = Parrot::Docs::Item->new('', $input);
+ my $formatter = Parrot::Docs::PodToHtml->new();
+
+ my $outfile = File::Spec->catfile($target_dir, $input);
+ $outfile =~ s/\.[^.]*$/.html/;
+
+ my $dir = File::Path::make_path(File::Basename::dirname($outfile));
- # If the file has pod, use pod2html on it.
+ open my $out_fh, '>', $outfile;
- # Otherwise, use text2html.
+ $formatter->output_fh($out_fh);
+ $formatter->parse_file($input);
+ warn "$input generated no HTML output\n"
+ unless $formatter->content_seen;
$generated{$input} = 1;
}
More information about the parrot-commits
mailing list