texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Fri, 14 Jan 2022 17:18:08 -0500 (EST)

branch: master
commit a93a4f18d60799a14e2ca92012eeea86f5fa7aa3
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Jan 14 22:55:04 2022 +0100

    Move section_level() to Common.pm to avoid circular dependency
    
    * tp/Texinfo/Common.pm (section_level), tp/Texinfo/Convert/HTML.pm
    (_convert_heading_command), tp/Texinfo/Convert/Text.pm (heading),
    tp/Texinfo/Structuring.pm (sectioning_structure),
    tp/Texinfo/Transformations.pm (fill_gaps_in_sectioning),
    tp/init/book.pm: move
    section_level() from Texinfo::Structuring to Texinfo::Common to
    avoid a dependency of Texinfo::Convert::Text on Texinfo::Structuring.
    This avoids a circular dependency, as Texinfo::Structuring depends on
    Texinfo::Convert::NodeNameNormalization which depends on
    Texinfo::Convert::Text.
    
    * tp/Texinfo/Transformations.pm (new_master_menu): take directly
    gdt() from Texinfo::Translations.
    
    * tp/texi2any.pl: use $main_configuration for the configuration
    source for Texinfo::Transformations::regenerate_master_menu().
---
 ChangeLog                     | 21 +++++++++++++++++++++
 tp/Texinfo/Common.pm          | 36 ++++++++++++++++++++++++++++++++++--
 tp/Texinfo/Convert/HTML.pm    |  2 +-
 tp/Texinfo/Convert/Text.pm    | 15 ++++++---------
 tp/Texinfo/Structuring.pm     | 42 +++++++-----------------------------------
 tp/Texinfo/Transformations.pm | 13 ++++++++-----
 tp/init/book.pm               |  6 +++++-
 tp/texi2any.pl                |  3 ++-
 8 files changed, 84 insertions(+), 54 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0181ae96eb..3dc59af8c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2022-01-14  Patrice Dumas  <pertusus@free.fr>
+
+       Move section_level() to Common.pm to avoid circular dependency
+
+       * tp/Texinfo/Common.pm (section_level), tp/Texinfo/Convert/HTML.pm
+       (_convert_heading_command), tp/Texinfo/Convert/Text.pm (heading),
+       tp/Texinfo/Structuring.pm (sectioning_structure),
+       tp/Texinfo/Transformations.pm (fill_gaps_in_sectioning),
+       tp/init/book.pm: move
+       section_level() from Texinfo::Structuring to Texinfo::Common to
+       avoid a dependency of Texinfo::Convert::Text on Texinfo::Structuring.
+       This avoids a circular dependency, as Texinfo::Structuring depends on
+       Texinfo::Convert::NodeNameNormalization which depends on
+       Texinfo::Convert::Text.
+
+       * tp/Texinfo/Transformations.pm (new_master_menu): take directly
+       gdt() from Texinfo::Translations.
+
+       * tp/texi2any.pl: use $main_configuration for the configuration
+       source for Texinfo::Transformations::regenerate_master_menu().
+
 2022-01-14  Patrice Dumas  <pertusus@free.fr>
 
        Improve links to internal pod without a section
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index a14f593ff7..ee1bd21db7 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1315,6 +1315,7 @@ sub add_preamble_before_content($)
   unshift (@{$before_node_section->{'contents'}}, @first_types);
 }
 
+# for Parser and main program
 sub warn_unknown_language($) {
   my $lang = shift;
 
@@ -1345,6 +1346,7 @@ my %possible_split = (
   'node' => 1,
 );
 
+# main program
 sub warn_unknown_split($) {
   my $split = shift;
 
@@ -1396,6 +1398,9 @@ sub _count_opened_tree_braces($$)
   return $braces_count;
 }
 
+# used in Structuring in addition to Parser
+
+# retrieve a leading manual name in parentheses, if there is one.
 # $LABEL_CONTENTS_CONTAINER->{'contents'} is the Texinfo for the specification
 # of a node.  It is relevant in any situation when a label is expected,
 # @node, menu entry, float, anchor...  For the @node command, for instance,
@@ -1411,8 +1416,6 @@ sub _count_opened_tree_braces($$)
 # elements substituted the initial contents is also returned,
 # typically to replace $LABEL_CONTENTS_CONTAINER->{'contents'}
 # for consistency.
-#
-# retrieve a leading manual name in parentheses, if there is one.
 sub parse_node_manual($)
 {
   my $label_contents_container = shift;
@@ -1565,6 +1568,30 @@ sub set_output_encodings($$)
   }
 }
 
+my $min_level = $command_structuring_level{'chapter'};
+my $max_level = $command_structuring_level{'subsubsection'};
+
+# Return numbered level of an element, as modified by raise/lowersections
+sub section_level($)
+{
+  my $section = shift;
+  my $level = $command_structuring_level{$section->{'cmdname'}};
+  # correct level according to raise/lowersections
+  if ($section->{'extra'} and $section->{'extra'}->{'sections_level'}) {
+    $level -= $section->{'extra'}->{'sections_level'};
+    if ($level < $min_level) {
+      if ($command_structuring_level{$section->{'cmdname'}} < $min_level) {
+        $level = $command_structuring_level{$section->{'cmdname'}};
+      } else {
+        $level = $min_level;
+      }
+    } elsif ($level > $max_level) {
+      $level = $max_level;
+    }
+  }
+  return $level;
+}
+
 sub trim_spaces_comment_from_content($)
 {
   my $contents = shift;
@@ -2945,6 +2972,11 @@ In @*table @-commands, reassociate the index entry 
information from an index
 @-command appearing right after an @item line to the @item first element.
 Remove the index @-command from the tree.
 
+=item $level = section_level($section)
+
+Return numbered level of the tree sectioning I<$section>, as modified by
+raise/lowersections.
+
 =item set_output_encodings($configuration_informations, $parser_informations)
 
 If not already set, set C<OUTPUT_ENCODING_NAME> based on input file
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 0426253d06..a30f962eba 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -3347,7 +3347,7 @@ sub _convert_heading_command($$$$$)
     # for *heading* @-commands which do not have a level
     # in the document as they are not associated with the
     # sectioning tree, but still have a $heading_level
-    $heading_level = Texinfo::Structuring::section_level($element);
+    $heading_level = Texinfo::Common::section_level($element);
   }
  
   my $do_heading = (defined($heading) and $heading ne ''
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 67a4c8ebce..6f752a3f58 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -22,7 +22,11 @@ package Texinfo::Convert::Text;
 use 5.00405;
 use strict;
 
-# accent commands list.
+use File::Basename;
+
+use Data::Dumper;
+use Carp qw(cluck carp);
+
 use Texinfo::Common;
 use Texinfo::Convert::Unicode;
 # for debugging
@@ -30,13 +34,6 @@ use Texinfo::Convert::Texinfo;
 # misc functions and data
 use Texinfo::Convert::Utils;
 
-#use Texinfo::Structuring;
-
-use Data::Dumper;
-use Carp qw(cluck carp);
-
-use File::Basename;
-
 require Exporter;
 use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
 @ISA = qw(Exporter);
@@ -314,7 +311,7 @@ sub heading($$$;$$)
   }
   my $section_level;
   if (!defined($current->{'structure'}->{'section_level'})) {
-    $section_level = Texinfo::Structuring::section_level($current);
+    $section_level = Texinfo::Common::section_level($current);
   } else {
     $section_level = $current->{'structure'}->{'section_level'};
   }
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index b7decd1ea0..561c0852b7 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -26,18 +26,19 @@ use 5.00405;
 # See comment at start of HTML.pm
 use if $] >= 5.012, feature => 'unicode_strings';
 
+use Carp qw(cluck);
+
 use strict;
 
 use Texinfo::Common;
 
-# for debugging.  Also for index entries sorting.
-use Texinfo::Convert::Text;
 # for error messages 
 use Texinfo::Convert::Texinfo qw(node_extra_to_texi);
-
+# for debugging.  Also for index entries sorting.
+use Texinfo::Convert::Text;
+# for internal references and misc uses
 use Texinfo::Convert::NodeNameNormalization;
 
-use Carp qw(cluck);
 
 require Exporter;
 use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
@@ -89,31 +90,6 @@ $unnumbered_commands{'top'} = 1;
 $unnumbered_commands{'centerchap'} = 1;
 $unnumbered_commands{'part'} = 1;
 
-my $min_level = $command_structuring_level{'chapter'};
-my $max_level = $command_structuring_level{'subsubsection'};
-
-# Return numbered level of an element, as modified by raise/lowersections
-sub section_level($)
-{
-  my $section = shift;
-  my $level = $command_structuring_level{$section->{'cmdname'}};
-  # correct level according to raise/lowersections
-  if ($section->{'extra'} and $section->{'extra'}->{'sections_level'}) {
-    $level -= $section->{'extra'}->{'sections_level'};
-    if ($level < $min_level) {
-      if ($command_structuring_level{$section->{'cmdname'}} < $min_level) {
-        $level = $command_structuring_level{$section->{'cmdname'}};
-      } else {
-        $level = $min_level;
-      }
-    } elsif ($level > $max_level) {
-      $level = $max_level;
-    }
-  }
-  return $level;
-}
-
-
 # Go through the sectioning commands (e.g. @chapter, not @node), and
 # set:
 # 'section_level'
@@ -159,7 +135,8 @@ sub sectioning_structure($$$)
       }
     }
     my $level;
-    $level = $content->{'structure'}->{'section_level'} = 
section_level($content);
+    $level = $content->{'structure'}->{'section_level'}
+         = Texinfo::Common::section_level($content);
     if (!defined($level)) {
       warn "bug: level not defined for $content->{'cmdname'}\n";
       $level = $content->{'structure'}->{'section_level'} = 0;
@@ -1972,11 +1949,6 @@ Number the floats as described in the Texinfo manual.  
Sets
 the I<number> key in the C<structure> hash of the float
 tree elements.
 
-=item $level = section_level($section)
-
-Return numbered level of the tree sectioning I<$section>, as modified by
-raise/lowersections.
-
 =item $command_name = section_level_adjusted_command_name($element)
 
 Return the sectioning command name corresponding to the sectioning
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index 3eab955e69..1f9b64d385 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -29,6 +29,7 @@ use Carp qw(cluck);
 use List::Util qw(any);
 
 use Texinfo::Common;
+use Texinfo::Translations;
 use Texinfo::Structuring;
 
 require Exporter;
@@ -95,12 +96,12 @@ sub fill_gaps_in_sectioning($)
     }
     my $current_section = shift @sections_list;
     my $current_section_level
-       = Texinfo::Structuring::section_level($current_section);
+       = Texinfo::Common::section_level($current_section);
     my $next_section = $sections_list[0];
     
     if (defined($next_section)) {
       my $next_section_level
-                        = Texinfo::Structuring::section_level($next_section);
+                        = Texinfo::Common::section_level($next_section);
 
       if ($next_section_level - $current_section_level > 1) {
         my @correct_level_offset_commands = _correct_level($next_section,
@@ -584,21 +585,23 @@ sub new_master_menu($$)
   }
   if (scalar(@master_menu_contents)) {
     my $first_preformatted = $master_menu_contents[0]->{'contents'}->[0];
-    my $master_menu_title = $self->gdt(' --- The Detailed Node Listing ---');
+    my $master_menu_title = Texinfo::Translations::gdt($self,
+                                      ' --- The Detailed Node Listing ---');
     my @master_menu_title_contents;
     foreach my $content (@{$master_menu_title->{'contents'}}, {'text' => 
"\n"}) {
       $content->{'parent'} = $first_preformatted;
       push @master_menu_title_contents, $content;
     }
     unshift @{$first_preformatted->{'contents'}}, @master_menu_title_contents;
-    return Texinfo::Structuring::new_block_command(\@master_menu_contents, 
undef, 'detailmenu');
+    return Texinfo::Structuring::new_block_command(\@master_menu_contents, 
undef,
+                                                   'detailmenu');
   } else {
     return undef;
   }
 }
 
 # self is used to pass down a translatable object with customization
-# information to call gdt().
+# information for the gdt() call.
 sub regenerate_master_menu($$)
 {
   my $self = shift;
diff --git a/tp/init/book.pm b/tp/init/book.pm
index 85f6bb59d3..bef7a537a7 100644
--- a/tp/init/book.pm
+++ b/tp/init/book.pm
@@ -12,6 +12,10 @@ use strict;
 
 use vars qw($element_file_name);
 
+use Texinfo::Common;
+use Texinfo::Convert::Texinfo;
+use Texinfo::Structuring;
+
 texinfo_set_from_init_file('contents', 1);
 texinfo_set_from_init_file('CONTENTS_OUTPUT_LOCATION', 'inline');
 texinfo_set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
@@ -246,7 +250,7 @@ sub book_convert_heading_command($$$$$)
     # for *heading* @-commands which do not have a level
     # in the document as they are not associated with the
     # sectioning tree, but still have a $heading_level
-    $heading_level = Texinfo::Structuring::section_level($element);
+    $heading_level = Texinfo::Common::section_level($element);
   }
 
   my $heading = $self->command_text($element);
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 2e3ba14f7e..2dc5010aa8 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1301,7 +1301,8 @@ while(@input_files) {
   }
 
   if ($tree_transformations{'regenerate_master_menu'}) {
-    Texinfo::Transformations::regenerate_master_menu($parser, $labels);
+    Texinfo::Transformations::regenerate_master_menu($main_configuration,
+                                                     $labels);
   }
 
   # this can be done for every format, since information is already gathered



reply via email to

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