[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Structuring.pm (new_detailmenu), tp
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Structuring.pm (new_detailmenu), tp/Texinfo/XS/structuring_transfo/structuring.c (new_detailmenu): rename new_master_menu as new_detailmenu, change also variables names. Update callers and variables names in callers. |
Date: |
Sun, 14 Apr 2024 08:41: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 e896003a50 * tp/Texinfo/Structuring.pm (new_detailmenu),
tp/Texinfo/XS/structuring_transfo/structuring.c (new_detailmenu): rename
new_master_menu as new_detailmenu, change also variables names. Update callers
and variables names in callers.
e896003a50 is described below
commit e896003a5002146d54c0f4178671a6d8a6165ffc
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Apr 14 14:40:55 2024 +0200
* tp/Texinfo/Structuring.pm (new_detailmenu),
tp/Texinfo/XS/structuring_transfo/structuring.c (new_detailmenu):
rename new_master_menu as new_detailmenu, change also variables names.
Update callers and variables names in callers.
---
ChangeLog | 7 +++
tp/Texinfo/Document.pm | 2 +-
tp/Texinfo/Structuring.pm | 61 +++++++++++++---------
tp/Texinfo/Transformations.pm | 19 +++----
tp/Texinfo/XS/structuring_transfo/structuring.c | 33 ++++++------
tp/Texinfo/XS/structuring_transfo/structuring.h | 2 +-
.../XS/structuring_transfo/transformations.c | 23 ++++----
tp/t/do_master_menu.t | 4 +-
8 files changed, 86 insertions(+), 65 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f922844968..e67873498d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-04-14 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Structuring.pm (new_detailmenu),
+ tp/Texinfo/XS/structuring_transfo/structuring.c (new_detailmenu):
+ rename new_master_menu as new_detailmenu, change also variables names.
+ Update callers and variables names in callers.
+
2024-04-14 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Indices.pm: remove export of functions.
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index 97f33a9d95..39a15c454f 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -461,7 +461,7 @@ sub register_label_element($$;$$)
_existing_label_error($self, $element, $registrar,
$customization_information);
}
- # FIXME do not push at the end but have the caller give an information
+ # TODO do not push at the end but have the caller give an information
# on the element it should be after or before in the list?
push @{$self->{'labels_list'}}, $element;
return $retval;
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index daffcf776c..717bde200b 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -506,6 +506,7 @@ sub _register_menu_node_targets($$$)
}
}
+# Should be called after sectioning_structure.
sub get_node_node_childs_from_sectioning
{
my ($node) = @_;
@@ -1283,7 +1284,10 @@ sub section_level_adjusted_command_name($)
return $command;
}
-# returns the texinfo tree corresponding to a single menu entry pointing
+
+# The following code is about menu elements creation
+
+# returns the Texinfo tree corresponding to a single menu entry pointing
# to $NODE.
# if $USE_SECTIONS is set, use the section name as menu entry name.
sub new_node_menu_entry
@@ -1437,7 +1441,8 @@ sub _insert_menu_comment_content($$$;$)
splice (@$menu_contents, $position, 0, $menu_comment);
}
-# $CUSTOMIZATION_INFORMATION is only used for the top menu
+# Creates a new @menu element based on $NODE sectioning information.
+# $CUSTOMIZATION_INFORMATION is only used for the top menu.
sub new_complete_node_menu
{
my ($node, $customization_information, $use_sections) = @_;
@@ -1449,7 +1454,7 @@ sub new_complete_node_menu
}
# only holds contents here, will be turned into a proper block
- # command in new_block_command
+ # command in new_block_command below
my $section = $node->{'extra'}->{'associated_section'};
my $new_menu = {'contents' => [], 'parent' => $section};
foreach my $child (@node_childs) {
@@ -1460,7 +1465,8 @@ sub new_complete_node_menu
}
}
- # in top node, insert menu comments for parts and for the first appendix
+ # in top node, additionally insert menu comments for parts and for
+ # the first appendix.
if ($section and $section->{'cmdname'} eq 'top'
and $customization_information
and $node->{'extra'}->{'normalized'}
@@ -1514,8 +1520,10 @@ sub new_complete_node_menu
return $new_menu;
}
-# used in Plaintext converter and tree transformations
-sub new_master_menu($$$$;$)
+# Create a new @detailmenu element.
+# used in tree transformations. Used in converters through
+# new_complete_menu_master_menu.
+sub new_detailmenu($$$$;$)
{
my $customization_information = shift;
my $registrar = shift;
@@ -1525,7 +1533,7 @@ sub new_master_menu($$$$;$)
# only holds contents here, will be turned into a proper block
# command in new_block_command
- my $master_menu = {'contents' => []};
+ my $new_detailmenu = {'contents' => []};
if (defined($menus) and scalar(@$menus)) {
foreach my $menu (@$menus) {
foreach my $entry (@{$menu->{'contents'}}) {
@@ -1534,7 +1542,7 @@ sub new_master_menu($$$$;$)
= _normalized_entry_associated_internal_node($entry,
$identifier_target);
if ($node) {
- push @{$master_menu->{'contents'}}, _print_down_menus($node, undef,
+ push @{$new_detailmenu->{'contents'}}, _print_down_menus($node,
undef,
$customization_information,
$registrar,
$identifier_target, $use_sections);
@@ -1543,10 +1551,11 @@ sub new_master_menu($$$$;$)
}
}
}
- if (scalar(@{$master_menu->{'contents'}})) {
+ if (scalar(@{$new_detailmenu->{'contents'}})) {
# There is a menu comment with a preformatted added in front of each
# detailed menu section with the node section name
- my $first_preformatted =
$master_menu->{'contents'}->[0]->{'contents'}->[0];
+ my $first_preformatted
+ = $new_detailmenu->{'contents'}->[0]->{'contents'}->[0];
my $master_menu_title
= Texinfo::Translations::gdt(' --- The Detailed Node Listing ---',
$customization_information->get_conf('documentlanguage'),
@@ -1557,17 +1566,19 @@ sub new_master_menu($$$$;$)
push @master_menu_title_contents, $content;
}
unshift @{$first_preformatted->{'contents'}}, @master_menu_title_contents;
- foreach my $content (@{$master_menu->{'contents'}}) {
- $content->{'parent'} = $master_menu;
+ foreach my $content (@{$new_detailmenu->{'contents'}}) {
+ $content->{'parent'} = $new_detailmenu;
}
- Texinfo::Structuring::new_block_command($master_menu, 'detailmenu');
- return $master_menu;
+ Texinfo::Structuring::new_block_command($new_detailmenu, 'detailmenu');
+ return $new_detailmenu;
} else {
return undef;
}
}
# TODO document
+# Returns a @menu element for $NODE, formatted with a master menu with a
+# @detailmenu if $NODE is the Top node.
# $SELF should be a converter.
sub new_complete_menu_master_menu($$$)
{
@@ -1581,7 +1592,7 @@ sub new_complete_menu_master_menu($$$)
and $node->{'extra'}->{'normalized'} eq 'Top'
and $node->{'extra'}->{'associated_section'}
and $node->{'extra'}->{'associated_section'}->{'cmdname'} eq 'top') {
- my $detailmenu = new_master_menu($self, undef, $labels, [$menu_node]);
+ my $detailmenu = new_detailmenu($self, undef, $labels, [$menu_node]);
if ($detailmenu) {
# add a blank line before the detailed node listing
my $menu_comment = {'type' => 'menu_comment',
@@ -1693,6 +1704,9 @@ 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
@@ -2474,15 +2488,14 @@ argument and C<@end> to turn the element to a proper
block command.
=item $new_menu = new_complete_node_menu($node, $customization_information,
$use_sections)
X<C<new_complete_node_menu>>
-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.
-I<$customization_information>, if defined, should hold information
-needed for translations. Translations are only needed when generating the
-top node menu.
+Returns a C<@menu> Texinfo tree element 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.
+I<$customization_information>, if defined, should hold information needed for
+translations. Translations are only needed when generating the top node menu.
-=item $detailmenu = new_master_menu($customization_information, $registrar,
$identifier_target, $menus)
-X<C<new_master_menu>>
+=item $detailmenu = new_detailmenu($customization_information, $registrar,
$identifier_target, $menus)
+X<C<new_detailmenu>>
Returns a detailmenu tree element formatted as a master node.
I<$menus> is an array reference containing the regular menus of the Top node.
@@ -2498,7 +2511,7 @@ and warning messages>).
=item $entry = new_node_menu_entry($node, $use_sections)
X<C<new_node_menu_entry>>
-Returns the texinfo tree corresponding to a single menu entry pointing to
+Returns the Texinfo tree corresponding to a single menu entry pointing to
I<$node>. If I<$use_sections> is set, use the section name for the menu
entry name. Returns C<undef> if the node argument is missing.
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index 769d8524c2..be9ce08077 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -645,12 +645,12 @@ sub regenerate_master_menu($;$)
or !$top_node->{'extra'}->{'menus'}
or !scalar(@{$top_node->{'extra'}->{'menus'}}));
- my $new_master_menu
- = Texinfo::Structuring::new_master_menu($document,
+ my $new_detailmenu
+ = Texinfo::Structuring::new_detailmenu_element($document,
$document->registrar(),
$identifier_target, $top_node->{'extra'}->{'menus'},
$use_sections);
- return undef if (!defined($new_master_menu));
+ return undef if (!defined($new_detailmenu));
my $global_detailmenu
= $document->global_commands_information()->{'detailmenu'};
@@ -659,9 +659,9 @@ sub regenerate_master_menu($;$)
foreach my $entry (@{$menu->{'contents'}}) {
if ($entry->{'cmdname'} and $entry->{'cmdname'} eq 'detailmenu') {
# replace existing detailmenu by the master menu
- $new_master_menu->{'parent'} = $menu;
+ $new_detailmenu->{'parent'} = $menu;
splice (@{$menu->{'contents'}}, $detailmenu_index, 1,
- $new_master_menu);
+ $new_detailmenu);
# also replace in global commands
my $index = 0;
my $global_detailmenu_index = -1;
@@ -674,7 +674,7 @@ sub regenerate_master_menu($;$)
}
if ($global_detailmenu_index >= 0) {
splice (@$global_detailmenu, $global_detailmenu_index, 1,
- $new_master_menu);
+ $new_detailmenu);
}
# FIXME use an API to register a new internal reference?
my $internal_references = $document->internal_references_information();
@@ -714,7 +714,7 @@ sub regenerate_master_menu($;$)
$index --;
}
- $new_master_menu->{'parent'} = $last_menu;
+ $new_detailmenu->{'parent'} = $last_menu;
if ($index) {
my $last_element = $last_menu->{'contents'}->[$index-1];
if ($last_element->{'type'} and $last_element->{'type'} eq 'menu_comment'
@@ -744,8 +744,8 @@ sub regenerate_master_menu($;$)
}
}
# insert master menu
- splice (@{$last_menu->{'contents'}}, $index, 0, $new_master_menu);
- push @$global_detailmenu, $new_master_menu;
+ splice (@{$last_menu->{'contents'}}, $index, 0, $new_detailmenu);
+ push @$global_detailmenu, $new_detailmenu;
return 1;
}
@@ -930,6 +930,7 @@ sub _protect_first_parenthesis_in_targets($$$)
return undef;
}
+# TODO not documented
sub protect_first_parenthesis_in_targets($)
{
my $tree = shift;
diff --git a/tp/Texinfo/XS/structuring_transfo/structuring.c
b/tp/Texinfo/XS/structuring_transfo/structuring.c
index c1ade41fe6..c4d4246cb7 100644
--- a/tp/Texinfo/XS/structuring_transfo/structuring.c
+++ b/tp/Texinfo/XS/structuring_transfo/structuring.c
@@ -2085,14 +2085,14 @@ print_down_menus (const ELEMENT *node, ELEMENT_STACK
*up_nodes,
}
ELEMENT *
-new_master_menu (ERROR_MESSAGE_LIST *error_messages,
- const OPTIONS *options,
- const LABEL_LIST *identifiers_target,
- const ELEMENT_LIST *menus, int use_sections)
+new_detailmenu (ERROR_MESSAGE_LIST *error_messages,
+ const OPTIONS *options,
+ const LABEL_LIST *identifiers_target,
+ const ELEMENT_LIST *menus, int use_sections)
{
/* only holds contents here, will be turned into a proper block
in new_block_command */
- ELEMENT *master_menu = new_element (ET_NONE);
+ ELEMENT *new_detailmenu_e = new_element (ET_NONE);
if (menus && menus->number > 0)
{
@@ -2118,11 +2118,10 @@ new_master_menu (ERROR_MESSAGE_LIST *error_messages,
{
int k;
for (k = 0; k < down_menus->number; k++)
- down_menus->list[k]->parent = master_menu;
- insert_list_slice_into_contents (master_menu,
- master_menu->contents.number,
- down_menus, 0,
- down_menus->number);
+ down_menus->list[k]->parent = new_detailmenu_e;
+ insert_list_slice_into_contents (new_detailmenu_e,
+ new_detailmenu_e->contents.number,
+ down_menus, 0, down_menus->number);
destroy_list (down_menus);
}
}
@@ -2130,14 +2129,14 @@ new_master_menu (ERROR_MESSAGE_LIST *error_messages,
}
}
}
- if (master_menu->contents.number > 0)
+ if (new_detailmenu_e->contents.number > 0)
{
int i;
ELEMENT *new_line = new_element (ET_NONE);
/* There is a menu comment with a preformatted added in front of each
detailed menu section with the node section name */
ELEMENT *first_preformatted
- = master_menu->contents.list[0]->contents.list[0];
+ = new_detailmenu_e->contents.list[0]->contents.list[0];
text_append (&new_line->text, "\n");
new_line->parent = first_preformatted;
@@ -2170,12 +2169,12 @@ new_master_menu (ERROR_MESSAGE_LIST *error_messages,
}
- new_block_command (master_menu, CM_detailmenu);
- return master_menu;
+ new_block_command (new_detailmenu_e, CM_detailmenu);
+ return new_detailmenu_e;
}
else
{
- destroy_element (master_menu);
+ destroy_element (new_detailmenu_e);
return 0;
}
}
@@ -2200,8 +2199,8 @@ new_complete_menu_master_menu (ERROR_MESSAGE_LIST
*error_messages,
ELEMENT *detailmenu;
add_to_element_list (menus, menu_node);
- detailmenu = new_master_menu (error_messages, options,
- identifiers_target, menus, 0);
+ detailmenu = new_detailmenu (error_messages, options,
+ identifiers_target, menus, 0);
destroy_list (menus);
if (detailmenu)
diff --git a/tp/Texinfo/XS/structuring_transfo/structuring.h
b/tp/Texinfo/XS/structuring_transfo/structuring.h
index 998828a8e9..d671da4247 100644
--- a/tp/Texinfo/XS/structuring_transfo/structuring.h
+++ b/tp/Texinfo/XS/structuring_transfo/structuring.h
@@ -20,7 +20,7 @@ ELEMENT *new_node_menu_entry (const ELEMENT *node, int
use_sections);
ELEMENT *new_complete_node_menu (const ELEMENT *node, DOCUMENT *document,
const OPTIONS *options, int use_sections);
void new_block_command (ELEMENT *element, enum command_id cmd);
-ELEMENT *new_master_menu (ERROR_MESSAGE_LIST *error_messages,
+ELEMENT *new_detailmenu (ERROR_MESSAGE_LIST *error_messages,
const OPTIONS *options,
const LABEL_LIST *identifiers_target,
const ELEMENT_LIST *menus, int use_sections);
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index 52aa95891c..d02065833e 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -1136,7 +1136,7 @@ regenerate_master_menu (DOCUMENT *document, int
use_sections)
const ELEMENT *top_node = find_identifier_target (identifiers_target, "Top");
const ELEMENT_LIST *menus;
- ELEMENT *master_menu;
+ ELEMENT *new_detailmenu_e;
ELEMENT *last_menu;
const ELEMENT *last_content;
int i;
@@ -1151,12 +1151,12 @@ regenerate_master_menu (DOCUMENT *document, int
use_sections)
else
return 0;
- master_menu = new_master_menu (document->error_messages,
- document->options, identifiers_target,
- menus, use_sections);
+ new_detailmenu_e = new_detailmenu (document->error_messages,
+ document->options, identifiers_target,
+ menus, use_sections);
/* no need for a master menu */
- if (!master_menu)
+ if (!new_detailmenu_e)
return 0;
document->modified_information |= F_DOCM_tree;
@@ -1173,8 +1173,8 @@ regenerate_master_menu (DOCUMENT *document, int
use_sections)
{
size_t j;
ELEMENT *removed = remove_from_contents (menu, detailmenu_index);
- replace_element_in_list (
- &document->global_commands->detailmenu, removed, master_menu);
+ replace_element_in_list (&document->global_commands->detailmenu,
+ removed, new_detailmenu_e);
/* TODO are the new entries added to internal refs?
Note that if they are not, it is possible that this has
no impact as the associated entry in menu may be
@@ -1210,7 +1210,7 @@ regenerate_master_menu (DOCUMENT *document, int
use_sections)
}
}
destroy_element_and_children (removed);
- insert_into_contents (menu, master_menu, detailmenu_index);
+ insert_into_contents (menu, new_detailmenu_e, detailmenu_index);
return 1;
}
}
@@ -1222,7 +1222,7 @@ regenerate_master_menu (DOCUMENT *document, int
use_sections)
if (last_content && last_content->cmd == CM_end)
index--;
- master_menu->parent = last_menu;
+ new_detailmenu_e->parent = last_menu;
if (index)
{
@@ -1259,8 +1259,9 @@ regenerate_master_menu (DOCUMENT *document, int
use_sections)
}
}
/* insert master menu */
- insert_into_contents (last_menu, master_menu, index);
- add_to_element_list (&document->global_commands->detailmenu, master_menu);
+ insert_into_contents (last_menu, new_detailmenu_e, index);
+ add_to_element_list (&document->global_commands->detailmenu,
+ new_detailmenu_e);
return 1;
}
diff --git a/tp/t/do_master_menu.t b/tp/t/do_master_menu.t
index bdc547cb79..1ea2ff22ac 100644
--- a/tp/t/do_master_menu.t
+++ b/tp/t/do_master_menu.t
@@ -129,7 +129,7 @@
Texinfo::Structuring::associate_internal_references($document);
my $identifier_target = $document->labels_information();
my $top_node = $identifier_target->{'Top'};
# FIXME does not test XS
-my $master_menu = Texinfo::Structuring::new_master_menu($parser,
+my $master_menu = Texinfo::Structuring::new_detailmenu($parser,
$document->registrar(),
$identifier_target,
$top_node->{'extra'}->{'menus'});
@@ -176,7 +176,7 @@
Texinfo::Structuring::associate_internal_references($document);
$identifier_target = $document->labels_information();
$top_node = $identifier_target->{'Top'};
# FIXME does not test XS
-$master_menu = Texinfo::Structuring::new_master_menu($parser,
+$master_menu = Texinfo::Structuring::new_detailmenu($parser,
$document->registrar(),
$identifier_target,
$top_node->{'extra'}->{'menus'});
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Structuring.pm (new_detailmenu), tp/Texinfo/XS/structuring_transfo/structuring.c (new_detailmenu): rename new_master_menu as new_detailmenu, change also variables names. Update callers and variables names in callers.,
Patrice Dumas <=