[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Structuring.pm
From: |
Gavin D. Smith |
Subject: |
branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Structuring.pm (_normalized_entry_associated_internal_node, new_master_menu): Move to Structuring.pm as Common.pm should not depend on Texinfo::Structuring or Texinfo::Translations. Report from Patrice. |
Date: |
Sat, 05 Aug 2023 06:19:29 -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 bfb364577a * tp/Texinfo/Common.pm, tp/Texinfo/Structuring.pm
(_normalized_entry_associated_internal_node, new_master_menu): Move to
Structuring.pm as Common.pm should not depend on Texinfo::Structuring or
Texinfo::Translations. Report from Patrice.
bfb364577a is described below
commit bfb364577aa73a755fb3bba303aa142a5f50a8a9
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Aug 5 11:19:20 2023 +0100
* tp/Texinfo/Common.pm, tp/Texinfo/Structuring.pm
(_normalized_entry_associated_internal_node, new_master_menu):
Move to Structuring.pm as Common.pm should not depend on
Texinfo::Structuring or Texinfo::Translations. Report from Patrice.
---
ChangeLog | 7 ++
tp/Texinfo/Common.pm | 150 ---------------------------------------
tp/Texinfo/Convert/Plaintext.pm | 2 +-
tp/Texinfo/Structuring.pm | 153 ++++++++++++++++++++++++++++++++++++++++
tp/Texinfo/Transformations.pm | 7 +-
tp/t/do_master_menu.t | 4 +-
6 files changed, 166 insertions(+), 157 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4485c0fe42..2ac5f19fb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-08-05 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/Common.pm, tp/Texinfo/Structuring.pm
+ (_normalized_entry_associated_internal_node, new_master_menu):
+ Move to Structuring.pm as Common.pm should not depend on
+ Texinfo::Structuring or Texinfo::Translations. Report from Patrice.
+
2023-08-05 Gavin Smith <gavinsmith0123@gmail.com>
add CHECK_MISSING_MENU_ENTRY
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 62934b5c44..c8e0c6a278 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1947,149 +1947,6 @@ sub _collect_commands_list_in_tree($$$)
}
}
-# Return ($NORMALIZED_ENTRY_NODE, $NODE) where $NODE is the node referred to
-# by menu entry $ENTRY, and $NORMALIZED_ENTRY_NODE is the name of this node.
-sub _normalized_entry_associated_internal_node($;$)
-{
- my $entry = shift;
- my $labels = shift;
-
- foreach my $arg (@{$entry->{'contents'}}) {
- if ($arg->{'type'} eq 'menu_entry_node') {
- if (! $arg->{'extra'}->{'manual_content'}) {
- my $normalized_entry_node = $arg->{'extra'}->{'normalized'};
- if (defined($normalized_entry_node)) {
- if ($labels) {
- return ($normalized_entry_node, $labels->{$normalized_entry_node});
- } else {
- return ($normalized_entry_node, undef);
- }
- }
- }
- last;
- }
- }
- return (undef, undef);
-}
-
-# used in Plaintext converter and tree transformations
-sub new_master_menu($$$)
-{
- my $self = shift;
- my $labels = shift;
- my $menus = shift;
-
- my @master_menu_contents;
- 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)
- = _normalized_entry_associated_internal_node($entry, $labels);
- if (defined($node) and $node->{'extra'}) {
- push @master_menu_contents, _print_down_menus($node, $labels);
- }
- }
- }
- }
- }
- if (scalar(@master_menu_contents)) {
- my $first_preformatted = $master_menu_contents[0]->{'contents'}->[0];
- 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');
- } else {
- return undef;
- }
-}
-
-sub _print_down_menus($$);
-sub _print_down_menus($$)
-{
- my $node = shift;
- my $labels = shift;
- my @menus;
-
- if ($node->{'extra'}->{'menus'}
- and scalar(@{$node->{'extra'}->{'menus'}})) {
- @menus = @{$node->{'extra'}->{'menus'}};
- } else {
- my $section = $node->{'extra'}->{'associated_section'};
- my $current_menu
- = Texinfo::Structuring::new_complete_node_menu($node, undef);
- if (defined($current_menu)) {
- @menus = ( $current_menu );
- }
- }
-
- my @master_menu_contents;
-
- if (@menus) {
- my @node_children;
- foreach my $menu (@menus) {
- foreach my $entry (@{$menu->{'contents'}}) {
- if ($entry->{'type'} and $entry->{'type'} eq 'menu_entry') {
- push @master_menu_contents, Texinfo::Common::copy_tree($entry);
- # gather node children to recursively print their menus
- my ($normalized_entry_node, $node)
- = _normalized_entry_associated_internal_node($entry, $labels);
- if (defined($node) and $node->{'extra'}) {
- push @node_children, $node;
- }
- }
- }
- }
- if (scalar(@master_menu_contents)) {
- # Prepend node title
- my $node_title_contents;
- if ($node->{'extra'}->{'associated_section'}
- and $node->{'extra'}->{'associated_section'}->{'args'}
- and $node->{'extra'}->{'associated_section'}->{'args'}->[0]
- and
$node->{'extra'}->{'associated_section'}->{'args'}->[0]->{'contents'}) {
- $node_title_contents
- = Texinfo::Common::copy_contents(
-
$node->{'extra'}->{'associated_section'}->{'args'}->[0]->{'contents'});
- } else {
- $node_title_contents
- =
Texinfo::Common::copy_contents($node->{'args'}->[0]->{'contents'});
- }
- my $menu_comment = {'type' => 'menu_comment', 'contents' => []};
- $menu_comment->{'contents'}->[0] = {'type' => 'preformatted',
- 'parent' => $menu_comment};
- $menu_comment->{'contents'}->[0]->{'contents'}
- = [{'text' => "\n", 'type' => 'empty_line'}, @$node_title_contents,
- {'text' => "\n", 'type' => 'empty_line'},
- {'text' => "\n", 'type' => 'empty_line'}];
- foreach my $content (@{$menu_comment->{'contents'}->[0]->{'contents'}}) {
- $content->{'parent'} = $menu_comment->{'contents'}->[0];
- }
- unshift @master_menu_contents, $menu_comment;
-
- # now recurse in the children
- foreach my $child (@node_children) {
- push @master_menu_contents, _print_down_menus($child, $labels);
- }
- }
- }
- return @master_menu_contents;
-}
-
-if (0) {
- # it is needed to mark the translation as gdt is called like
- # Texinfo::Translations::gdt($self, ' --- The Detailed Node Listing ---')
- # and not like gdt(' --- The Detailed Node Listing ---')
- gdt(' --- The Detailed Node Listing ---');
-}
-
-
-
# functions useful for Texinfo tree transformations
# and some tree transformations functions, mostly those
@@ -3064,13 +2921,6 @@ In tables, relate index entries preceding and following
an
entry with said item. Reference one of them in the entry's
C<entry_associated_element>.
-=item $detailmenu = new_master_menu($translations, $labels)
-X<C<new_master_menu>>
-
-Returns a detailmenu tree element formatted as a master node.
-I<$translations>, if defined, should be a L<Texinfo::Translations> object and
-should also hold customization information.
-
=item $normalized_name = normalize_top_node_name($node_string)
X<C<normalize_top_node_name>>
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 9d07184d61..dbd57ec35e 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -3836,7 +3836,7 @@ sub _convert($$)
$menu_node = Texinfo::Structuring::new_complete_node_menu($node);
if ($command eq 'top' and $menu_node
and $node->{'extra'}->{'normalized'} eq 'Top') {
- my $detailmenu = Texinfo::Common::new_master_menu($self,
+ my $detailmenu = Texinfo::Structuring::new_master_menu($self,
$self->{'labels'},
[ $menu_node ]);
if ($detailmenu) {
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 352ba177a6..e67c6e8fc3 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -46,6 +46,8 @@ use Texinfo::Convert::Texinfo qw(target_element_to_texi_label
use Texinfo::Convert::Text;
# for internal references and misc uses
use Texinfo::Convert::NodeNameNormalization;
+# for new_master_menu translations
+use Texinfo::Translations;
require Exporter;
@@ -1771,6 +1773,150 @@ sub _sort_string($$)
: (($a =~ /^[[:alpha:]]/ && 1) || -1);
}
+# Return ($NORMALIZED_ENTRY_NODE, $NODE) where $NODE is the node referred to
+# by menu entry $ENTRY, and $NORMALIZED_ENTRY_NODE is the name of this node.
+sub _normalized_entry_associated_internal_node($;$)
+{
+ my $entry = shift;
+ my $labels = shift;
+
+ foreach my $arg (@{$entry->{'contents'}}) {
+ if ($arg->{'type'} eq 'menu_entry_node') {
+ if (! $arg->{'extra'}->{'manual_content'}) {
+ my $normalized_entry_node = $arg->{'extra'}->{'normalized'};
+ if (defined($normalized_entry_node)) {
+ if ($labels) {
+ return ($normalized_entry_node, $labels->{$normalized_entry_node});
+ } else {
+ return ($normalized_entry_node, undef);
+ }
+ }
+ }
+ last;
+ }
+ }
+ return (undef, undef);
+}
+
+# used in Plaintext converter and tree transformations
+sub new_master_menu($$$)
+{
+ my $self = shift;
+ my $labels = shift;
+ my $menus = shift;
+
+ my @master_menu_contents;
+ 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)
+ = _normalized_entry_associated_internal_node($entry, $labels);
+ if (defined($node) and $node->{'extra'}) {
+ push @master_menu_contents, _print_down_menus($node, $labels);
+ }
+ }
+ }
+ }
+ }
+ if (scalar(@master_menu_contents)) {
+ my $first_preformatted = $master_menu_contents[0]->{'contents'}->[0];
+ 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');
+ } else {
+ return undef;
+ }
+}
+
+sub _print_down_menus($$);
+sub _print_down_menus($$)
+{
+ my $node = shift;
+ my $labels = shift;
+ my @menus;
+
+ if ($node->{'extra'}->{'menus'}
+ and scalar(@{$node->{'extra'}->{'menus'}})) {
+ @menus = @{$node->{'extra'}->{'menus'}};
+ } else {
+ my $section = $node->{'extra'}->{'associated_section'};
+ my $current_menu
+ = Texinfo::Structuring::new_complete_node_menu($node, undef);
+ if (defined($current_menu)) {
+ @menus = ( $current_menu );
+ }
+ }
+
+ my @master_menu_contents;
+
+ if (@menus) {
+ my @node_children;
+ foreach my $menu (@menus) {
+ foreach my $entry (@{$menu->{'contents'}}) {
+ if ($entry->{'type'} and $entry->{'type'} eq 'menu_entry') {
+ push @master_menu_contents, Texinfo::Common::copy_tree($entry);
+ # gather node children to recursively print their menus
+ my ($normalized_entry_node, $node)
+ = _normalized_entry_associated_internal_node($entry, $labels);
+ if (defined($node) and $node->{'extra'}) {
+ push @node_children, $node;
+ }
+ }
+ }
+ }
+ if (scalar(@master_menu_contents)) {
+ # Prepend node title
+ my $node_title_contents;
+ if ($node->{'extra'}->{'associated_section'}
+ and $node->{'extra'}->{'associated_section'}->{'args'}
+ and $node->{'extra'}->{'associated_section'}->{'args'}->[0]
+ and
$node->{'extra'}->{'associated_section'}->{'args'}->[0]->{'contents'}) {
+ $node_title_contents
+ = Texinfo::Common::copy_contents(
+
$node->{'extra'}->{'associated_section'}->{'args'}->[0]->{'contents'});
+ } else {
+ $node_title_contents
+ =
Texinfo::Common::copy_contents($node->{'args'}->[0]->{'contents'});
+ }
+ my $menu_comment = {'type' => 'menu_comment', 'contents' => []};
+ $menu_comment->{'contents'}->[0] = {'type' => 'preformatted',
+ 'parent' => $menu_comment};
+ $menu_comment->{'contents'}->[0]->{'contents'}
+ = [{'text' => "\n", 'type' => 'empty_line'}, @$node_title_contents,
+ {'text' => "\n", 'type' => 'empty_line'},
+ {'text' => "\n", 'type' => 'empty_line'}];
+ foreach my $content (@{$menu_comment->{'contents'}->[0]->{'contents'}}) {
+ $content->{'parent'} = $menu_comment->{'contents'}->[0];
+ }
+ unshift @master_menu_contents, $menu_comment;
+
+ # now recurse in the children
+ foreach my $child (@node_children) {
+ push @master_menu_contents, _print_down_menus($child, $labels);
+ }
+ }
+ }
+ return @master_menu_contents;
+}
+
+if (0) {
+ # it is needed to mark the translation as gdt is called like
+ # Texinfo::Translations::gdt($self, ' --- The Detailed Node Listing ---')
+ # and not like gdt(' --- The Detailed Node Listing ---')
+ gdt(' --- The Detailed Node Listing ---');
+}
+
+
+
+
sub _sort_index_entries($$)
{
my $key1 = shift;
@@ -2360,6 +2506,13 @@ Returns a texinfo tree menu for node I<$node>, pointing
to the children
of the node obtained with the sectioning structure. If I<$use_sections>
is set, use section names for the menu entry names.
+=item $detailmenu = new_master_menu($translations, $labels)
+X<C<new_master_menu>>
+
+Returns a detailmenu tree element formatted as a master node.
+I<$translations>, if defined, should be a L<Texinfo::Translations> object and
+should also hold customization information.
+
=item $entry = new_node_menu_entry($node, $use_sections)
X<C<new_node_menu_entry>>
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index b965a8fee7..660e22bcda 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -412,10 +412,9 @@ sub complete_node_menu($;$)
foreach my $entry (@{$menu->{'contents'}}) {
if ($entry->{'type'} and $entry->{'type'} eq 'menu_entry') {
my ($normalized_entry_node, $node)
- =
Texinfo::Common::_normalized_entry_associated_internal_node($entry);
+ =
Texinfo::Structuring::_normalized_entry_associated_internal_node($entry);
if (defined($normalized_entry_node)) {
- $existing_entries{$normalized_entry_node}
- = [$menu, $entry];
+ $existing_entries{$normalized_entry_node} = [$menu, $entry];
}
}
}
@@ -535,7 +534,7 @@ sub regenerate_master_menu($$)
or !$top_node->{'extra'}->{'menus'}
or !scalar(@{$top_node->{'extra'}->{'menus'}}));
- my $new_master_menu = Texinfo::Common::new_master_menu($self,
+ my $new_master_menu = Texinfo::Structuring::new_master_menu($self,
$labels, $top_node->{'extra'}->{'menus'});
return undef if (!defined($new_master_menu));
diff --git a/tp/t/do_master_menu.t b/tp/t/do_master_menu.t
index 29292762ab..c673ab5dcd 100644
--- a/tp/t/do_master_menu.t
+++ b/tp/t/do_master_menu.t
@@ -131,7 +131,7 @@ my $refs = $parser->internal_references_information();
Texinfo::Structuring::associate_internal_references($registrar, $parser,
$parser_information, $labels, $refs);
my $top_node = $labels->{'Top'};
-my $master_menu = Texinfo::Common::new_master_menu($parser, $labels,
+my $master_menu = Texinfo::Structuring::new_master_menu($parser, $labels,
$top_node->{'extra'}->{'menus'});
my $out = Texinfo::Convert::Texinfo::convert_to_texinfo($master_menu);
@@ -177,7 +177,7 @@ $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::Structuring::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');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Structuring.pm (_normalized_entry_associated_internal_node, new_master_menu): Move to Structuring.pm as Common.pm should not depend on Texinfo::Structuring or Texinfo::Translations. Report from Patrice.,
Gavin D. Smith <=