texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo/tp DebugTexinfo/DebugTree.pm Texinfo/Co...


From: Patrice Dumas
Subject: texinfo/tp DebugTexinfo/DebugTree.pm Texinfo/Co...
Date: Sun, 15 Jan 2012 16:40:52 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        12/01/15 16:40:52

Modified files:
        tp/DebugTexinfo: DebugTree.pm 
        tp/Texinfo/Convert: Converter.pm 

Log message:
        Add a default output subroutine in Texinfo::Convert::Converter.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/DebugTexinfo/DebugTree.pm?cvsroot=texinfo&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Converter.pm?cvsroot=texinfo&r1=1.73&r2=1.74

Patches:
Index: DebugTexinfo/DebugTree.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/DebugTexinfo/DebugTree.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- DebugTexinfo/DebugTree.pm   28 Oct 2011 21:59:43 -0000      1.5
+++ DebugTexinfo/DebugTree.pm   15 Jan 2012 16:40:52 -0000      1.6
@@ -29,6 +29,17 @@
 
 @ISA = qw(Texinfo::Convert::Converter);
 
+my %defaults = (
+  'EXTENSION' => 'debugtree',
+);
+
+sub converter_defaults($)
+{
+  return %defaults;
+}
+
+# FIXME this cannot be used through texi2any.pl since it should write to
+# a file (unless OUTFILE is '' which should not happen when called by 
texi2any).
 sub output($$)
 {
   my $self = shift;
@@ -45,21 +56,33 @@
     if ($elements and ($self->get_conf('SPLIT') 
                        or !$self->get_conf('MONOLITHIC'))) {
       #print STDERR "S ".$self->get_conf('SPLIT')."\n";
-      $pages = Texinfo::Structuring::split_pages($elements,
+      Texinfo::Structuring::split_pages($elements,
                                                  $self->get_conf('SPLIT'));
     }
   }
-  if ($pages) {
-    #print STDERR "PPP $pages\n";
-    $root = {'type' => 'pages_root',
-             'contents' => $pages };
-  } elsif ($elements) {
+  if ($elements) {
     $root = {'type' => 'elements_root',
              'contents' => $elements };
   }
   return _print_tree($self, $root);
 }
 
+sub convert($$)
+{
+  my $self = shift;
+  my $root = shift;
+
+  return _print_tree($self, $root);
+}
+
+sub convert_tree($$)
+{
+  my $self = shift;
+  my $root = shift;
+
+  return _print_tree($self, $root);
+}
+
 sub _print_tree($$;$$);
 
 sub _print_tree($$;$$)

Index: Texinfo/Convert/Converter.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Converter.pm,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -b -r1.73 -r1.74
--- Texinfo/Convert/Converter.pm        15 Jan 2012 15:08:00 -0000      1.73
+++ Texinfo/Convert/Converter.pm        15 Jan 2012 16:40:52 -0000      1.74
@@ -497,7 +497,32 @@
   $self->{'output_file'} = $outfile;
 }
 
-#sub output
+sub output($$)
+{
+  my $self = shift;
+  my $root = shift;
+
+  $self->_set_outfile();
+  return undef unless $self->_create_destination_directory();
+  
+  my $fh;
+  if (! $self->{'output_file'} eq '') {
+    $fh = $self->Texinfo::Common::open_out ($self->{'output_file'});
+    if (!$fh) {
+      $self->document_error(sprintf($self->__("Could not open %s for writing: 
%s"),
+                                    $self->{'output_file'}, $!));
+      return undef;
+    }
+  }
+
+  $self->_set_global_multiple_commands(-1);
+
+  if ($self->get_conf('USE_NODES')) {
+    return $self->convert_document_nodes($root, $fh);
+  } else {
+    return $self->convert_document_sections($root, $fh);
+  }
+}
 
 # This is not used as code, but used to mark months as strings to be
 # translated
@@ -677,15 +702,15 @@
   } 
 }   
 
-sub convert_document_sections($$;$)
+sub _convert_document_elements($$;$$)
 {
   my $self = shift;
   my $root = shift;
+  my $elements = shift;
   my $fh = shift;
 
-  my $result = '';
-  my $elements = Texinfo::Structuring::split_by_section($root);
   if ($elements) {
+    my $result = '';
     foreach my $element (@$elements) {
       $result .= $self->_output_text ($self->convert_tree($element), $fh);
     }
@@ -695,6 +720,27 @@
   }
 }
 
+sub convert_document_sections($$;$)
+{
+  my $self = shift;
+  my $root = shift;
+  my $fh = shift;
+
+  my $elements = Texinfo::Structuring::split_by_section($root);
+  return $self->_convert_document_elements($root, $elements, $fh);
+}
+
+sub convert_document_nodes($$;$)
+{
+  my $self = shift;
+  my $root = shift;
+  my $fh = shift;
+
+  my $elements = Texinfo::Structuring::split_by_node($root);
+  return $self->_convert_document_elements($root, $elements, $fh);
+}
+
+
 my @inline_types = ('def_line', 'paragraph', 'preformatted',
   'misc_command_arg', 'misc_line_arg', 'block_line_arg',
   'menu_entry_name', 'menu_entry_node');



reply via email to

[Prev in Thread] Current Thread [Next in Thread]