texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Common.pm (new_master_menu): Always


From: Gavin D. Smith
Subject: branch master updated: * tp/Texinfo/Common.pm (new_master_menu): Always take an array reference as an argument with a list of menus to operate on, so that there is only one way of calling this function. Callers updated. * tp/Texinfo/Convert/Plaintext.pm (_convert) <sectioning commands>: Check that node name is actually "Top".
Date: Fri, 04 Aug 2023 11:09:01 -0400

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

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new f0355663e3 * tp/Texinfo/Common.pm (new_master_menu): Always take an 
array reference as an argument with a list of menus to operate on, so that 
there is only one way of calling this function.  Callers updated. * 
tp/Texinfo/Convert/Plaintext.pm (_convert) <sectioning commands>: Check that 
node name is actually "Top".
f0355663e3 is described below

commit f0355663e352cf2731b410e7aa3edbac3f47b0e6
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Fri Aug 4 16:08:53 2023 +0100

    * tp/Texinfo/Common.pm (new_master_menu): Always take an array
    reference as an argument with a list of menus to operate on, so
    that there is only one way of calling this function.  Callers updated.
    * tp/Texinfo/Convert/Plaintext.pm (_convert) <sectioning commands>:
    Check that node name is actually "Top".
---
 ChangeLog                       |  8 ++++++++
 tp/Texinfo/Common.pm            | 20 ++++----------------
 tp/Texinfo/Convert/Plaintext.pm |  5 +++--
 tp/Texinfo/Transformations.pm   |  8 +++++---
 tp/t/do_master_menu.t           |  7 +++++--
 5 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0c7001441f..8eb51ae0c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-08-04  Gavin Smith <gavinsmith0123@gmail.com>
+
+       * tp/Texinfo/Common.pm (new_master_menu): Always take an array
+       reference as an argument with a list of menus to operate on, so
+       that there is only one way of calling this function.  Callers updated.
+       * tp/Texinfo/Convert/Plaintext.pm (_convert) <sectioning commands>:
+       Check that node name is actually "Top".
+
 2023-08-04  Gavin Smith <gavinsmith0123@gmail.com>
 
        Generate master menu in plaintext output
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 12ee3748f4..a1f3d8f58b 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1971,27 +1971,15 @@ sub _normalized_entry_associated_internal_node($;$)
 }
 
 # used in Plaintext converter and tree transformations
-sub new_master_menu($$;$)
+sub new_master_menu($$$)
 {
   my $self = shift;
   my $labels = shift;
-  my $top_menu = shift;
-
-  my $node = $labels->{'Top'};
-  return undef if (!defined($node));
-
-  my @menus;
-  if (defined($top_menu)) {
-    @menus = ( $top_menu );
-  } elsif ($node->{'extra'}
-             and $node->{'extra'}->{'menus'}
-             and scalar(@{$node->{'extra'}->{'menus'}})) {
-    @menus = @{$node->{'extra'}->{'menus'}};
-  }
+  my $menus = shift;
 
   my @master_menu_contents;
-  if (@menus) {
-    foreach my $menu (@menus) {
+  if (defined($menus) and @$menus) {
+    foreach my $menu (@$menus) {
       foreach my $entry (@{$menu->{'contents'}}) {
         if ($entry->{'type'} and $entry->{'type'} eq 'menu_entry') {
           my ($normalized_entry_node, $node)
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index dbd5d71dbc..a0e4c81be4 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -3834,10 +3834,11 @@ sub _convert($$)
         $self->{'seenmenus'}->{$node} = 1;
         my $menu_node;
         $menu_node = Texinfo::Structuring::new_complete_node_menu($node);
-        if ($command eq 'top' and $menu_node) {
+        if ($command eq 'top' and $menu_node
+             and $node->{'extra'}->{'normalized'} eq 'Top') {
           my $detailmenu = Texinfo::Common::new_master_menu($self,
                                                         $self->{'labels'},
-                                                        $menu_node);
+                                                        [ $menu_node ]);
           if ($detailmenu) {
             # TODO: add a blank line before detailmenu, as in
             # regenerate_master_menu.
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index af89538400..030f903988 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -552,14 +552,16 @@ sub regenerate_master_menu($$)
   my $self = shift;
   my $labels = shift;
   my $top_node = $labels->{'Top'};
-  return undef if (!defined($top_node));
 
-  my $new_master_menu = Texinfo::Common::new_master_menu($self, $labels);
-  return undef if (!defined($new_master_menu)
+  return undef if (!defined($top_node)
                    or !$top_node->{'extra'}
                    or !$top_node->{'extra'}->{'menus'}
                    or !scalar(@{$top_node->{'extra'}->{'menus'}}));
 
+  my $new_master_menu = Texinfo::Common::new_master_menu($self,
+                                 $labels, $top_node->{'extra'}->{'menus'});
+  return undef if (!defined($new_master_menu));
+
   foreach my $menu (@{$top_node->{'extra'}->{'menus'}}) {
     my $detailmenu_index = 0;
     foreach my $entry (@{$menu->{'contents'}}) {
diff --git a/tp/t/do_master_menu.t b/tp/t/do_master_menu.t
index 1f7ee8f4d7..29292762ab 100644
--- a/tp/t/do_master_menu.t
+++ b/tp/t/do_master_menu.t
@@ -130,7 +130,9 @@ my $parser_information = $parser->global_information();
 my $refs = $parser->internal_references_information();
 Texinfo::Structuring::associate_internal_references($registrar, $parser,
                                  $parser_information, $labels, $refs);
-my $master_menu = Texinfo::Common::new_master_menu($parser, $labels);
+my $top_node = $labels->{'Top'};
+my $master_menu = Texinfo::Common::new_master_menu($parser, $labels,
+                    $top_node->{'extra'}->{'menus'});
 my $out = Texinfo::Convert::Texinfo::convert_to_texinfo($master_menu);
 
 my $reference = '@detailmenu
@@ -175,7 +177,8 @@ $parser_information = $parser->global_information();
 $refs = $parser->internal_references_information();
 Texinfo::Structuring::associate_internal_references($registrar, $parser,
                                  $parser_information, $labels, $refs);
-$master_menu = Texinfo::Common::new_master_menu($parser, $labels);
+$master_menu = Texinfo::Common::new_master_menu($parser, $labels,
+                    $top_node->{'extra'}->{'menus'});
 $out = Texinfo::Convert::Texinfo::convert_to_texinfo($master_menu);
 is ($out, $reference, 'master menu no detailmenu');
 



reply via email to

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