[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7471] add_missing_menus
From: |
gavinsmith0123 |
Subject: |
[7471] add_missing_menus |
Date: |
Thu, 27 Oct 2016 17:21:14 +0000 (UTC) |
Revision: 7471
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7471
Author: gavin
Date: 2016-10-27 17:21:13 +0000 (Thu, 27 Oct 2016)
Log Message:
-----------
add_missing_menus
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Convert/HTML.pm
trunk/tp/Texinfo/Convert/Plaintext.pm
trunk/tp/Texinfo/Structuring.pm
trunk/tp/t/30sectioning.t
trunk/tp/t/results/sectioning/no_menu.pl
trunk/tp/tests/indices/res_parser/index_special_region/index.html
trunk/tp/tests/indices/res_parser/index_special_region_html/index.html
trunk/tp/tests/indices/res_parser/index_special_region_no_insertcopying/index.html
trunk/tp/tests/indices/res_parser/index_special_region_no_insertcopying_html/index.html
trunk/tp/tests/indices/res_parser/index_special_region_no_region/index.html
trunk/tp/tests/indices/res_parser/index_special_region_no_region_html/index.html
trunk/tp/tests/indices/res_parser_info/index_special_region/index_special_region.info
trunk/tp/tests/indices/res_parser_info/index_special_region_html/index.html
trunk/tp/tests/indices/res_parser_info/index_special_region_no_insertcopying/index_special_region-no_insertcopying.info
trunk/tp/tests/indices/res_parser_info/index_special_region_no_insertcopying_html/index.html
trunk/tp/tests/indices/res_parser_info/index_special_region_no_region/index_special_region-no_section.info
trunk/tp/tests/indices/res_parser_info/index_special_region_no_region_html/index.html
trunk/tp/texi2any.pl
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2016-10-25 18:03:51 UTC (rev 7470)
+++ trunk/ChangeLog 2016-10-27 17:21:13 UTC (rev 7471)
@@ -1,3 +1,27 @@
+2016-10-27 Gavin Smith <address@hidden>
+
+ * tp/texi2any.pl: Remove code for calling 'add_missing_menus' if
+ 'validatemenus' is off. It can add menus incorrectly if all the
+ menus in the node are not recorded, which could be the case
+ for menus incorrectly nested inside another command.
+
+ * tp/Texinfo/Convert/Structuring.pm (add_node_menu_if_missing)
+ Split out new function 'menu_of_node'.
+
+ * tp/Texinfo/Convert/HTML.pm
+ (_convert_menu_command): Record that a menu has been seen in the
+ current node.
+ (_convert_heading_command): If no menu has been seen in the
+ node, call 'menu_of_node' and convert the result.
+
+ * tp/Texinfo/Convert/Plaintext.pm
+ (_menu): Record that a menu has been seen in the current node.
+ (_convert): If no menu has been seen in the node, call
+ menu_of_node and convert the result.
+
+ * tp/t/30sectioning.t (no_menu): Test 'info' format instead of
+ 'plaintext'.
+
2016-10-25 Gavin Smith <address@hidden>
* tp/Texinfo/Convert/Plaintext.pm (count_bytes): Call throughout
Modified: trunk/tp/Texinfo/Convert/HTML.pm
===================================================================
--- trunk/tp/Texinfo/Convert/HTML.pm 2016-10-25 18:03:51 UTC (rev 7470)
+++ trunk/tp/Texinfo/Convert/HTML.pm 2016-10-27 17:21:13 UTC (rev 7471)
@@ -2387,6 +2387,25 @@
}
}
$result .= $content if (defined($content));
+
+ if ($cmdname ne 'node'
+ and $self->{'current_node'}
+ and !$self->{'seenmenus'}->{$self->{'current_node'}}) {
+ $self->{'seenmenus'}->{$self->{'current_node'}} = 1;
+ # Generate a menu for this node.
+ my $menu_text;
+ my $parser = Texinfo::Parser::simple_parser();
+
+ my $menu_node = Texinfo::Structuring::menu_of_node ($parser,
+ $command->{'extra'}{'associated_node'});
+ if ($menu_node) {
+ $menu_text = _convert ($self, $menu_node);
+ if ($menu_text) {
+ $result .= $menu_text;
+ $result .= "\n";
+ }
+ }
+ }
return $result;
}
@@ -2774,6 +2793,9 @@
$begin_row = '<tr><td>';
$end_row = '</td></tr>';
}
+ if ($self->{'current_node'}) {
+ $self->{'seenmenus'}->{$self->{'current_node'}} = 1;
+ }
return $self->_attribute_class('table', 'menu')
." border=\"0\" cellspacing=\"0\">${begin_row}\n"
. $content . "${end_row}</table>\n";
@@ -7551,6 +7573,9 @@
pop @{$self->{'document_context'}};
}
+ if ($root->{'cmdname'} eq 'node') {
+ $self->{'current_node'} = $root;
+ }
# args are formatted, now format the command itself
my $result;
if ($args_formatted) {
Modified: trunk/tp/Texinfo/Convert/Plaintext.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Plaintext.pm 2016-10-25 18:03:51 UTC (rev
7470)
+++ trunk/tp/Texinfo/Convert/Plaintext.pm 2016-10-27 17:21:13 UTC (rev
7471)
@@ -1174,6 +1174,9 @@
my $result = "* Menu:\n\n";
_add_text_count($self, $result);
_add_lines_count($self, 2);
+ if ($self->{'node'}) {
+ $self->{'seenmenus'}->{$self->{'node'}} = 1;
+ }
return $result;
} else {
return '';
@@ -3348,6 +3351,25 @@
}
} elsif (($root->{'cmdname'} eq 'multitable')) {
$self->{'document_context'}->[-1]->{'in_multitable'}--;
+ } elsif ($root_commands{$root->{'cmdname'}}
+ and $sectioning_commands{$root->{'cmdname'}}
+ and $root->{'cmdname'} ne 'part') {
+ # add menu if missing
+ my $node = $self->{'node'};
+ if ($node) {
+ if (!$self->{'seenmenus'}->{$node}) {
+ $self->{'seenmenus'}->{$node} = 1;
+ my $parser = Texinfo::Parser::simple_parser();
+ my $menu_node = Texinfo::Structuring::menu_of_node ($parser, $node);
+ if ($menu_node) {
+ my $menu_text = $self->_convert ($menu_node);
+ if ($menu_text) {
+ $result .= $menu_text;
+ $result .= "\n";
+ }
+ }
+ }
+ }
}
# close the contexts and register the cells
Modified: trunk/tp/Texinfo/Structuring.pm
===================================================================
--- trunk/tp/Texinfo/Structuring.pm 2016-10-25 18:03:51 UTC (rev 7470)
+++ trunk/tp/Texinfo/Structuring.pm 2016-10-27 17:21:13 UTC (rev 7471)
@@ -1621,13 +1621,12 @@
return $new_block;
}
-sub add_node_menu_if_missing($$)
+sub menu_of_node
{
my $self = shift;
my $node = shift;
-
- if (!$node->{'extra'}->{'associated_section'}->{'section_childs'}
- or $node->{'menus'} and @{$node->{'menus'}}) {
+
+ if (!$node->{'extra'}->{'associated_section'}->{'section_childs'}) {
return;
}
@@ -1649,9 +1648,28 @@
push @pending, $entry;
}
- # Add a menu to this node
my $section = $node->{'extra'}->{'associated_section'};
my $current_menu = _new_block_command (address@hidden, $section, 'menu');
+
+ return $current_menu;
+}
+
+
+sub add_node_menu_if_missing($$)
+{
+ my $self = shift;
+ my $node = shift;
+
+ if ($node->{'menus'} and @{$node->{'menus'}}) {
+ return;
+ }
+
+ my $current_menu = menu_of_node($self, $node);
+ if (!$current_menu) {
+ return;
+ }
+
+ my $section = $node->{'extra'}->{'associated_section'};
push @{$section->{'contents'}}, $current_menu;
push @{$section->{'contents'}}, {'type' => 'empty_line',
'text' => "\n",
Modified: trunk/tp/t/30sectioning.t
===================================================================
--- trunk/tp/t/30sectioning.t 2016-10-25 18:03:51 UTC (rev 7470)
+++ trunk/tp/t/30sectioning.t 2016-10-27 17:21:13 UTC (rev 7471)
@@ -1843,7 +1843,7 @@
@node c3
@chapter c3
-', {'test_formats' => ['plaintext', 'html']}
+', {'test_formats' => ['info', 'html']}
],
['contents_at_document_begin',
undef, {'test_file' => 'contents_at_document_begin.texi'}],
Modified: trunk/tp/t/results/sectioning/no_menu.pl
===================================================================
--- trunk/tp/t/results/sectioning/no_menu.pl 2016-10-25 18:03:51 UTC (rev
7470)
+++ trunk/tp/t/results/sectioning/no_menu.pl 2016-10-27 17:21:13 UTC (rev
7471)
@@ -609,15 +609,45 @@
-$result_converted{'plaintext'}->{'no_menu'} = '1 c1
+$result_converted{'info'}->{'no_menu'} = 'This is , produced from .
+
+
+File: , Node: Top, Up: (dir)
+
+* Menu:
+
+* c1::
+* c2::
+* c3::
+
+
+
+File: , Node: c1, Next: c2, Up: Top
+
+1 c1
****
+
+File: , Node: c2, Next: c3, Prev: c1, Up: Top
+
2 c2
****
+
+File: , Node: c3, Prev: c2, Up: Top
+
3 c3
****
+
+
+Tag Table:
+Node: Top27
+Node: c192
+Node: c2145
+Node: c3209
+
+End Tag Table
';
@@ -672,6 +702,15 @@
</div>
<a name="SEC_Top"></a>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top">• <a href="#c1"
accesskey="1">c1</a>:</td><td> </td><td align="left" valign="top">
+</td></tr>
+<tr><td align="left" valign="top">• <a href="#c2"
accesskey="2">c2</a>:</td><td> </td><td align="left" valign="top">
+</td></tr>
+<tr><td align="left" valign="top">• <a href="#c3"
accesskey="3">c3</a>:</td><td> </td><td align="left" valign="top">
+</td></tr>
+</table>
+
<hr>
<a name="c1"></a>
<div class="header">
Modified: trunk/tp/tests/indices/res_parser/index_special_region/index.html
===================================================================
--- trunk/tp/tests/indices/res_parser/index_special_region/index.html
2016-10-25 18:03:51 UTC (rev 7470)
+++ trunk/tp/tests/indices/res_parser/index_special_region/index.html
2016-10-27 17:21:13 UTC (rev 7471)
@@ -62,6 +62,11 @@
</tr></table>
<a name="Top-1"></a>
<h1 class="top">Top</h1>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top"><a
href="Copying-and-indices.html#Copying-and-indices">Appendix A Copying and
indices</a></td><td> </td><td align="left" valign="top">
+</td></tr>
+</table>
+
<hr>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[ < ]</td>
Modified: trunk/tp/tests/indices/res_parser/index_special_region_html/index.html
===================================================================
--- trunk/tp/tests/indices/res_parser/index_special_region_html/index.html
2016-10-25 18:03:51 UTC (rev 7470)
+++ trunk/tp/tests/indices/res_parser/index_special_region_html/index.html
2016-10-27 17:21:13 UTC (rev 7471)
@@ -105,6 +105,11 @@
</tr></table>
<a name="Top-1"></a>
<h1 class="top">Top</h1>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top"><a
href="Copying-and-indices.html#Copying-and-indices">Appendix A Copying and
indices</a></td><td> </td><td align="left" valign="top">
+</td></tr>
+</table>
+
<hr>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[ < ]</td>
Modified:
trunk/tp/tests/indices/res_parser/index_special_region_no_insertcopying/index.html
===================================================================
---
trunk/tp/tests/indices/res_parser/index_special_region_no_insertcopying/index.html
2016-10-25 18:03:51 UTC (rev 7470)
+++
trunk/tp/tests/indices/res_parser/index_special_region_no_insertcopying/index.html
2016-10-27 17:21:13 UTC (rev 7471)
@@ -62,6 +62,11 @@
</tr></table>
<a name="Top-1"></a>
<h1 class="top">Top</h1>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top"><a
href="Copying-and-indices.html#Copying-and-indices">Appendix A Copying and
indices</a></td><td> </td><td align="left" valign="top">
+</td></tr>
+</table>
+
<hr>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[ < ]</td>
Modified:
trunk/tp/tests/indices/res_parser/index_special_region_no_insertcopying_html/index.html
===================================================================
---
trunk/tp/tests/indices/res_parser/index_special_region_no_insertcopying_html/index.html
2016-10-25 18:03:51 UTC (rev 7470)
+++
trunk/tp/tests/indices/res_parser/index_special_region_no_insertcopying_html/index.html
2016-10-27 17:21:13 UTC (rev 7471)
@@ -105,6 +105,11 @@
</tr></table>
<a name="Top-1"></a>
<h1 class="top">Top</h1>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top"><a
href="Copying-and-indices.html#Copying-and-indices">Appendix A Copying and
indices</a></td><td> </td><td align="left" valign="top">
+</td></tr>
+</table>
+
<hr>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[ < ]</td>
Modified:
trunk/tp/tests/indices/res_parser/index_special_region_no_region/index.html
===================================================================
--- trunk/tp/tests/indices/res_parser/index_special_region_no_region/index.html
2016-10-25 18:03:51 UTC (rev 7470)
+++ trunk/tp/tests/indices/res_parser/index_special_region_no_region/index.html
2016-10-27 17:21:13 UTC (rev 7471)
@@ -63,6 +63,11 @@
<a name="Top-1"></a>
<h1 class="top">Top</h1>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top"><a
href="Copying-and-indices.html#Copying-and-indices">Appendix A Copying and
indices</a></td><td> </td><td align="left" valign="top">
+</td></tr>
+</table>
+
<hr>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[ < ]</td>
Modified:
trunk/tp/tests/indices/res_parser/index_special_region_no_region_html/index.html
===================================================================
---
trunk/tp/tests/indices/res_parser/index_special_region_no_region_html/index.html
2016-10-25 18:03:51 UTC (rev 7470)
+++
trunk/tp/tests/indices/res_parser/index_special_region_no_region_html/index.html
2016-10-27 17:21:13 UTC (rev 7471)
@@ -106,6 +106,11 @@
<a name="Top-1"></a>
<h1 class="top">Top</h1>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top"><a
href="Copying-and-indices.html#Copying-and-indices">Appendix A Copying and
indices</a></td><td> </td><td align="left" valign="top">
+</td></tr>
+</table>
+
<hr>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[ < ]</td>
Modified:
trunk/tp/tests/indices/res_parser_info/index_special_region/index_special_region.info
===================================================================
---
trunk/tp/tests/indices/res_parser_info/index_special_region/index_special_region.info
2016-10-25 18:03:51 UTC (rev 7470)
+++
trunk/tp/tests/indices/res_parser_info/index_special_region/index_special_region.info
2016-10-27 17:21:13 UTC (rev 7471)
@@ -18,6 +18,11 @@
Top
***
+* Menu:
+
+* Copying and indices::
+
+
1 Chapter
*********
@@ -26,8 +31,8 @@
[index ]
* Menu:
-* Copying appendix: Copying and indices. (line 4)
-* Copying this document: Top. (line 9)
+* Copying appendix: Copying and indices. (line 4)
+* Copying this document: Top. (line 13)
This test demonstrates @anchor and indices in @copying and titlepage,
and various wrong index entries.
@@ -68,21 +73,21 @@
* Copying appendix: Copying and indices. (line 8)
* Copying this document: Copying and indices. (line 14)
-* Public domain: Top. (line 33)
+* Public domain: Top. (line 37)
[index ]
* Menu:
* Copying appendix: Copying and indices. (line 8)
* Copying this document: Copying and indices. (line 14)
-* Public domain: Top. (line 33)
+* Public domain: Top. (line 37)
[index ]
* Menu:
* another fun: Copying and indices. (line 8)
-* findex entry: Top. (line 20)
-* fun: Top. (line 24)
+* findex entry: Top. (line 24)
+* fun: Top. (line 28)
---------- Footnotes ----------
@@ -92,10 +97,10 @@
Tag Table:
Node: Top366
-Ref: Copying information483
-Ref: Top-Footnote-1934
-Ref: Public domain reference941
-Node: Copying and indices998
-Ref: Copying and indices-Footnote-12276
+Ref: Copying information517
+Ref: Top-Footnote-1968
+Ref: Public domain reference975
+Node: Copying and indices1032
+Ref: Copying and indices-Footnote-12310
End Tag Table
Modified:
trunk/tp/tests/indices/res_parser_info/index_special_region_html/index.html
===================================================================
--- trunk/tp/tests/indices/res_parser_info/index_special_region_html/index.html
2016-10-25 18:03:51 UTC (rev 7470)
+++ trunk/tp/tests/indices/res_parser_info/index_special_region_html/index.html
2016-10-27 17:21:13 UTC (rev 7471)
@@ -63,6 +63,11 @@
</div>
<a name="Top-1"></a>
<h1 class="top">Top</h1>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top">• <a
href="Copying-and-indices.html#Copying-and-indices" accesskey="1">Copying and
indices</a>:</td><td> </td><td align="left" valign="top">
+</td></tr>
+</table>
+
<a name="Chapter"></a>
<h2 class="chapter">1 Chapter</h2>
Modified:
trunk/tp/tests/indices/res_parser_info/index_special_region_no_insertcopying/index_special_region-no_insertcopying.info
===================================================================
---
trunk/tp/tests/indices/res_parser_info/index_special_region_no_insertcopying/index_special_region-no_insertcopying.info
2016-10-25 18:03:51 UTC (rev 7470)
+++
trunk/tp/tests/indices/res_parser_info/index_special_region_no_insertcopying/index_special_region-no_insertcopying.info
2016-10-27 17:21:13 UTC (rev 7471)
@@ -18,6 +18,11 @@
Top
***
+* Menu:
+
+* Copying and indices::
+
+
1 Chapter
*********
@@ -57,13 +62,13 @@
* Menu:
* another fun: Copying and indices. (line 8)
-* findex entry: Top. (line 12)
-* fun: Top. (line 16)
+* findex entry: Top. (line 16)
+* fun: Top. (line 20)
Tag Table:
Node: Top400
-Node: Copying and indices704
+Node: Copying and indices738
End Tag Table
Modified:
trunk/tp/tests/indices/res_parser_info/index_special_region_no_insertcopying_html/index.html
===================================================================
---
trunk/tp/tests/indices/res_parser_info/index_special_region_no_insertcopying_html/index.html
2016-10-25 18:03:51 UTC (rev 7470)
+++
trunk/tp/tests/indices/res_parser_info/index_special_region_no_insertcopying_html/index.html
2016-10-27 17:21:13 UTC (rev 7471)
@@ -62,6 +62,11 @@
</div>
<a name="Top-1"></a>
<h1 class="top">Top</h1>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top">• <a
href="Copying-and-indices.html#Copying-and-indices" accesskey="1">Copying and
indices</a>:</td><td> </td><td align="left" valign="top">
+</td></tr>
+</table>
+
<a name="Chapter"></a>
<h2 class="chapter">1 Chapter</h2>
Modified:
trunk/tp/tests/indices/res_parser_info/index_special_region_no_region/index_special_region-no_section.info
===================================================================
---
trunk/tp/tests/indices/res_parser_info/index_special_region_no_region/index_special_region-no_section.info
2016-10-25 18:03:51 UTC (rev 7470)
+++
trunk/tp/tests/indices/res_parser_info/index_special_region_no_region/index_special_region-no_section.info
2016-10-27 17:21:13 UTC (rev 7471)
@@ -18,6 +18,11 @@
Top
***
+* Menu:
+
+* Copying and indices::
+
+
1 Chapter
*********
@@ -57,13 +62,13 @@
* Menu:
* another fun: Copying and indices. (line 8)
-* findex entry: Top. (line 12)
-* fun: Top. (line 16)
+* findex entry: Top. (line 16)
+* fun: Top. (line 20)
Tag Table:
Node: Top387
-Node: Copying and indices685
+Node: Copying and indices719
End Tag Table
Modified:
trunk/tp/tests/indices/res_parser_info/index_special_region_no_region_html/index.html
===================================================================
---
trunk/tp/tests/indices/res_parser_info/index_special_region_no_region_html/index.html
2016-10-25 18:03:51 UTC (rev 7470)
+++
trunk/tp/tests/indices/res_parser_info/index_special_region_no_region_html/index.html
2016-10-27 17:21:13 UTC (rev 7471)
@@ -63,6 +63,11 @@
<a name="Top-1"></a>
<h1 class="top">Top</h1>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top">• <a
href="Copying-and-indices.html#Copying-and-indices" accesskey="1">Copying and
indices</a>:</td><td> </td><td align="left" valign="top">
+</td></tr>
+</table>
+
<a name="Chapter"></a>
<h2 class="chapter">1 Chapter</h2>
Modified: trunk/tp/texi2any.pl
===================================================================
--- trunk/tp/texi2any.pl 2016-10-25 18:03:51 UTC (rev 7470)
+++ trunk/tp/texi2any.pl 2016-10-27 17:21:13 UTC (rev 7471)
@@ -1309,8 +1309,6 @@
if ($tree_transformations{'complete_tree_nodes_menus'}) {
Texinfo::Structuring::complete_tree_nodes_menus($parser, $tree);
- } elsif (!$parser->{'validatemenus'}) {
- Texinfo::Structuring::add_missing_menus($parser, $tree);
}
if ($tree_transformations{'regenerate_master_menu'}) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7471] add_missing_menus,
gavinsmith0123 <=