1. Shlomi Fish
  2. XML-CompareML

Commits

shl...@52c325ad-5fd0-0310-8a0f-c43feede02cc  committed b8c8fe5

Added full test coverage for XML::CompareML::DocBook is broken.

  • Participants
  • Parent commits f7c3750
  • Branches default

Comments (0)

Files changed (7)

File MANIFEST

View file
 t/files/scm-comparison.xml
 t/files/scm-sys-list-1.xml
 t/pod.t
+t/pod-coverage.t

File META.yml

View file
 ---
 name: XML-CompareML
-version: 0.2.1
+version: 0.2.2
 author:
   - 'Shlomi Fish <shlomif@iglu.org.il>'
 abstract: A processor for the CompareML markup language
 provides:
   XML::CompareML:
     file: lib/XML/CompareML.pm
-    version: 0.2.1
+    version: 0.2.2
   XML::CompareML::Base:
     file: lib/XML/CompareML/Base.pm
   XML::CompareML::DTD::Generate:

File lib/XML/CompareML/Base.pm

View file
 use strict;
 use warnings;
 
+=head1 NAME
+
+XML::CompareML::Base - base class for the CompareML-to-something converters.
+
+=head1 SYNOPSIS
+
+see L<XML::CompareML>.
+
+=head1 METHODS
+
+=head2 new()
+
+A constructor - should be used by a derived class.
+
+=head2 $compare->process()
+
+See L<XML::CompareML>
+=cut
+
 use XML::LibXML;
 
 use XML::CompareML::DTD::Generate;
 use base qw(Class::Accessor);
 
 __PACKAGE__->mk_accessors(
-    qw(timestamp root_elem impls_indexes impls_names),
+    qw(_timestamp root_elem impls_indexes impls_names),
     qw(parser dom),
 );
 
     return $self;
 }
 
-sub findnodes
+sub _findnodes
 {
     my $self = shift;
     return $self->root_elem->findnodes(@_);
 }
 
-sub xml_node_contents_to_string
+sub _xml_node_contents_to_string
 {
     my $self = shift;
     my $node = shift;
     {
         return;
     }
-    return $self->xml_node_contents_to_string($name_elem);    
+    return $self->_xml_node_contents_to_string($name_elem);    
 }
 
 sub _impl_get_name
     return $self->_impl_get_tag_text($impl_elem, "name");
 }
 
-sub get_implementations
+sub _get_implementations
 {
     my $self = shift;
     return 
                         'name' => $self->_impl_get_name($_)
                     } 
                 } 
-            $self->findnodes("/comparison/meta/implementations/impl")
+            $self->_findnodes("/comparison/meta/implementations/impl")
         ];
 }
 
-sub get_timestamp
+sub _get_timestamp
 {
     my $self = shift;
-    my @nodes = $self->findnodes("/comparison/meta/timestamp");
+    my @nodes = $self->_findnodes("/comparison/meta/timestamp");
     if (@nodes)
     {
-        return $self->xml_node_contents_to_string($nodes[0]);
+        return $self->_xml_node_contents_to_string($nodes[0]);
     }
     else
     {
     my ($contents_elem) = $self->root_elem->getChildrenByTagName("contents");
     my ($top_section_elem) = $contents_elem->getChildrenByTagName("section");
 
-    my @impls = @{$self->get_implementations()};
+    my @impls = @{$self->_get_implementations()};
 
     $self->{impls} = \@impls;
     $self->impls_indexes(+{ map { $impls[$_]->{'id'} => $_ } (0 .. $#impls) });
     $self->impls_names(+{map { $_->{'id'} => $_->{'name'} } @impls });
-    $self->timestamp($self->get_timestamp());
+    $self->_timestamp($self->_get_timestamp());
 
     $self->{document_text} = "";
     $self->{toc_text} = "";
 
     # Make sure we print anything only when we finished extracting all
     # the meta-data.
-    $self->print_header();
+    $self->_print_header();
 
-    $self->start_rendering();
+    $self->_start_rendering();
 
-    $self->render_section('elem' => $top_section_elem, 'depth' => 0,);
+    $self->_render_section('elem' => $top_section_elem, 'depth' => 0,);
 
-    $self->finish_rendering();
+    $self->_finish_rendering();
 
     print {*{$self->{o}}} $self->{document_text};
     
-    $self->print_footer();
+    $self->_print_footer();
 }
 
-sub name
+sub _name
 {
     my $self = shift;
     my $id = shift;
     return $self->impls_names->{$id};
 }
 
-sub sorter
+sub _sorter
 {
     my $self = shift;
     my $impl = shift;
     return $indexes->{$impl};
 }
 
-sub out
+sub _out
 {
     my $self = shift;
     $self->{document_text} .= join("", @_);
 }
 
-sub toc_out
+sub _toc_out
 {
     my $self = shift;
     $self->{toc_text} .= join("", @_);
 }
 
-sub render_section
+sub _render_section
 {
     my $self = shift;
     my %args = (@_);
         'sub_sections' => \@sub_sections,
         );
         
-    $self->render_section_start(
+    $self->_render_section_start(
         @args
     );
     
     if ($compare)
     {
-        $self->render_sys_table_start(@args);
+        $self->_render_sys_table_start(@args);
 
         my @systems = ($compare->getChildrenByTagName("s"));
         my %kv =
             (map
-                { $_->getAttribute("id") => $self->render_s_elem($_) }
+                { $_->getAttribute("id") => $self->_render_s_elem($_) }
                 @systems
             );
-        my @keys_sorted = (sort { $self->sorter($a) <=> $self->sorter($b) } keys(%kv));
+        my @keys_sorted = (sort { $self->_sorter($a) <=> $self->_sorter($b) } keys(%kv));
         foreach my $k (@keys_sorted)
         {
-            $self->render_sys_table_row(
-                'name' => $self->name($k),
+            $self->_render_sys_table_row(
+                'name' => $self->_name($k),
                 'desc' => $kv{$k},
             );
         }
-        $self->render_sys_table_end();
+        $self->_render_sys_table_end();
     }
 
     foreach my $sub (@sub_sections)
     {
-        $self->render_section(
+        $self->_render_section(
             'elem' => $sub,
             'depth' => ($depth+1)
             );
     }
 
-    $self->render_section_end(
+    $self->_render_section_end(
         @args,
     );
 }
 
+=head1 AUTHOR
+
+Shlomi Fish, L<http://www.shlomifish.org/>.
+
+=head1 SEE ALSO
+
+L<XML::CompareML>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2004, Shlomi Fish. All rights reserved.
+
+You can use, modify and distribute this module under the terms of the MIT X11
+license. ( L<http://www.opensource.org/licenses/mit-license.php> ).
+
+=cut
+
 1;

File lib/XML/CompareML/DTD/Generate.pm

View file
 use strict;
 use warnings;
 
+=head1 NAME
+
+XML::CompareML::DTD::Generate - generate the DTD for CompareML.
+
+=head1 SYNOPSIS
+
+    use XML::CompareML::DTD::Generate;
+
+    my $dtd_text = XML::CompareML::DTD::Generate::get_dtd();
+
+=head1 FUNCTIONS
+
+=head2 get_dtd()
+
+Calculates and returns the DTD. Not exported.
+
+=cut
+
 sub get_dtd
 {
     return <<"EOF";
 <!ATTLIST impl id CDATA #REQUIRED>    
 EOF
 }
+
+=head1 AUTHOR
+
+Shlomi Fish, L<http://www.shlomifish.org/>.
+
+=head1 SEE ALSO
+
+L<XML::CompareML>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2004, Shlomi Fish. All rights reserved.
+
+You can use, modify and distribute this module under the terms of the MIT X11
+license. ( L<http://www.opensource.org/licenses/mit-license.php> ).
+
+=cut
+
 1;

File lib/XML/CompareML/DocBook.pm

View file
 use strict;
 use warnings;
 
+=head1 NAME
+
+XML::CompareML::DocBook - convert CompareML to DocBook
+
+=head1 SYNOPSIS
+
+See L<XML::CompareXML>.
+
+=cut
+
 use XML::LibXML::Common qw(:w3c);
 
 use base 'XML::CompareML::Base';
 
-sub print_header
+sub _print_header
 {
     my $self = shift;
     my $o = $self->{o};
 }
 
 # Do Nothing
-sub start_rendering
+sub _start_rendering
 {
 }
 
 # Do Nothing
-sub finish_rendering
+sub _finish_rendering
 {
 }
 
-sub print_footer
+sub _print_footer
 {
     my $self = shift;
     print {*{$self->{o}}} "</article>\n";
 }
 
-sub render_section_start
+sub _render_section_start
 {
     my $self = shift;
     my %args = (@_);
 
     if ($depth)
     {
-        $self->out("<section id=\"$id\">\n");
+        $self->_out("<section id=\"$id\">\n");
     }
 
-    $self->out("<title>$title_string</title>\n");
+    $self->_out("<title>$title_string</title>\n");
 
     if ($depth == 0)
     {
     }
 }
 
-sub render_sys_table_start
+sub _render_sys_table_start
 {
     my ($self,%args) = @_;
 
 EOF
 }
 
-sub html_to_docbook
+sub _html_to_docbook
 {
     my $parent_node = shift;
     my $not_first = shift;
     return $ret;
 }
 
-sub render_s_elem
+sub _render_s_elem
 {
     my ($self, $s_elem) = @_;
     return html_to_docbook($s_elem);
 }
 
-sub render_sys_table_row
+sub _render_sys_table_row
 {
     my ($self, %args) = @_;
 
                 "<entry>\n" . $args{desc} . "\n</entry>\n</row>\n");
 }
 
-sub render_sys_table_end
+sub _render_sys_table_end
 {
     my $self = shift;
     $self->out("</tbody>\n</tgroup>\n</table>\n");
 }
 
-sub render_section_end
+sub _render_section_end
 {
     my ($self, %args) = @_;
 
     }
 }
 
+=head1 AUTHOR
+
+Shlomi Fish, L<http://www.shlomifish.org/>.
+
+=head1 SEE ALSO
+
+L<XML::CompareML>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2004, Shlomi Fish. All rights reserved.
+
+You can use, modify and distribute this module under the terms of the MIT X11
+license. ( L<http://www.opensource.org/licenses/mit-license.php> ).
+
+=cut
+
 1;
 

File lib/XML/CompareML/HTML.pm

View file
 
 use base 'XML::CompareML::Base';
 
-sub print_header
+
+=head1 NAME
+
+XML::CompareML::HTML - convert CompareML to HTML
+
+=head1 SYNOPSIS
+
+See L<XML::CompareXML>.
+
+=head1 METHODS
+
+=cut
+
+sub _print_header
 {
     my $self = shift;
 
 EOF
 }
 
+=head2 get_head_css_style()
+
+Should return the CSS style of the <head> element. Overridable in 
+child classes.
+
+=cut
+
 sub get_head_css_style
 {
     my $self = shift;
     return $style;
 }
 
-sub start_rendering
+sub _start_rendering
 {
     my $self = shift;
     $self->{toc_text} .= "<ul class=\"toc\">\n";
 }
 
-sub finish_rendering
+sub _finish_rendering
 {
     my $self = shift;
     
     $self->{document_text} =~ s!<<<TOC>>>!$toc_text!;
 }
 
-sub print_footer
+sub _print_footer
 {
     my $self = shift;
     print {*{$self->{o}}} "\n</body>\n</html>\n";
 }
 
-sub render_section_start
+sub _render_section_start
 {
     my $self = shift;
     my %args = (@_);
     my $sub_sections = $args{sub_sections};
 
     my $d = $depth+1;
-    $self->out("<h$d id=\"$id\">$title_string</h$d>\n");
+    $self->_out("<h$d id=\"$id\">$title_string</h$d>\n");
 
     if ($expl)
     {
-        $self->out("<p class=\"expl\">\n" . $self->xml_node_contents_to_string($expl) . "\n</p>\n");
+        $self->_out("<p class=\"expl\">\n" . $self->_xml_node_contents_to_string($expl) . "\n</p>\n");
     }
 
     if ($depth == 0)
     {
-        if (defined($self->timestamp()))
+        if (defined($self->_timestamp()))
         {
-            $self->out("<p><b>Timestamp:</b> <tt>" . $self->timestamp() . "</tt></p>");
+            $self->_out("<p><b>Timestamp:</b> <tt>" . $self->_timestamp() . "</tt></p>");
         }
-        $self->out("<<<TOC>>>\n");
+        $self->_out("<<<TOC>>>\n");
     }
 
-    $self->toc_out("<li><a href=\"#$id\">$title_string</a>");
+    $self->_toc_out("<li><a href=\"#$id\">$title_string</a>");
 
     if (@$sub_sections)
     {
-        $self->toc_out("\n<ul>\n");
+        $self->_toc_out("\n<ul>\n");
     }
 }
 
-sub render_sys_table_start
+sub _render_sys_table_start
 {
     my $self = shift;
-    $self->out("<table class=\"compare\">\n");
+    $self->_out("<table class=\"compare\">\n");
 }
 
-sub render_s_elem
+sub _render_s_elem
 {
     my ($self, $s_elem) = @_;
-    return $self->xml_node_contents_to_string($s_elem);
+    return $self->_xml_node_contents_to_string($s_elem);
 }
 
-sub render_sys_table_row
+sub _render_sys_table_row
 {
     my ($self, %args) = @_;
     
-    $self->out(
+    $self->_out(
         "<tr>\n<td class=\"sys\">" . $args{name} . "</td>\n" .
         "<td class=\"desc\">\n" . $args{desc} . "\n</td>\n</tr>\n"
     );
 }
 
-sub render_sys_table_end
+sub _render_sys_table_end
 {
     my $self = shift;
-    $self->out("</table>\n");
+    $self->_out("</table>\n");
 }
 
-sub render_section_end
+sub _render_section_end
 {
     my ($self, %args) = @_;
 
     
     if (@$sub_sections)
     {
-        $self->toc_out("\n</ul>\n");
+        $self->_toc_out("\n</ul>\n");
     }
-    $self->toc_out("</li>\n");
+    $self->_toc_out("</li>\n");
 }
 
+=head2 $converter->gen_systems_list({output_handle => \*STDOUT})
+
+Generates a list of li's with links to the systems, not unlike:
+
+L<http://better-scm.berlios.de/comparison/>
+
+=cut
+
 sub gen_systems_list
 {
     my ($self, %args) = @_;
 
     my $fh = $args{output_handle};
 
-    my @implementations = $self->findnodes("/comparison/meta/implementations/impl");
+    my @implementations = $self->_findnodes("/comparison/meta/implementations/impl");
 
     foreach my $impl (@implementations)
     {
             ;
     }
 }
+
+=head1 AUTHOR
+
+Shlomi Fish, L<http://www.shlomifish.org/>.
+
+=head1 SEE ALSO
+
+L<XML::CompareML>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2004, Shlomi Fish. All rights reserved.
+
+You can use, modify and distribute this module under the terms of the MIT X11
+license. ( L<http://www.opensource.org/licenses/mit-license.php> ).
+
+=cut
+
 1;

File t/pod-coverage.t

View file
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();