[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 8 Nov 2022 03:29:29 -0500 (EST) |
branch: master
commit 6fcdfa52a832214ba93efc89a1bcd932daff66f9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Nov 5 18:44:53 2022 +0100
* tp/Texinfo/Structuring.pm (check_nodes_are_referenced): consider
that a node is referenced if it appears in a manu that would be
setup automatically. That is if a node has automatic direction,
no menu, all the children determined by automatic directions are
considered to be referenced.
(get_node_node_childs_from_sectioning): avoid spurious
auto-vivification.
---
ChangeLog | 10 +
tp/Texinfo/Structuring.pm | 27 +-
tp/t/30sectioning.t | 10 +
.../init_files_tests/customize_translations.pl | 12 +-
.../sectioning/automatic_menu_referencing_node.pl | 462 +++++++++++++++++++++
5 files changed, 506 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 30576ea853..ac9e8c9cc2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-11-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Structuring.pm (check_nodes_are_referenced): consider
+ that a node is referenced if it appears in a manu that would be
+ setup automatically. That is if a node has automatic direction,
+ no menu, all the children determined by automatic directions are
+ considered to be referenced.
+ (get_node_node_childs_from_sectioning): avoid spurious
+ auto-vivification.
+
2022-11-04 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Common.pm (pgdt): add pgdt that does nothing to
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 7879a6ffa6..9950f30947 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -417,6 +417,18 @@ sub check_nodes_are_referenced
if ($node->{'structure'}->{'menu_up_hash'}) {
$referenced_nodes{$node} = 1;
}
+ # If an automatic menu can be setup, consider that all
+ # the nodes appearing in the automatic menu are referenced.
+ # Note that the menu may not be actually setup, but
+ # it is better not to warn for nothing.
+ if ((scalar(@{$node->{'extra'}->{'nodes_manuals'}}) == 1)
+ and (not $node->{'extra'}->{'menus'}
+ or not scalar(@{$node->{'extra'}->{'menus'}}))) {
+ my @node_childs = get_node_node_childs_from_sectioning($node);
+ foreach my $node_child (@node_childs) {
+ $referenced_nodes{$node_child} = 1;
+ }
+ }
}
# consider nodes in @*ref commands to be referenced
@@ -1470,7 +1482,10 @@ sub get_node_node_childs_from_sectioning
my @node_childs;
- if
($node->{'extra'}->{'associated_section'}->{'structure'}->{'section_childs'}) {
+ if ($node->{'extra'}
+ and $node->{'extra'}->{'associated_section'}
+ and $node->{'extra'}->{'associated_section'}->{'structure'}
+ and
$node->{'extra'}->{'associated_section'}->{'structure'}->{'section_childs'}) {
foreach my $child
(@{$node->{'extra'}->{'associated_section'}->{'structure'}->{'section_childs'}})
{
if ($child->{'extra'} and $child->{'extra'}->{'associated_node'}) {
push @node_childs, $child->{'extra'}->{'associated_node'};
@@ -1479,9 +1494,12 @@ sub get_node_node_childs_from_sectioning
}
# Special case for @top. Gather all the children of the @part following
# @top.
- if ($node->{'extra'}->{'associated_section'}->{'cmdname'} eq 'top') {
+ if ($node->{'extra'}
+ and $node->{'extra'}->{'associated_section'}
+ and $node->{'extra'}->{'associated_section'}->{'cmdname'} eq 'top') {
my $current = $node->{'extra'}->{'associated_section'};
- while ($current->{'structure'}->{'section_next'}) {
+ while ($current->{'structure'}
+ and $current->{'structure'}->{'section_next'}) {
$current = $current->{'structure'}->{'section_next'};
if ($current->{'cmdname'} and $current->{'cmdname'} eq 'part'
and $current->{'structure'}->{'section_childs'}) {
@@ -1490,7 +1508,8 @@ sub get_node_node_childs_from_sectioning
push @node_childs, $child->{'extra'}->{'associated_node'};
}
}
- } elsif ($current->{'extra'}->{'associated_node'}) {
+ } elsif ($current->{'extra'}
+ and $current->{'extra'}->{'associated_node'}) {
# for @appendix, and what follows, as it stops a @part, but is
# not below @top
push @node_childs, $current->{'extra'}->{'associated_node'};
diff --git a/tp/t/30sectioning.t b/tp/t/30sectioning.t
index 4dd30bcee7..a957e259da 100644
--- a/tp/t/30sectioning.t
+++ b/tp/t/30sectioning.t
@@ -1321,6 +1321,16 @@ $unnumbered_top_without_node_text,
@ref{@asis{(}manual2) name2}.
'],
+['automatic_menu_referencing_node',
+'@node Top
+@top top
+
+@node Chapter
+@chapter chap
+
+@node section
+@section sec
+']
);
my $complex_case = '@node Top,First node,(dir)
diff --git a/tp/t/results/init_files_tests/customize_translations.pl
b/tp/t/results/init_files_tests/customize_translations.pl
index 53d28f4a38..0d403940fc 100644
--- a/tp/t/results/init_files_tests/customize_translations.pl
+++ b/tp/t/results/init_files_tests/customize_translations.pl
@@ -899,17 +899,7 @@ $result_menus{'customize_translations'} = {
'structure' => {}
};
-$result_errors{'customize_translations'} = [
- {
- 'error_line' => 'warning: node `section fr\' unreferenced
-',
- 'file_name' => '',
- 'line_nr' => 18,
- 'macro' => '',
- 'text' => 'node `section fr\' unreferenced',
- 'type' => 'warning'
- }
-];
+$result_errors{'customize_translations'} = [];
$result_floats{'customize_translations'} = {};
diff --git a/tp/t/results/sectioning/automatic_menu_referencing_node.pl
b/tp/t/results/sectioning/automatic_menu_referencing_node.pl
new file mode 100644
index 0000000000..113f9cd748
--- /dev/null
+++ b/tp/t/results/sectioning/automatic_menu_referencing_node.pl
@@ -0,0 +1,462 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors
+ %result_indices %result_sectioning %result_nodes %result_menus
+ %result_floats %result_converted %result_converted_errors
+ %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'automatic_menu_referencing_node'} = {
+ 'contents' => [
+ {
+ 'type' => 'before_node_section'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'Top'
+ }
+ ],
+ 'extra' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'node_content' => [
+ {}
+ ],
+ 'nodes_manuals' => [
+ {
+ 'node_content' => [
+ {}
+ ],
+ 'normalized' => 'Top'
+ }
+ ],
+ 'normalized' => 'Top',
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'top'
+ }
+ ],
+ 'extra' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'top',
+ 'contents' => [
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ }
+ ],
+ 'extra' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 2,
+ 'macro' => ''
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'Chapter'
+ }
+ ],
+ 'extra' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'node_content' => [
+ {}
+ ],
+ 'nodes_manuals' => [
+ {
+ 'node_content' => [
+ {}
+ ],
+ 'normalized' => 'Chapter'
+ }
+ ],
+ 'normalized' => 'Chapter',
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 4,
+ 'macro' => ''
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'chap'
+ }
+ ],
+ 'extra' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'chapter',
+ 'contents' => [
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ }
+ ],
+ 'extra' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 5,
+ 'macro' => ''
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'section'
+ }
+ ],
+ 'extra' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'node_content' => [
+ {}
+ ],
+ 'nodes_manuals' => [
+ {
+ 'node_content' => [
+ {}
+ ],
+ 'normalized' => 'section'
+ }
+ ],
+ 'normalized' => 'section',
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 7,
+ 'macro' => ''
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'sec'
+ }
+ ],
+ 'extra' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'section',
+ 'extra' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 8,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'type' => 'document_root'
+};
+$result_trees{'automatic_menu_referencing_node'}{'contents'}[1]{'extra'}{'node_content'}[0]
=
$result_trees{'automatic_menu_referencing_node'}{'contents'}[1]{'args'}[0]{'contents'}[0];
+$result_trees{'automatic_menu_referencing_node'}{'contents'}[1]{'extra'}{'nodes_manuals'}[0]{'node_content'}[0]
=
$result_trees{'automatic_menu_referencing_node'}{'contents'}[1]{'args'}[0]{'contents'}[0];
+$result_trees{'automatic_menu_referencing_node'}{'contents'}[3]{'extra'}{'node_content'}[0]
=
$result_trees{'automatic_menu_referencing_node'}{'contents'}[3]{'args'}[0]{'contents'}[0];
+$result_trees{'automatic_menu_referencing_node'}{'contents'}[3]{'extra'}{'nodes_manuals'}[0]{'node_content'}[0]
=
$result_trees{'automatic_menu_referencing_node'}{'contents'}[3]{'args'}[0]{'contents'}[0];
+$result_trees{'automatic_menu_referencing_node'}{'contents'}[5]{'extra'}{'node_content'}[0]
=
$result_trees{'automatic_menu_referencing_node'}{'contents'}[5]{'args'}[0]{'contents'}[0];
+$result_trees{'automatic_menu_referencing_node'}{'contents'}[5]{'extra'}{'nodes_manuals'}[0]{'node_content'}[0]
=
$result_trees{'automatic_menu_referencing_node'}{'contents'}[5]{'args'}[0]{'contents'}[0];
+
+$result_texis{'automatic_menu_referencing_node'} = '@node Top
+@top top
+
+@node Chapter
+@chapter chap
+
+@node section
+@section sec
+';
+
+
+$result_texts{'automatic_menu_referencing_node'} = 'top
+***
+
+1 chap
+******
+
+1.1 sec
+=======
+';
+
+$result_sectioning{'automatic_menu_referencing_node'} = {
+ 'structure' => {
+ 'section_childs' => [
+ {
+ 'cmdname' => 'top',
+ 'extra' => {
+ 'associated_node' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'normalized' => 'Top'
+ },
+ 'structure' => {}
+ }
+ },
+ 'structure' => {
+ 'section_childs' => [
+ {
+ 'cmdname' => 'chapter',
+ 'extra' => {
+ 'associated_node' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'normalized' => 'Chapter'
+ },
+ 'structure' => {}
+ }
+ },
+ 'structure' => {
+ 'section_childs' => [
+ {
+ 'cmdname' => 'section',
+ 'extra' => {
+ 'associated_node' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'normalized' => 'section'
+ },
+ 'structure' => {}
+ }
+ },
+ 'structure' => {
+ 'section_level' => 2,
+ 'section_number' => '1.1',
+ 'section_up' => {}
+ }
+ }
+ ],
+ 'section_level' => 1,
+ 'section_number' => 1,
+ 'section_up' => {},
+ 'toplevel_prev' => {},
+ 'toplevel_up' => {}
+ }
+ }
+ ],
+ 'section_level' => 0,
+ 'section_up' => {}
+ }
+ }
+ ],
+ 'section_level' => -1
+ }
+};
+$result_sectioning{'automatic_menu_referencing_node'}{'structure'}{'section_childs'}[0]{'structure'}{'section_childs'}[0]{'structure'}{'section_childs'}[0]{'structure'}{'section_up'}
=
$result_sectioning{'automatic_menu_referencing_node'}{'structure'}{'section_childs'}[0]{'structure'}{'section_childs'}[0];
+$result_sectioning{'automatic_menu_referencing_node'}{'structure'}{'section_childs'}[0]{'structure'}{'section_childs'}[0]{'structure'}{'section_up'}
=
$result_sectioning{'automatic_menu_referencing_node'}{'structure'}{'section_childs'}[0];
+$result_sectioning{'automatic_menu_referencing_node'}{'structure'}{'section_childs'}[0]{'structure'}{'section_childs'}[0]{'structure'}{'toplevel_prev'}
=
$result_sectioning{'automatic_menu_referencing_node'}{'structure'}{'section_childs'}[0];
+$result_sectioning{'automatic_menu_referencing_node'}{'structure'}{'section_childs'}[0]{'structure'}{'section_childs'}[0]{'structure'}{'toplevel_up'}
=
$result_sectioning{'automatic_menu_referencing_node'}{'structure'}{'section_childs'}[0];
+$result_sectioning{'automatic_menu_referencing_node'}{'structure'}{'section_childs'}[0]{'structure'}{'section_up'}
= $result_sectioning{'automatic_menu_referencing_node'};
+
+$result_nodes{'automatic_menu_referencing_node'} = {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'associated_section' => {
+ 'cmdname' => 'top',
+ 'extra' => {},
+ 'structure' => {}
+ },
+ 'normalized' => 'Top'
+ },
+ 'structure' => {
+ 'node_next' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'associated_section' => {
+ 'cmdname' => 'chapter',
+ 'extra' => {},
+ 'structure' => {
+ 'section_number' => 1
+ }
+ },
+ 'normalized' => 'Chapter'
+ },
+ 'structure' => {
+ 'node_prev' => {},
+ 'node_up' => {}
+ }
+ }
+ }
+};
+$result_nodes{'automatic_menu_referencing_node'}{'structure'}{'node_next'}{'structure'}{'node_prev'}
= $result_nodes{'automatic_menu_referencing_node'};
+$result_nodes{'automatic_menu_referencing_node'}{'structure'}{'node_next'}{'structure'}{'node_up'}
= $result_nodes{'automatic_menu_referencing_node'};
+
+$result_menus{'automatic_menu_referencing_node'} = {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'normalized' => 'Top'
+ },
+ 'structure' => {}
+};
+
+$result_errors{'automatic_menu_referencing_node'} = [];
+
+
+$result_floats{'automatic_menu_referencing_node'} = {};
+
+
+
+$result_converted{'info'}->{'automatic_menu_referencing_node'} = 'This is ,
produced from .
+
+
+File: , Node: Top, Next: Chapter, Up: (dir)
+
+top
+***
+
+* Menu:
+
+* Chapter::
+
+
+File: , Node: Chapter, Prev: Top, Up: Top
+
+1 chap
+******
+
+* Menu:
+
+* section::
+
+
+File: , Node: section, Up: Chapter
+
+1.1 sec
+=======
+
+
+
+Tag Table:
+Node: Top27
+Node: Chapter108
+Node: section193
+
+End Tag Table
+
+
+Local Variables:
+coding: utf-8
+End:
+';
+
+
+$result_converted{'html'}->{'automatic_menu_referencing_node'} = '<!DOCTYPE
html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>top</title>
+
+<meta name="description" content="top">
+<meta name="keywords" content="top">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<link href="#Top" rel="start" title="Top">
+
+
+</head>
+
+<body lang="en">
+<div class="top-level-extent" id="Top">
+<div class="nav-panel">
+<p>
+Next: <a href="#Chapter" accesskey="n" rel="next">chap</a> </p>
+</div>
+<h1 class="top" id="top">top</h1>
+
+<ul class="mini-toc">
+<li><a href="#Chapter" accesskey="1">chap</a></li>
+</ul>
+<hr>
+<div class="chapter-level-extent" id="Chapter">
+<div class="nav-panel">
+<p>
+Previous: <a href="#Top" accesskey="p" rel="prev">top</a>, Up: <a href="#Top"
accesskey="u" rel="up">top</a> </p>
+</div>
+<h2 class="chapter" id="chap">1 chap</h2>
+
+<ul class="mini-toc">
+<li><a href="#section" accesskey="1">sec</a></li>
+</ul>
+<hr>
+<div class="section-level-extent" id="section">
+<div class="nav-panel">
+<p>
+Up: <a href="#Chapter" accesskey="u" rel="up">chap</a> </p>
+</div>
+<h3 class="section" id="sec">1.1 sec</h3>
+</div>
+</div>
+</div>
+
+
+
+</body>
+</html>
+';
+
+1;
- [no subject], (continued)
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject],
Patrice Dumas <=
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08