[svn:parrot] r37070 - in trunk: . lib/Parrot/Docs t/perl
fperrad at svn.parrot.org
fperrad at svn.parrot.org
Mon Mar 2 07:39:57 UTC 2009
Author: fperrad
Date: Mon Mar 2 07:39:57 2009
New Revision: 37070
URL: https://trac.parrot.org/parrot/changeset/37070
Log:
[chm] HtmlHelp compiler accepts only HTML file. So, all file must be htmlized.
Added:
trunk/lib/Parrot/Docs/Text2HTML.pm (contents, props changed)
Modified:
trunk/MANIFEST
trunk/lib/Parrot/Docs/Item.pm
trunk/t/perl/Parrot_Docs.t
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST Mon Mar 2 03:15:40 2009 (r37069)
+++ trunk/MANIFEST Mon Mar 2 07:39:57 2009 (r37070)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Fri Feb 27 12:54:11 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Mon Mar 2 07:36:01 2009 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -1829,6 +1829,7 @@
lib/Parrot/Docs/Section/Perl.pm [devel]lib
lib/Parrot/Docs/Section/Tests.pm [devel]lib
lib/Parrot/Docs/Section/Tools.pm [devel]lib
+lib/Parrot/Docs/Text2HTML.pm [devel]lib
lib/Parrot/Harness/DefaultTests.pm [devel]lib
lib/Parrot/Harness/Options.pm [devel]lib
lib/Parrot/Harness/Smoke.pm [devel]lib
@@ -1945,8 +1946,8 @@
runtime/parrot/library/Iter.pir [library]
runtime/parrot/library/JSON.pir [library]
runtime/parrot/library/MIME/Base64.pir [library]
-runtime/parrot/library/Math/Random/mt19937ar.pir [library]
runtime/parrot/library/Math/Rand.pir [library]
+runtime/parrot/library/Math/Random/mt19937ar.pir [library]
runtime/parrot/library/NCI/call_toolkit_init.pir [library]
runtime/parrot/library/OpenGL.pir [library]
runtime/parrot/library/P6object.pir [library]
@@ -2858,7 +2859,7 @@
tools/dev/manicheck.pl []
tools/dev/mk_gitignore.pl []
tools/dev/mk_inno.pl []
-tools/dev/mk_inno_language.pl [devel]
+tools/dev/mk_inno_language.pl []
tools/dev/mk_language_shell.pl []
tools/dev/mk_manifest_and_skip.pl []
tools/dev/mk_native_pbc []
Modified: trunk/lib/Parrot/Docs/Item.pm
==============================================================================
--- trunk/lib/Parrot/Docs/Item.pm Mon Mar 2 03:15:40 2009 (r37069)
+++ trunk/lib/Parrot/Docs/Item.pm Mon Mar 2 07:39:57 2009 (r37070)
@@ -35,6 +35,7 @@
use Parrot::Docs::Directory;
use Parrot::Docs::POD2HTML;
+use Parrot::Docs::Text2HTML;
=item C<new_item($text, @paths)>
@@ -149,11 +150,11 @@
foreach my $rel_path (@rel_paths) {
my $file = $source->file_with_relative_path($rel_path);
- my $formatter = Parrot::Docs::POD2HTML->new;
if ( $file->contains_pod ) {
print "\n", $rel_path unless $silent;
+ my $formatter = Parrot::Docs::POD2HTML->new;
$formatter->write_html( $source, $target, $rel_path, $self );
$index_html .= $formatter->html_link( $formatter->append_html_suffix($rel_path),
@@ -174,8 +175,10 @@
elsif ( $file->is_docs_link ) {
print "\n", $rel_path unless $silent;
- # Link to the actual file rather than the HTML version.
- $index_html .= $formatter->html_link( $target->relative_path( $file->path ),
+ my $formatter = Parrot::Docs::Text2HTML->new;
+ $formatter->write_html( $source, $target, $rel_path, $self );
+
+ $index_html .= $formatter->html_link( $formatter->append_html_suffix($rel_path),
$source->relative_path( $file->path ) );
$index_html .= "<br>\n";
Added: trunk/lib/Parrot/Docs/Text2HTML.pm
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/lib/Parrot/Docs/Text2HTML.pm Mon Mar 2 07:39:57 2009 (r37070)
@@ -0,0 +1,97 @@
+# Copyright (C) 2009, Parrot Foundation.
+# $Id$
+
+=head1 NAME
+
+Parrot::Docs::Text2HTML - Plain text to HTML formatter
+
+=head1 SYNOPSIS
+
+ use Parrot::Docs::Text2HTML;
+
+=head1 DESCRIPTION
+
+C<Parrot::Docs::Text2HTML> subclasses C<Parrot::Docs::POD2HTML>.
+
+=head2 Instance Methods
+
+=over
+
+=cut
+
+package Parrot::Docs::Text2HTML;
+
+use strict;
+use warnings;
+
+use base qw( Parrot::Docs::POD2HTML );
+
+=item C<write_html($source, $target, $rel_path, $item)>
+
+Writes an HTML version of the file specified by C<$rel_path> in
+C<$source> to the equivalent location in C<$target>.
+
+=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);
+
+ $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<html_for_file($file)>
+
+Returns the HTML for the specified file.
+
+=cut
+
+sub html_for_file {
+ my $self = shift;
+ my $file = shift;
+
+ my $string = $self->html_header_before_title;
+ $string .= $self->{'Title'};
+ $string .= $self->html_header_after_title;
+ $string .= "\n<pre>\n";
+ $string .= $file->read;
+ $string .= "\n</pre>\n";
+ $string .= $self->html_footer;
+
+ return $string;
+}
+
+1;
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Modified: trunk/t/perl/Parrot_Docs.t
==============================================================================
--- trunk/t/perl/Parrot_Docs.t Mon Mar 2 03:15:40 2009 (r37069)
+++ trunk/t/perl/Parrot_Docs.t Mon Mar 2 07:39:57 2009 (r37070)
@@ -43,7 +43,7 @@
my @a = $d->files_of_type('Perl module');
# This will fail if you add a new module.
-is( @a, 7, 'files_of_type succeed' );
+is( @a, 8, 'files_of_type succeed' );
@a = $d->files_of_type('foo');
is( @a, 0, 'files_of_type fail' );
More information about the parrot-commits
mailing list