texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/ManipulateTree.pm (normalized_menu_e


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ManipulateTree.pm (normalized_menu_entry_internal_node) (normalized_entry_associated_internal_node, first_menu_node), tp/Texinfo/Structuring.pm: move functions, some previously internal, from Structuring.pm to ManipulateTree.pm. Update callers.
Date: Sun, 14 Apr 2024 10:36:05 -0400

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new f015e839ba * tp/Texinfo/ManipulateTree.pm 
(normalized_menu_entry_internal_node) 
(normalized_entry_associated_internal_node, first_menu_node), 
tp/Texinfo/Structuring.pm: move functions, some previously internal, from 
Structuring.pm to ManipulateTree.pm.  Update callers.
f015e839ba is described below

commit f015e839babaecbb4872780704e5992614edca73
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Apr 14 16:35:55 2024 +0200

    * tp/Texinfo/ManipulateTree.pm (normalized_menu_entry_internal_node)
    (normalized_entry_associated_internal_node, first_menu_node),
    tp/Texinfo/Structuring.pm: move functions, some previously internal,
    from Structuring.pm to ManipulateTree.pm.  Update callers.
    
    * tp/Texinfo/OutputUnits.pm, doc/tp_api/Makefile.am
    (texi2any_internals_dependencies), tp/Makefile.am (dist_modules_DATA),
    tp/Texinfo/Structuring.pm: move output units related functions from
    Structuring.pm to the new module Texinfo::OutputUnits.  Update
    callers.
---
 ChangeLog                                       |  13 +
 doc/tp_api/Makefile.am                          |   1 +
 tp/Makefile.am                                  |   1 +
 tp/Texinfo/Convert/Converter.pm                 |  14 +-
 tp/Texinfo/Convert/DocBook.pm                   |   1 +
 tp/Texinfo/Convert/HTML.pm                      |  21 +-
 tp/Texinfo/Convert/IXIN.pm                      |   4 +-
 tp/Texinfo/Convert/Info.pm                      |  10 +-
 tp/Texinfo/Convert/Plaintext.pm                 |  15 +-
 tp/Texinfo/Convert/TexinfoMarkup.pm             |   1 +
 tp/Texinfo/ManipulateTree.pm                    |  75 +-
 tp/Texinfo/Structuring.pm                       | 874 +-----------------------
 tp/Texinfo/Transformations.pm                   |   5 +-
 tp/Texinfo/XS/structuring_transfo/structuring.h |   1 -
 tp/init/book.pm                                 |   1 +
 tp/t/test_utils.pl                              |  15 +-
 util/texi-elements-by-size                      |   1 -
 17 files changed, 152 insertions(+), 901 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e67873498d..fadea87b1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-04-14  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ManipulateTree.pm (normalized_menu_entry_internal_node)
+       (normalized_entry_associated_internal_node, first_menu_node),
+       tp/Texinfo/Structuring.pm: move functions, some previously internal,
+       from Structuring.pm to ManipulateTree.pm.  Update callers.
+
+       * tp/Texinfo/OutputUnits.pm, doc/tp_api/Makefile.am
+       (texi2any_internals_dependencies), tp/Makefile.am (dist_modules_DATA),
+       tp/Texinfo/Structuring.pm: move output units related functions from
+       Structuring.pm to the new module Texinfo::OutputUnits.  Update
+       callers.
+
 2024-04-14  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Structuring.pm (new_detailmenu),
diff --git a/doc/tp_api/Makefile.am b/doc/tp_api/Makefile.am
index b8c9c27bc7..e4acd5ce46 100644
--- a/doc/tp_api/Makefile.am
+++ b/doc/tp_api/Makefile.am
@@ -59,6 +59,7 @@ texi2any_internals_dependencies = \
   $(top_srcdir)/tp/Texinfo/Translations.pm \
   $(top_srcdir)/tp/Texinfo/Transformations.pm \
   $(top_srcdir)/tp/Texinfo/Indices.pm \
+  $(top_srcdir)/tp/Texinfo/OutputUnits.pm \
   $(top_srcdir)/tp/Texinfo/Convert/Texinfo.pm \
   $(top_srcdir)/tp/Texinfo/Convert/Utils.pm \
   $(top_srcdir)/tp/Texinfo/Convert/Unicode.pm \
diff --git a/tp/Makefile.am b/tp/Makefile.am
index 4ffc1b3d64..ed82f59cb3 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -77,6 +77,7 @@ dist_modules_DATA = \
  Texinfo/ManipulateTree.pm \
  Texinfo/MiscXS.pm \
  Texinfo/Options.pm \
+ Texinfo/OutputUnits.pm \
  Texinfo/Parser.pm \
  Texinfo/ParserNonXS.pm \
  Texinfo/Report.pm \
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index d7acdaf07f..2caf9ceb43 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -49,7 +49,7 @@ use Texinfo::Convert::Unicode;
 use Texinfo::Convert::Texinfo;
 use Texinfo::Convert::Text;
 use Texinfo::Convert::NodeNameNormalization;
-use Texinfo::Structuring;
+use Texinfo::OutputUnits;
 
 use Texinfo::Translations;
 
@@ -1130,7 +1130,7 @@ sub set_output_units_files($$$$$$)
     print STDERR 'Page '
      # uncomment for perl object name
      #."$output_unit "
-     .Texinfo::Structuring::output_unit_texi($output_unit)
+     .Texinfo::OutputUnits::output_unit_texi($output_unit)
      .": 
$output_unit_filename($self->{'file_counters'}->{$output_unit_filename})\n"
               if ($self->get_conf('DEBUG'));
   }
@@ -1624,9 +1624,9 @@ sub sort_element_counts($$;$$)
 
   my $output_units;
   if ($use_sections) {
-    $output_units = Texinfo::Structuring::split_by_section($document);
+    $output_units = Texinfo::OutputUnits::split_by_section($document);
   } else {
-    $output_units = Texinfo::Structuring::split_by_node($document);
+    $output_units = Texinfo::OutputUnits::split_by_node($document);
   }
 
   my $max_count = 0;
@@ -2092,9 +2092,9 @@ Can be used for the conversion of output units by 
converters.
 C<convert_output_unit> takes a I<$converter> and an output unit
 I<$output_unit> as argument.  The implementation of
 C<convert_output_unit> of C<Texinfo::Convert::Converter> could be suitable in
-many cases.  Output units are typically returned by L<Texinfo::Structuring
-split_by_section|Texinfo::Structuring/$output_units = 
split_by_section($document)>
-or L<Texinfo::Structuring split_by_node|Texinfo::Structuring/$output_units =
+many cases.  Output units are typically returned by L<Texinfo::OutputUnits
+split_by_section|Texinfo::OutputUnits/$output_units = 
split_by_section($document)>
+or L<Texinfo::OutputUnits split_by_node|Texinfo::OutputUnits/$output_units =
 split_by_node($document)>.
 
 Output units are not relevant for all the formats, the Texinfo tree can also be
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 46ff9d3072..40ae41301a 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -31,6 +31,7 @@ use Texinfo::Common;
 # for debugging
 use Texinfo::Convert::Texinfo;
 
+# for section_level_adjusted_command_name
 use Texinfo::Structuring;
 
 use Texinfo::Convert::Unicode;
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 991e5b46f2..2e7028db03 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -73,6 +73,7 @@ use Texinfo::Convert::Text;
 use Texinfo::Convert::NodeNameNormalization;
 use Texinfo::ManipulateTree;
 use Texinfo::Structuring;
+use Texinfo::OutputUnits;
 # for index_entry_first_letter_text_or_command
 use Texinfo::Indices;
 use Texinfo::Convert::Converter;
@@ -1635,7 +1636,7 @@ sub from_element_direction($$$;$$$)
       die "No unit type for element_target $direction $target_unit: "
        . Texinfo::Common::debug_print_output_unit($target_unit)
        . "directions :"
-           . Texinfo::Structuring::print_output_unit_directions($source_unit);
+           . Texinfo::OutputUnits::print_output_unit_directions($source_unit);
     }
     ########
     if ($target_unit->{'unit_type'} eq 'external_node_unit') {
@@ -4635,7 +4636,7 @@ sub _default_format_element_header($$$$)
      #."$output_unit (@{$output_unit->{'unit_contents'}}) ".
      . "(".join('|', map{Texinfo::Common::debug_print_element($_)}
              @{$output_unit->{'unit_contents'}}) . ") ".
-     Texinfo::Structuring::output_unit_texi($output_unit) ."\n"
+     Texinfo::OutputUnits::output_unit_texi($output_unit) ."\n"
         if ($self->get_conf('DEBUG'));
 
   # Do the heading if the command is the first command in the element
@@ -9910,7 +9911,7 @@ sub _html_set_pages_files($$$$$$$$$)
     print STDERR 'Page '
       # uncomment for perl object name
       #."$output_unit "
-      .Texinfo::Structuring::output_unit_texi($output_unit)
+      .Texinfo::OutputUnits::output_unit_texi($output_unit)
       .": 
$output_unit_filename($self->{'file_counters'}->{$output_unit_filename})\n"
              if ($self->get_conf('DEBUG'));
   }
@@ -9997,9 +9998,9 @@ sub _prepare_conversion_units($$$)
   my ($output_units, $special_units, $associated_special_units);
 
   if ($self->get_conf('USE_NODES')) {
-    $output_units = Texinfo::Structuring::split_by_node($document);
+    $output_units = Texinfo::OutputUnits::split_by_node($document);
   } else {
-    $output_units = Texinfo::Structuring::split_by_section($document);
+    $output_units = Texinfo::OutputUnits::split_by_section($document);
   }
 
   # Needs to be set early in case it would be needed to find some region
@@ -10059,7 +10060,7 @@ sub _prepare_units_directions_files($$$$$$$$)
   $self->_prepare_output_units_global_targets($output_units, $special_units,
                                               $associated_special_units);
 
-  Texinfo::Structuring::split_pages($output_units, $self->get_conf('SPLIT'));
+  Texinfo::OutputUnits::split_pages($output_units, $self->get_conf('SPLIT'));
 
   # determine file names associated with the different pages, and setup
   # the counters for special element pages.
@@ -10072,14 +10073,14 @@ sub _prepare_units_directions_files($$$$$$$$)
   }
 
   # do output units directions.
-  Texinfo::Structuring::units_directions($self, $identifiers_target,
+  Texinfo::OutputUnits::units_directions($self, $identifiers_target,
                                          $output_units);
 
   _prepare_special_units_directions($self, $special_units);
 
   # do output units directions related to files.
   # Here such that PrevFile and NextFile can be set.
-  Texinfo::Structuring::units_file_directions($output_units);
+  Texinfo::OutputUnits::units_file_directions($output_units);
 
   # elements_in_file_count is only set in HTML, not in
   # Texinfo::Convert::Converter
@@ -10418,7 +10419,7 @@ sub _prepare_output_units_global_targets($$$$)
         print STDERR " $global_direction"
             # uncomment to get the perl object name
             # ."($global_unit)"
-     .': '. Texinfo::Structuring::output_unit_texi($global_unit)."\n";
+     .': '. Texinfo::OutputUnits::output_unit_texi($global_unit)."\n";
       }
     }
     print STDERR "\n";
@@ -12153,7 +12154,7 @@ sub convert_output_unit($$;$)
 
   if ($debug) {
     print STDERR "UNIT($explanation) -> ou: $unit_type_name '"
-        .Texinfo::Structuring::output_unit_texi($output_unit)."'\n";
+        .Texinfo::OutputUnits::output_unit_texi($output_unit)."'\n";
   }
 
   $self->{'current_output_unit'} = $output_unit;
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index af0e2cdfa9..dbe2a3f4f8 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -76,7 +76,9 @@ use Texinfo::Commands;
 use Texinfo::Options;
 use Texinfo::Common;
 
+# for section_level_adjusted_command_name
 use Texinfo::Structuring;
+use Texinfo::OutputUnits;
 
 use Texinfo::Convert::TexinfoSXML;
 
@@ -420,7 +422,7 @@ sub output_ixin($$)
 
   # FIXME vars: wait for Thien-Thi answer.
 
-  my $output_units = Texinfo::Structuring::split_by_node($document);
+  my $output_units = Texinfo::OutputUnits::split_by_node($document);
   # setting_commands is for @-commands appearing before the first node,
   # while end_of_nodes_setting_commands holds, for @-commands names, the
   # last @-command element.
diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm
index c8582b94a9..43a24100f5 100644
--- a/tp/Texinfo/Convert/Info.pm
+++ b/tp/Texinfo/Convert/Info.pm
@@ -22,16 +22,18 @@
 package Texinfo::Convert::Info;
 
 use 5.00405;
-use strict;
 
-use Carp qw(cluck);
+use strict;
 
 # To check if there is no erroneous autovivification
 #no autovivification qw(fetch delete exists store strict);
 
+use Carp qw(cluck);
+
 use Texinfo::Common;
-use Texinfo::Convert::Plaintext;
+use Texinfo::OutputUnits;
 use Texinfo::Convert::Text;
+use Texinfo::Convert::Plaintext;
 
 use Texinfo::Convert::Paragraph;
 
@@ -115,7 +117,7 @@ sub output($$)
 
   my $header_bytes = length($header);
   my $complete_header_bytes = $header_bytes;
-  my $output_units = Texinfo::Structuring::split_by_node($document);
+  my $output_units = Texinfo::OutputUnits::split_by_node($document);
 
   print STDERR "DOCUMENT\n" if ($self->get_conf('DEBUG'));
 
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 24f0d483f6..11b96447bb 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -38,8 +38,9 @@ use Encode;
 
 use Texinfo::Commands;
 use Texinfo::Common;
-use Texinfo::Structuring;
 use Texinfo::Convert::Texinfo;
+use Texinfo::Structuring;
+use Texinfo::OutputUnits;
 use Texinfo::Convert::Utils;
 use Texinfo::Convert::Text;
 use Texinfo::Convert::Utils;
@@ -585,7 +586,7 @@ sub count_context_bug_message($$$)
     my $output_unit_text;
     if ($output_unit) {
       $output_unit_text
-         = Texinfo::Structuring::output_unit_texi($output_unit);
+         = Texinfo::OutputUnits::output_unit_texi($output_unit);
     } else {
       $output_unit_text = '';
     }
@@ -653,7 +654,7 @@ sub convert($$)
 
   my $result = '';
 
-  my $output_units = Texinfo::Structuring::split_by_node($document);
+  my $output_units = Texinfo::OutputUnits::split_by_node($document);
 
   foreach my $output_unit (@$output_units) {
     my $node_text = convert_output_unit($self, $output_unit);
@@ -704,14 +705,14 @@ sub output($$)
   }
 
   if ($self->get_conf('USE_NODES')) {
-    $output_units = Texinfo::Structuring::split_by_node($document);
+    $output_units = Texinfo::OutputUnits::split_by_node($document);
   } else {
-    $output_units = Texinfo::Structuring::split_by_section($document);
+    $output_units = Texinfo::OutputUnits::split_by_section($document);
   }
 
-  Texinfo::Structuring::split_pages($output_units, $self->get_conf('SPLIT'));
+  Texinfo::OutputUnits::split_pages($output_units, $self->get_conf('SPLIT'));
 
-  Texinfo::Structuring::rebuild_output_units($output_units);
+  Texinfo::OutputUnits::rebuild_output_units($output_units);
 
   # determine file names associated with the different pages
   if ($output_file ne '') {
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm 
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index 4d4c0c83d7..27943d6abb 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -37,6 +37,7 @@ use strict;
 
 use Texinfo::Commands;
 use Texinfo::Common;
+# for section_level_adjusted_command_name
 use Texinfo::Structuring;
 use Texinfo::Convert::Converter;
 use Texinfo::Convert::Unicode;
diff --git a/tp/Texinfo/ManipulateTree.pm b/tp/Texinfo/ManipulateTree.pm
index 12f5c406e7..1b7c953ab2 100644
--- a/tp/Texinfo/ManipulateTree.pm
+++ b/tp/Texinfo/ManipulateTree.pm
@@ -805,6 +805,79 @@ sub relate_index_entries_to_table_items_in_tree($)
               $indices_information);
 }
 
+
+# Methods used to get information on menu entries and nodes.  Used in
+# structuring and transformation codes, here because this module is
+# used by all the structuring and transformation modules.
+# Not documented in POD because they are considered to be internal functions.
+
+# return $NORMALIZED_ENTRY_NODE, the identifier corresponding to
+# the internal node referred to by menu entry $ENTRY
+sub normalized_menu_entry_internal_node($)
+{
+  my $entry = shift;
+
+  foreach my $content (@{$entry->{'contents'}}) {
+    if ($content->{'type'} eq 'menu_entry_node') {
+      if ($content->{'extra'}) {
+        if (! $content->{'extra'}->{'manual_content'}) {
+          return $content->{'extra'}->{'normalized'};
+        }
+      }
+      return undef;
+    }
+  }
+  return undef;
+}
+
+# Return $NODE where $NODE is the node referred to by menu entry $ENTRY.
+sub normalized_entry_associated_internal_node($$)
+{
+  my $entry = shift;
+  my $identifier_target = shift;
+
+  my $normalized_entry_node = normalized_menu_entry_internal_node($entry);
+
+  if (defined($normalized_entry_node)) {
+    return $identifier_target->{$normalized_entry_node};
+  }
+  return undef;
+}
+
+# In $NODE, find the first menu entry node in the first menu.  If the
+# node in menu refers to a target element in the document, return that
+# element
+sub first_menu_node($$)
+{
+  my $node = shift;
+  my $identifier_target = shift;
+  if ($node->{'extra'}->{'menus'}) {
+    foreach my $menu (@{$node->{'extra'}->{'menus'}}) {
+      foreach my $menu_content (@{$menu->{'contents'}}) {
+        if ($menu_content->{'type'}
+            and $menu_content->{'type'} eq 'menu_entry') {
+          my $menu_node
+            = normalized_entry_associated_internal_node($menu_content,
+                                                        $identifier_target);
+          # an internal node
+          return $menu_node if ($menu_node);
+          foreach my $content (@{$menu_content->{'contents'}}) {
+            if ($content->{'type'} eq 'menu_entry_node') {
+              # a reference to an external manual
+              if ($content->{'extra'}
+                  and $content->{'extra'}->{'manual_content'}) {
+                return $content
+              }
+              last;
+            }
+          }
+        }
+      }
+    }
+  }
+  return undef;
+}
+
 
 1;
 
@@ -825,7 +898,7 @@ Texinfo to other formats.  There is no promise of API 
stability.
 
 =head1 DESCRIPTION
 
-Texinfo::ManipulateTree contains methods for copying and modifying the
+C<Texinfo::ManipulateTree> contains methods for copying and modifying the
 Texinfo tree used for default conversion to output formats.
 
 For optional tree transformation, see L<Texinfo::Transformations>.
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 717bde200b..2e6fa900c3 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -61,15 +61,10 @@ use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
   associate_internal_references
   check_nodes_are_referenced
   complete_node_tree_with_menus
-  units_directions
-  units_file_directions
   nodes_tree
   number_floats
   sectioning_structure
   set_menus_node_directions
-  split_by_node
-  split_by_section
-  split_pages
   warn_non_empty_parts
 ) ] );
 
@@ -96,23 +91,6 @@ my %XS_overrides = (
     => "Texinfo::StructTransfXS::check_nodes_are_referenced",
   "Texinfo::Structuring::number_floats"
     => "Texinfo::StructTransfXS::number_floats",
-  "Texinfo::Structuring::rebuild_output_units"
-    => "Texinfo::StructTransfXS::rebuild_output_units",
-  "Texinfo::Structuring::_XS_unsplit"
-    => "Texinfo::StructTransfXS::unsplit",
-);
-
-# used in conversion only, and should only be loaded with XS converters
-my %XS_convert_overrides = (
-  # Not useful for HTML as functions, as the calling functions are
-  # already overriden
-  # Could be readded when other converters than HTML are done in C
-  #  "Texinfo::Structuring::split_by_node"
-  #    => "Texinfo::StructTransfXS::split_by_node");
-  #  "Texinfo::Structuring::split_by_section"
-  #    => "Texinfo::StructTransfXS::split_by_section");
-  #  "Texinfo::Structuring::split_pages"
-  #    => "Texinfo::StructTransfXS::split_pages"
 );
 
 our $module_loaded = 0;
@@ -123,24 +101,12 @@ sub import {
         Texinfo::XSLoader::override ($sub, $XS_overrides{$sub});
       }
     }
-    #if ($XS_convert) {
-    #  for my $sub (keys %XS_convert_overrides) {
-    #    Texinfo::XSLoader::override ($sub, $XS_convert_overrides{$sub});
-    #  }
-    #}
     $module_loaded = 1;
   }
   # The usual import method
   goto &Exporter::import;
 }
 
-my %types_to_enter;
-foreach my $type_to_enter ('brace_command_arg', 'line_arg',
-    'paragraph') {
-  $types_to_enter{$type_to_enter} = 1;
-}
-
-
 my %command_structuring_level = %Texinfo::Common::command_structuring_level;
 
 my %appendix_commands = %Texinfo::Commands::appendix_commands;
@@ -452,39 +418,6 @@ sub _check_menu_entry($$$$$$)
   }
 }
 
-# return $NORMALIZED_ENTRY_NODE, the identifier corresponding to
-# the internal node referred to by menu entry $ENTRY
-sub normalized_menu_entry_internal_node($)
-{
-  my $entry = shift;
-
-  foreach my $content (@{$entry->{'contents'}}) {
-    if ($content->{'type'} eq 'menu_entry_node') {
-      if ($content->{'extra'}) {
-        if (! $content->{'extra'}->{'manual_content'}) {
-          return $content->{'extra'}->{'normalized'};
-        }
-      }
-      return undef;
-    }
-  }
-  return undef;
-}
-
-# Return $NODE where $NODE is the node referred to by menu entry $ENTRY.
-sub _normalized_entry_associated_internal_node($$)
-{
-  my $entry = shift;
-  my $identifier_target = shift;
-
-  my $normalized_entry_node = normalized_menu_entry_internal_node($entry);
-
-  if (defined($normalized_entry_node)) {
-    return $identifier_target->{$normalized_entry_node};
-  }
-  return undef;
-}
-
 sub _register_menu_node_targets($$$)
 {
   my $identifier_target = shift;
@@ -497,8 +430,8 @@ sub _register_menu_node_targets($$$)
         if ($menu_content->{'type'}
             and $menu_content->{'type'} eq 'menu_entry') {
           my $menu_node
-            = _normalized_entry_associated_internal_node($menu_content,
-                                                         $identifier_target);
+       = Texinfo::ManipulateTree::normalized_entry_associated_internal_node(
+                                            $menu_content, $identifier_target);
           $register->{$menu_node} = 1 if ($menu_node);
         }
       }
@@ -631,40 +564,6 @@ sub check_nodes_are_referenced($)
   }
 }
 
-# In $NODE, find the first menu entry node in the first menu.  If the
-# node in menu refers to a target element in the document, return that
-# element
-sub _first_menu_node($$)
-{
-  my $node = shift;
-  my $identifier_target = shift;
-  if ($node->{'extra'}->{'menus'}) {
-    foreach my $menu (@{$node->{'extra'}->{'menus'}}) {
-      foreach my $menu_content (@{$menu->{'contents'}}) {
-        if ($menu_content->{'type'}
-            and $menu_content->{'type'} eq 'menu_entry') {
-          my $menu_node
-            = _normalized_entry_associated_internal_node($menu_content,
-                                                        $identifier_target);
-          # an internal node
-          return $menu_node if ($menu_node);
-          foreach my $content (@{$menu_content->{'contents'}}) {
-            if ($content->{'type'} eq 'menu_entry_node') {
-              # a reference to an external manual
-              if ($content->{'extra'}
-                  and $content->{'extra'}->{'manual_content'}) {
-                return $content
-              }
-              last;
-            }
-          }
-        }
-      }
-    }
-  }
-  return undef;
-}
-
 # set menu_directions
 sub set_menus_node_directions($)
 {
@@ -912,7 +811,8 @@ sub complete_node_tree_with_menus($)
       } elsif (not $node_directions
                or not $node_directions->{'next'}) {
         # use first menu entry if available as next for Top
-        my $menu_child = _first_menu_node($node, $identifier_target);
+        my $menu_child = Texinfo::ManipulateTree::first_menu_node($node,
+                                                      $identifier_target);
         if ($menu_child) {
           $node->{'extra'}->{'node_directions'} = {}
              if (!$node->{'extra'}->{'node_directions'});
@@ -1539,8 +1439,8 @@ sub new_detailmenu($$$$;$)
       foreach my $entry (@{$menu->{'contents'}}) {
         if ($entry->{'type'} and $entry->{'type'} eq 'menu_entry') {
           my $node
-               = _normalized_entry_associated_internal_node($entry,
-                                                        $identifier_target);
+        = Texinfo::ManipulateTree::normalized_entry_associated_internal_node(
+                                                  $entry, $identifier_target);
           if ($node) {
             push @{$new_detailmenu->{'contents'}}, _print_down_menus($node, 
undef,
                                            $customization_information,
@@ -1647,8 +1547,8 @@ sub _print_down_menus($$$$$;$)
                Texinfo::ManipulateTree::copy_treeNonXS($entry);
         # gather node children to recursively print their menus
         my $node
-             = _normalized_entry_associated_internal_node($entry,
-                                                          $identifier_target);
+          = Texinfo::ManipulateTree::normalized_entry_associated_internal_node(
+                                                 $entry, $identifier_target);
         if ($node) {
           push @node_children, $node;
         }
@@ -1704,587 +1604,6 @@ sub _print_down_menus($$$$$;$)
   return @master_menu_contents;
 }
 
-
-# Output units code
-
-# Return a list of output units.  Each output unit starts with a @node as its
-# first content (except possibly the first one).  It is important that this
-# function reassociates all the root commands such that the result does not
-# depend on the previous association (if any).
-sub split_by_node($)
-{
-  my $document = shift;
-  my $root = $document->tree();
-
-  my $output_units;
-
-  my $current = { 'unit_type' => 'unit' };
-  push @$output_units, $current;
-  my @pending_parts = ();
-  foreach my $content (@{$root->{'contents'}}) {
-    if ($content->{'cmdname'} and $content->{'cmdname'} eq 'part') {
-      push @pending_parts, $content;
-      next;
-    }
-    if ($content->{'cmdname'} and $content->{'cmdname'} eq 'node') {
-      if (not $current->{'unit_command'}) {
-        $current->{'unit_command'} = $content;
-      } else {
-        $current = { 'unit_type' => 'unit', 'unit_command' => $content,
-                    'tree_unit_directions' => {'prev' => $output_units->[-1]}};
-        $output_units->[-1]->{'tree_unit_directions'} = {}
-            if (! $output_units->[-1]->{'tree_unit_directions'});
-        $output_units->[-1]->{'tree_unit_directions'}->{'next'} = $current;
-        push @$output_units, $current;
-      }
-    }
-    if (@pending_parts) {
-      foreach my $part (@pending_parts) {
-        push @{$current->{'unit_contents'}}, $part;
-        $part->{'associated_unit'} = $current;
-      }
-      @pending_parts = ();
-    }
-    push @{$current->{'unit_contents'}}, $content;
-    #if (defined($content->{'associated_unit'})) {
-    #  print STDERR "Resetting node associated_unit for $content\n";
-    #}
-    $content->{'associated_unit'} = $current;
-  }
-  if (@pending_parts) {
-    foreach my $part (@pending_parts) {
-      push @{$current->{'unit_contents'}}, $part;
-      $part->{'associated_unit'} = $current;
-    }
-    @pending_parts = ();
-  }
-
-  return $output_units;
-}
-
-# Return a list of output units.  Each output unit starts with the @node
-# associated with a sectioning command or with the sectioning command if there
-# is no associated node.  It is important that this function reassociates all
-# the root commands such that the result does not depend on the previous
-# association (if any).
-sub split_by_section($)
-{
-  my $document = shift;
-  my $root = $document->tree();
-
-  my $output_units;
-
-  my $current = { 'unit_type' => 'unit' };
-  push @$output_units, $current;
-  foreach my $content (@{$root->{'contents'}}) {
-    my $new_section;
-    if ($content->{'cmdname'} and $content->{'cmdname'} eq 'node'
-        and $content->{'extra'}
-        and $content->{'extra'}->{'associated_section'}) {
-      $new_section = $content->{'extra'}->{'associated_section'};
-    } elsif ($content->{'cmdname'} and $content->{'cmdname'} eq 'part'
-             and $content->{'extra'}
-             and $content->{'extra'}->{'part_associated_section'}) {
-      $new_section = $content->{'extra'}->{'part_associated_section'};
-    } elsif ($content->{'cmdname'} and $content->{'cmdname'} ne 'node'
-             and $Texinfo::Commands::root_commands{$content->{'cmdname'}}) {
-      $new_section = $content;
-    }
-    if ($new_section) {
-      if (not defined($current->{'unit_command'})) {
-        $current->{'unit_command'} = $new_section;
-      } elsif ($new_section ne $current->{'unit_command'}) {
-        $current = { 'unit_type' => 'unit',
-                     'unit_command' => $new_section,
-                     'tree_unit_directions' => {'prev' => 
$output_units->[-1]}};
-        $output_units->[-1]->{'tree_unit_directions'} = {}
-            if (! $output_units->[-1]->{'tree_unit_directions'});
-        $output_units->[-1]->{'tree_unit_directions'}->{'next'} = $current;
-        push @$output_units, $current;
-      }
-    }
-    push @{$current->{'unit_contents'}}, $content;
-    #if ($content->{'associated_unit'}) {
-    #  print STDERR "Resetting section associated_unit for $content\n";
-    #}
-    $content->{'associated_unit'} = $current;
-  }
-  return $output_units;
-}
-
-sub _XS_unsplit($)
-{
-  my $document = shift;
-  return -3;
-}
-
-# remove the association with document units
-# NOTE not documented, but is internally used for tests only.
-# In the situation where unsplit is called, in the test suite, it is
-# always better to do it both for XS and perl.
-sub unsplit($)
-{
-  my $document = shift;
-
-  my $unsplit_needed = 0;
-  my $XS_unsplit_needed = _XS_unsplit($document);
-  if ($XS_unsplit_needed > 0) {
-    $unsplit_needed = 1;
-  }
-
-  my $root = $document->tree();
-  if (!$root->{'type'} or $root->{'type'} ne 'document_root'
-      or !$root->{'contents'}) {
-    return 0;
-  }
-  foreach my $content (@{$root->{'contents'}}) {
-    if ($content->{'associated_unit'}) {
-      delete $content->{'associated_unit'};
-      $unsplit_needed = 1;
-    }
-  }
-  return $unsplit_needed;
-}
-
-# does nothing in perl, the XS version reexports the output units
-sub rebuild_output_units($)
-{
-  my $output_units = shift;
-}
-
-# Associate top-level units with pages according to the splitting
-# specification.  Set 'first_in_page' on each unit to the unit
-# that is the first in the output page.
-sub split_pages($$)
-{
-  my $output_units = shift;
-  my $split = shift;
-
-  return undef if (!$output_units or !scalar(@$output_units));
-
-  my $split_level;
-  if (!$split) {
-    foreach my $output_unit (@$output_units) {
-      $output_unit->{'first_in_page'} = $output_units->[0];
-    }
-    return;
-  } elsif ($split eq 'chapter') {
-    $split_level = 1;
-  } elsif ($split eq 'section') {
-    $split_level = 2;
-  } elsif ($split ne 'node') {
-    warn "Unknown split specification: $split\n";
-  }
-
-  my $current_first_in_page;
-  foreach my $output_unit (@$output_units) {
-    my $level;
-    my $section = _output_unit_section($output_unit);
-    if (defined($section)) {
-      $level = $section->{'extra'}->{'section_level'};
-    }
-    #print STDERR "level($split_level) $level "
-    #       .output_unit_texi($output_unit)."\n";
-    if (!defined($split_level) or (defined($level) and $split_level >= $level)
-        or !$current_first_in_page) {
-      $current_first_in_page = $output_unit;
-    }
-    $output_unit->{'first_in_page'} = $current_first_in_page;
-  }
-}
-
-# Returns something associated to a label that can be used to setup a target
-# to the label.  If the target is an external node, create the output unit 
here,
-# if it is a node return the output unit that is supposed to be the
-# target for links to the node.  Otherwise there is no such element (yet),
-# for floats and anchor, return undef.
-sub _label_target_unit_element($)
-{
-  my $label = shift;
-  if ($label->{'extra'} and $label->{'extra'}->{'manual_content'}) {
-    # setup an output_unit for consistency with regular output units
-    my $external_node_unit = { 'unit_type' => 'external_node_unit',
-                               'unit_command' => $label };
-    return $external_node_unit;
-  } elsif ($label->{'cmdname'} and $label->{'cmdname'} eq 'node') {
-    return $label->{'associated_unit'};
-  } else {
-    # case of a @float or an @anchor, no target element defined at this stage
-    return undef;
-  }
-}
-
-sub _output_unit_section($)
-{
-  my $output_unit = shift;
-  if (not defined($output_unit->{'unit_command'})) {
-    return undef;
-  }
-  my $element = $output_unit->{'unit_command'};
-  if ($element->{'cmdname'} eq 'node') {
-    if ($element->{'extra'}
-        and $element->{'extra'}->{'associated_section'}) {
-      return $element->{'extra'}->{'associated_section'};
-    } else {
-      return undef;
-    }
-  } else {
-    return $element;
-  }
-}
-
-sub _output_unit_node($)
-{
-  my $output_unit = shift;
-  if (not defined($output_unit->{'unit_command'})) {
-    return undef;
-  }
-  my $element = $output_unit->{'unit_command'};
-  if ($element->{'cmdname'} eq 'node') {
-    return $element;
-  } else {
-    if ($element->{'extra'}
-        and $element->{'extra'}->{'associated_node'}) {
-      return $element->{'extra'}->{'associated_node'}
-    } else {
-      return undef;
-    }
-  }
-}
-
-# Do output units directions (like in texi2html) and store them
-# in 'directions'.
-# The directions are only created if pointing to other output units.
-sub units_directions($$$)
-{
-  my $customization_information = shift;
-  my $identifier_target = shift;
-  my $output_units = shift;
-  return if (!$output_units or !@$output_units);
-
-  my $node_top = $identifier_target->{'Top'};
-  foreach my $output_unit (@$output_units) {
-    my $directions = {};
-    $directions->{'This'} = $output_unit;
-    $directions->{'Forward'} = $output_unit->{'tree_unit_directions'}->{'next'}
-      if ($output_unit->{'tree_unit_directions'}
-          and $output_unit->{'tree_unit_directions'}->{'next'}
-          and defined($output_unit->{'tree_unit_directions'}->{'next'}
-                                                               ->{'unit_type'})
-          and $output_unit->{'tree_unit_directions'}->{'next'}
-                                                  ->{'unit_type'} eq 'unit');
-    $directions->{'Back'} = $output_unit->{'tree_unit_directions'}->{'prev'}
-      if ($output_unit->{'tree_unit_directions'}
-          and $output_unit->{'tree_unit_directions'}->{'prev'}
-          and defined($output_unit->{'tree_unit_directions'}->{'prev'}
-                                                               ->{'unit_type'})
-          and $output_unit->{'tree_unit_directions'}->{'prev'}
-                                                     ->{'unit_type'} eq 
'unit');
-    my $node = _output_unit_node($output_unit);
-    if (defined($node)) {
-      foreach my $direction(['NodeUp', 'up'], ['NodeNext', 'next'],
-                            ['NodePrev', 'prev']) {
-        $directions->{$direction->[0]}
-           = _label_target_unit_element(
-               $node->{'extra'}->{'node_directions'}->{$direction->[1]})
-            if ($node->{'extra'}->{'node_directions'}
-                and $node->{'extra'}->{'node_directions'}->{$direction->[1]});
-      }
-      # Now do NodeForward which is something like the following node.
-      my $associated_section;
-      my $automatic_directions
-        = (not ($node->{'args'} and scalar(@{$node->{'args'}}) > 1));
-      if ($automatic_directions and $node->{'extra'}
-          and $node->{'extra'}->{'associated_section'}) {
-        $associated_section = $node->{'extra'}->{'associated_section'};
-      }
-      my $menu_child = _first_menu_node($node, $identifier_target);
-      if ($menu_child) {
-        $directions->{'NodeForward'}
-          = _label_target_unit_element($menu_child);
-      } elsif ($associated_section
-               and $associated_section->{'extra'}->{'section_childs'}
-               and $associated_section->{'extra'}->{'section_childs'}->[0]) {
-        $directions->{'NodeForward'}
-          = $associated_section->{'extra'}
-                  ->{'section_childs'}->[0]->{'associated_unit'};
-      } elsif ($node->{'extra'}->{'node_directions'}
-               and $node->{'extra'}->{'node_directions'}->{'next'}) {
-        $directions->{'NodeForward'}
-            = _label_target_unit_element(
-                  $node->{'extra'}->{'node_directions'}->{'next'});
-      } elsif ($node->{'extra'}->{'node_directions'}
-               and $node->{'extra'}->{'node_directions'}->{'up'}) {
-        my $up = $node->{'extra'}->{'node_directions'}->{'up'};
-        my @up_list = ($node);
-        # the condition with the up_list avoids infinite loops
-        # the last condition stops when the Top node is reached.
-        while (not (grep {$up eq $_} @up_list
-                    or ($node_top and $up eq $node_top))) {
-          if ($up->{'extra'}->{'node_directions'}
-              and defined($up->{'extra'}->{'node_directions'}->{'next'})) {
-            $directions->{'NodeForward'}
-              = _label_target_unit_element(
-                           $up->{'extra'}->{'node_directions'}->{'next'});
-            last;
-          }
-          push @up_list, $up;
-          last if (not $up->{'extra'}->{'node_directions'}
-                   or not $up->{'extra'}->{'node_directions'}->{'up'});
-          $up = $up->{'extra'}->{'node_directions'}->{'up'};
-        }
-      }
-
-      if ($directions->{'NodeForward'}
-          and $directions->{'NodeForward'}->{'unit_type'} eq 'unit'
-          and (!$directions->{'NodeForward'}->{'directions'}
-               or !$directions->{'NodeForward'}->{'directions'}
-                                                  ->{'NodeBack'})) {
-        $directions->{'NodeForward'}->{'directions'} = {}
-            if (! $directions->{'NodeForward'}->{'directions'});
-        $directions->{'NodeForward'}->{'directions'}
-                                       ->{'NodeBack'} = $output_unit;
-      }
-    }
-    my $section = _output_unit_section($output_unit);
-    if (not defined($section)) {
-      # If there is no associated section, find the previous element section.
-      # Use the FastForward of this element.
-      # Use it as FastBack if the section is top level, or use the FastBack.
-      my $section_output_unit;
-      my $current_unit = $output_unit;
-      while ($current_unit->{'tree_unit_directions'}
-             and $current_unit->{'tree_unit_directions'}->{'prev'}) {
-        $current_unit = $current_unit->{'tree_unit_directions'}->{'prev'};
-        $section = _output_unit_section($current_unit);
-        if (defined($section)) {
-          $section_output_unit = $current_unit;
-          last;
-        }
-      }
-      if ($section_output_unit) {
-        if ($section_output_unit->{'directions'}->{'FastForward'}) {
-          $directions->{'FastForward'}
-            = $section_output_unit->{'directions'}->{'FastForward'};
-        }
-        if ($section->{'extra'}->{'section_level'} <= 1) {
-          $directions->{'FastBack'} = $section_output_unit;
-        } elsif ($section_output_unit->{'directions'}->{'FastBack'}) {
-          $directions->{'FastBack'}
-            = $section_output_unit->{'directions'}->{'FastBack'};
-        }
-      }
-    } else {
-      foreach my $direction(['Up', 'up'], ['Next', 'next'],
-                            ['Prev', 'prev']) {
-        # in most cases $section->{'extra'}->{'section_directions'}
-        #          ->{$direction->[1]}
-        #                 ->{'associated_unit'} is defined
-        # but it may not be the case for the up of @top.
-        # The section may be its own up in cases like
-        #  @part part
-        #  @chapter chapter
-        # in that cas the direction is not set up
-        $directions->{$direction->[0]}
-         = $section->{'extra'}->{'section_directions'}->{$direction->[1]}
-             ->{'associated_unit'}
-          if ($section->{'extra'}->{'section_directions'}
-           and $section->{'extra'}->{'section_directions'}->{$direction->[1]}
-           and $section->{'extra'}->{'section_directions'}->{$direction->[1]}
-                                           ->{'associated_unit'}
-           and (!$section->{'associated_unit'}
-                or 
$section->{'extra'}->{'section_directions'}->{$direction->[1]}
-                    ->{'associated_unit'}
-                       ne $section->{'associated_unit'}));
-      }
-
-      # fastforward is the next element on same level than the upper parent
-      # element.
-      my $up = $section;
-      while ($up->{'extra'}->{'section_level'} > 1
-             and $up->{'extra'}->{'section_directions'}
-             and $up->{'extra'}->{'section_directions'}->{'up'}) {
-        $up = $up->{'extra'}->{'section_directions'}->{'up'};
-      }
-
-      if ($up->{'extra'}->{'section_level'} < 1
-          and $up->{'cmdname'} and $up->{'cmdname'} eq 'top'
-          and $up->{'extra'}->{'section_childs'}
-          and @{$up->{'extra'}->{'section_childs'}}) {
-        $directions->{'FastForward'}
-           = $up->{'extra'}->{'section_childs'}->[0]->{'associated_unit'};
-      } elsif ($up->{'extra'}->{'toplevel_directions'}
-               and $up->{'extra'}->{'toplevel_directions'}->{'next'}) {
-        $directions->{'FastForward'}
-          = $up->{'extra'}->{'toplevel_directions'}->{'next'}
-                                 ->{'associated_unit'};
-      } elsif ($up->{'extra'}->{'section_directions'}
-               and $up->{'extra'}->{'section_directions'}->{'next'}) {
-        $directions->{'FastForward'}
-          = $up->{'extra'}->{'section_directions'}->{'next'}
-                              ->{'associated_unit'};
-      }
-      # if the element isn't at the highest level, fastback is the
-      # highest parent element
-      if ($up and $up ne $section
-          and $up->{'associated_unit'}) {
-        $directions->{'FastBack'} = $up->{'associated_unit'};
-      } elsif ($section->{'extra'}->{'section_level'} <= 1
-               and $directions->{'FastForward'}) {
-        # the element is a top level element, we adjust the next
-        # toplevel element fastback
-        $directions->{'FastForward'}->{'directions'} = {}
-           if (! $directions->{'FastForward'}->{'directions'});
-        $directions->{'FastForward'}->{'directions'}->{'FastBack'}
-          = $output_unit;
-      }
-    }
-    if ($output_unit->{'directions'}) {
-      %{$output_unit->{'directions'}}
-        = (%{$output_unit->{'directions'}}, %$directions);
-    } else {
-      $output_unit->{'directions'} = $directions;
-    }
-  }
-  if ($customization_information->get_conf('DEBUG')) {
-    foreach my $output_unit (@$output_units) {
-      print STDERR 'Directions'
-       # uncomment to show the perl object name
-       #  . "($output_unit)"
-         . ': '.print_output_unit_directions($output_unit)."\n";
-    }
-  }
-}
-
-sub units_file_directions($)
-{
-  my $output_units = shift;
-  return if (!$output_units or !@$output_units);
-
-  my $current_filename;
-  my $first_unit_in_file;
-  # need to gather the directions before the FirstInFile* directions
-  # are added to the first element in the file.
-  my @first_unit_in_file_directions;
-  foreach my $output_unit (@$output_units) {
-    if (defined($output_unit->{'unit_filename'})) {
-      my $filename = $output_unit->{'unit_filename'};
-      my $current_output_unit = $output_unit;
-      if (not defined($current_filename)
-          or $filename ne $current_filename) {
-        $first_unit_in_file = $output_unit;
-        @first_unit_in_file_directions
-            = keys %{$output_unit->{'directions'}};
-        $current_filename = $filename;
-      }
-      while ($current_output_unit->{'tree_unit_directions'}
-             and $current_output_unit->{'tree_unit_directions'}->{'prev'}) {
-        $current_output_unit
-          = $current_output_unit->{'tree_unit_directions'}->{'prev'};
-        if (defined($current_output_unit->{'unit_filename'})) {
-          if ($current_output_unit->{'unit_filename'} ne $filename) {
-            $output_unit->{'directions'}->{'PrevFile'}
-                 = $current_output_unit;
-            last;
-          }
-        } else {
-          last;
-        }
-      }
-      $current_output_unit = $output_unit;
-      while ($current_output_unit->{'tree_unit_directions'}
-             and $current_output_unit->{'tree_unit_directions'}->{'next'}) {
-        $current_output_unit
-          = $current_output_unit->{'tree_unit_directions'}->{'next'};
-        if (defined($current_output_unit->{'unit_filename'})) {
-          if ($current_output_unit->{'unit_filename'} ne $filename) {
-            $output_unit->{'directions'}->{'NextFile'}
-               = $current_output_unit;
-            last;
-          }
-        } else {
-          last;
-        }
-      }
-    }
-    # set the directions of the first elements in file, to
-    # be used in footers for example
-    if (defined($first_unit_in_file)) {
-      foreach my $first_in_file_direction
-                (@first_unit_in_file_directions) {
-        $output_unit->{'directions'}
-                                ->{'FirstInFile'.$first_in_file_direction}
-          = $first_unit_in_file->{'directions'}
-                                         ->{$first_in_file_direction};
-      }
-    }
-  }
-}
-
-# used in debug messages
-sub output_unit_texi($)
-{
-  my $output_unit = shift;
-  if (!$output_unit) {
-    return "UNDEF OUTPUT UNIT";
-  }
-  if (!defined($output_unit->{'unit_type'})) {
-    # show the output_unit as element, as a possible bug is that
-    # an element was passed in argument instead of an output unit
-    return "unit $output_unit without type: ".
-       Texinfo::Common::debug_print_element_details($output_unit, 1)
-      .' '.Texinfo::Common::debug_print_output_unit($output_unit);
-  }
-
-  my $unit_command = $output_unit->{'unit_command'};
-
-  if ($output_unit->{'unit_type'} eq 'external_node_unit') {
-    return Texinfo::Convert::Texinfo::convert_to_texinfo(
-                            {'contents' => $unit_command->{'contents'}});
-  } elsif ($output_unit->{'unit_type'} eq 'special_unit') {
-    return "_SPECIAL_UNIT: $output_unit->{'special_unit_variety'}";
-  }
-
-  if (!$unit_command) {
-    # happens when there are only nodes and sections are used as elements
-    return "No associated command (type $output_unit->{'unit_type'})";
-  }
-  return Texinfo::Convert::Texinfo::root_heading_command_to_texinfo(
-                                                          $unit_command);
-}
-
-# Should be in the same order as relative_unit_direction_name
-# in main/output_unit.c
-my @relative_directions_order = ('This', 'Forward', 'Back', 'FastForward',
- 'FastBack', 'Next', 'Prev', 'Up', 'SectionNext', 'SectionPrev',
- 'SectionUp', 'NodeNext', 'NodePrev', 'NodeUp', 'NodeForward', 'NodeBack');
-my @file_directions_order = ('PrevFile', 'NextFile');
-my @all_directions_order
-    = (@relative_directions_order, @file_directions_order,
-       map {'FirstInFile'.$_} @relative_directions_order);
-
-# Used for debugging and in test suite, but not generally useful. Not
-# documented in pod section and not exportable as it should not, in
-# general, be used.
-sub print_output_unit_directions($)
-{
-  my $output_unit = shift;
-  my $result = 'output unit: '.output_unit_texi($output_unit)."\n";
-
-  if ($output_unit->{'directions'}) {
-    #foreach my $direction (sort(keys(%{$output_unit->{'directions'}}))) {
-    foreach my $direction (@all_directions_order) {
-      if (defined($output_unit->{'directions'}->{$direction})) {
-        $result .= "  $direction: ".
-         output_unit_texi($output_unit->{'directions'}->{$direction})."\n";
-      }
-    }
-  } else {
-    $result .= "  NO DIRECTION\n";
-  }
-  return $result;
-}
-
 1;
 
 __END__
@@ -2296,32 +1615,18 @@ Texinfo::Structuring - information on Texinfo::Document 
tree
 =head1 SYNOPSIS
 
   use Texinfo::Structuring qw(sectioning_structure nodes_tree number_floats
-    associate_internal_references split_by_node split_by_section split_pages
-    units_directions units_file_directions);
+    associate_internal_references);
 
-  # $document is a parsed Texinfo::Document document, $tree is the
-  # associated Texinfo document tree. When customization variables
-  # information is needed, it is obtained from the $document by calling
-  # the get_conf() method.
+  # $document is a parsed Texinfo::Document document.
+  # When customization variables information is needed, it is obtained
+  # from the $document by calling the get_conf() method.
   my $sections_list = sectioning_structure($document);
-  my $identifier_target = $document->labels_information();
-  my $global_commands = $document->global_commands_information();
   my $nodes_list = nodes_tree($document);
   set_menus_node_directions($document);
   complete_node_tree_with_menus($document);
-  my $refs = $document->internal_references_information();
   check_nodes_are_referenced($document);
   associate_internal_references($document);
   number_floats($document->floats_information());
-  my $output_units;
-  if ($split_at_nodes) {
-    $output_units = split_by_node($document);
-  } else {
-    $output_units = split_by_section($document);
-  }
-  split_pages($output_units, $split);
-  units_directions($document, $identifier_target, $output_units);
-  units_file_directions($output_units);
 
 =head1 NOTES
 
@@ -2330,8 +1635,8 @@ Texinfo to other formats.  There is no promise of API 
stability.
 
 =head1 DESCRIPTION
 
-Texinfo::Structuring first allows to collect information on a Texinfo
-document.  Thanks to C<sectioning_structure> the hierarchy of
+C<Texinfo::Structuring> allows to collect information on a Texinfo
+document structure.  Thanks to C<sectioning_structure> the hierarchy of
 sectioning commands is determined.  The directions implied by menus are
 determined with C<set_menus_node_directions>.  The node tree is analysed
 with C<nodes_tree>.  Nodes directions are completed with menu directions
@@ -2339,25 +1644,6 @@ with C<complete_node_tree_with_menus>.  Floats get their 
standard
 numbering with C<number_floats> and internal references are matched up
 with nodes, floats or anchors with C<associate_internal_references>.
 
-The following methods depend on the output format, so are usually called
-from converters.
-
-It is also possible to associate top-level contents of the tree, which
-consist in nodes and sectioning commands with output units that
-group together a node and the next sectioning element.  With
-C<split_by_node> nodes are considered to be the main sectioning elements,
-while with C<split_by_section> the sectioning command elements are the
-main elements.  The first mode is typical of Info format, while the second
-corresponds to a traditional book.  The elements may be further split in
-I<pages>, which are not pages as in book pages, but more like web pages,
-and hold series of output units.
-
-The output units may have directions to other output units prepared
-by C<units_directions>.  C<units_file_directions> should also
-set direction related to files, provided files are associated with
-output units by the user.
-
-
 =head1 METHODS
 
 No method is exported in the default case.
@@ -2396,82 +1682,6 @@ X<C<complete_node_tree_with_menus>>
 Complete nodes directions with menu directions.  Check consistency
 of menus, sectionning and nodes direction structures.
 
-=item units_directions($customization_information, $identifier_target, 
$output_units)
-X<C<units_directions>>
-
-Directions are set up for the output units in the array reference
-I<$output_units> given in argument. The corresponding hash is associated
-to the C<directions> key. In this hash, keys correspond to directions
-while values are output units.
-
-The following directions are set up:
-
-=over
-
-=item This
-
-The output unit itself.
-
-=item Forward
-
-Unit next.
-
-=item Back
-
-Previous output unit.
-
-=item NodeForward
-
-Following node output unit in reading order.  It is the next node unit, or the
-first in menu or the next of the up node.
-
-=item NodeBack
-
-Preceding node output unit.
-
-=item NodeUp
-
-=item NodeNext
-
-=item NodePrev
-
-The up, next and previous node output unit.
-
-=item Up
-
-=item Next
-
-=item Prev
-
-The up, next and previous section output unit.
-
-=item FastBack
-
-For top level output units, the previous top level output unit.  For other
-output units the up top level unit.  For example, for a chapter output unit it
-is the previous chapter output unit, for a subsection output unit it is the
-chapter output unit that contains the subsection.
-
-=item FastForward
-
-The next top level output unit.
-
-=back
-
-=item units_file_directions($output_units)
-X<C<units_file_directions>>
-
-In the directions reference described above for C<units_directions>,
-sets the I<PrevFile> and I<NextFile> directions to the output units in
-previous and following files.
-
-It also sets I<FirstInFile*> directions for all the output units by using
-the directions of the first output unit in file.  So, for example,
-I<FirstInFileNodeNext> is the output unit associated to the next node
-of the first output unit node in the file for each output unit in the file.
-
-The API for association of pages/output units to files is not defined yet.
-
 =item @children_nodes = get_node_node_childs_from_sectioning($node)
 X<C<get_node_node_childs_from_sectioning>>
 
@@ -2606,62 +1816,6 @@ elements corresponding to menu directions.
 
 =back
 
-=item $output_units = split_by_node($document)
-X<C<split_by_node>>
-
-Returns a reference array of output units where a node is associated to
-the following sectioning commands.  Sectioning commands without nodes
-are also with the previous node, while nodes without sectioning commands
-are alone in their output units.
-
-Output units are hash references with with type I<unit>, the node command
-associated with the element is associated to the C<unit_command> key,
-the associated nodes and sectioning tree elements are in the array
-associated with the C<contents> key.  The associated elements have
-an C<associated_unit> key that points to the associated output unit.
-
-Output units also have directions in the C<tree_unit_directions>
-hash reference, namely I<next> and I<prev> pointing to the
-previous and the next output unit.
-
-=item $output_units = split_by_section($document)
-X<C<split_by_section>>
-
-Similarly with C<split_by_node>, returns an array of output units.  This
-time, lone nodes are associated with the previous sections and lone
-sections makes up an output unit.
-
-The hash keys set are the same, except that I<unit_command> is the sectioning
-command associated with the output unit.
-
-=item $pages = split_pages($output_units, $split)
-X<C<split_pages>>
-
-The output units from the array reference argument have a
-I<first_in_page> value set to the first output unit in the group,
-and based on the value of I<$split>.  The possible values for
-I<$split> are
-
-=over
-
-=item chapter
-
-The output units are split at chapter or other toplevel sectioning commands.
-
-=item node
-
-Each element has its own output unit.
-
-=item section
-
-The output units are split at sectioning commands below chapter.
-
-=item value evaluating to false
-
-No splitting, only one page is returned, holding all the output units.
-
-=back
-
 =item warn_non_empty_parts($document)
 X<C<warn_non_empty_parts>>
 
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index be9ce08077..f520fb8242 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -516,7 +516,8 @@ sub complete_node_menu($;$)
         foreach my $entry (@{$menu->{'contents'}}) {
           if ($entry->{'type'} and $entry->{'type'} eq 'menu_entry') {
             my $normalized_entry_node
-              = 
Texinfo::Structuring::normalized_menu_entry_internal_node($entry);
+              = Texinfo::ManipulateTree::normalized_menu_entry_internal_node(
+                                                                       $entry);
             if (defined($normalized_entry_node)) {
               $existing_entries{$normalized_entry_node} = [$menu, $entry];
             }
@@ -646,7 +647,7 @@ sub regenerate_master_menu($;$)
                    or !scalar(@{$top_node->{'extra'}->{'menus'}}));
 
   my $new_detailmenu
-      = Texinfo::Structuring::new_detailmenu_element($document,
+      = Texinfo::Structuring::new_detailmenu($document,
                       $document->registrar(),
                       $identifier_target, $top_node->{'extra'}->{'menus'},
                       $use_sections);
diff --git a/tp/Texinfo/XS/structuring_transfo/structuring.h 
b/tp/Texinfo/XS/structuring_transfo/structuring.h
index d671da4247..1f7f11f052 100644
--- a/tp/Texinfo/XS/structuring_transfo/structuring.h
+++ b/tp/Texinfo/XS/structuring_transfo/structuring.h
@@ -24,7 +24,6 @@ ELEMENT *new_detailmenu (ERROR_MESSAGE_LIST *error_messages,
                  const OPTIONS *options,
                  const LABEL_LIST *identifiers_target,
                  const ELEMENT_LIST *menus, int use_sections);
-
 ELEMENT *new_complete_menu_master_menu (ERROR_MESSAGE_LIST *error_messages,
                                const OPTIONS *options,
                                const LABEL_LIST *identifiers_target,
diff --git a/tp/init/book.pm b/tp/init/book.pm
index b63510de55..18a12d6016 100644
--- a/tp/init/book.pm
+++ b/tp/init/book.pm
@@ -27,6 +27,7 @@ use strict;
 use Texinfo::Commands;
 use Texinfo::Common;
 use Texinfo::Convert::Texinfo;
+# for section_level_adjusted_command_name
 use Texinfo::Structuring;
 
 my %sectioning_heading_commands = 
%Texinfo::Commands::sectioning_heading_commands;
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 8255cc0ee0..3d7c3295e4 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -72,6 +72,7 @@ use Texinfo::Document;
 use Texinfo::Convert::PlainTexinfo;
 use Texinfo::ManipulateTree;
 use Texinfo::Structuring;
+use Texinfo::OutputUnits;
 # for format_index_entries_sort_strings
 use Texinfo::Indices;
 use Texinfo::Translations;
@@ -1386,7 +1387,7 @@ sub test($$)
   # on conversion should be fairly well tested.  See above the comment
   # near test_split with more explanation on why previous splitting should
   # not interfere with conversion.
-  my $unsplit_needed = Texinfo::Structuring::unsplit($document);
+  my $unsplit_needed = Texinfo::OutputUnits::unsplit($document);
   print STDERR "  UNSPLIT: $test_name\n"
     if ($self->{'DEBUG'} and $unsplit_needed);
 
@@ -1399,27 +1400,27 @@ sub test($$)
   # output units.
   my $output_units;
   if ($test_split eq 'node') {
-    $output_units = Texinfo::Structuring::split_by_node($document);
+    $output_units = Texinfo::OutputUnits::split_by_node($document);
   } elsif ($test_split eq 'section') {
-    $output_units = Texinfo::Structuring::split_by_section($document);
+    $output_units = Texinfo::OutputUnits::split_by_section($document);
   }
   if ($test_split) {
     my $identifier_target = $document->labels_information();
-    Texinfo::Structuring::units_directions($document,
+    Texinfo::OutputUnits::units_directions($document,
                                            $identifier_target,
                                            $output_units);
     $directions_text = '';
     foreach my $output_unit (@$output_units) {
       $directions_text .=
-          Texinfo::Structuring::print_output_unit_directions($output_unit);
+          Texinfo::OutputUnits::print_output_unit_directions($output_unit);
     }
   }
   if ($split_pages) {
-    Texinfo::Structuring::split_pages($output_units, $split_pages);
+    Texinfo::OutputUnits::split_pages($output_units, $split_pages);
   }
 
   if ($test_split or $split_pages) {
-    Texinfo::Structuring::rebuild_output_units($output_units);
+    Texinfo::OutputUnits::rebuild_output_units($output_units);
   }
 
   my $file = "t/results/$self->{'name'}/$test_name.pl";
diff --git a/util/texi-elements-by-size b/util/texi-elements-by-size
index 77d685d33a..31f5fdded1 100755
--- a/util/texi-elements-by-size
+++ b/util/texi-elements-by-size
@@ -41,7 +41,6 @@ BEGIN {
 }
 
 use Texinfo::Parser;
-use Texinfo::Structuring;
 use Texinfo::Convert::TextContent;
 
 my $my_version = "0.1 (TP $Texinfo::Parser::VERSION)";



reply via email to

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