[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5556] * Texinfo/Parser.pm, Texinfo/Structuring.pm( warn_non_emp
From: |
Patrice Dumas |
Subject: |
[5556] * Texinfo/Parser.pm, Texinfo/Structuring.pm( warn_non_empty_parts), |
Date: |
Sun, 11 May 2014 19:37:36 +0000 |
Revision: 5556
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5556
Author: pertusus
Date: 2014-05-11 19:37:36 +0000 (Sun, 11 May 2014)
Log Message:
-----------
* Texinfo/Parser.pm, Texinfo/Structuring.pm(warn_non_empty_parts),
t/test_utils.pl, texi2any.pl: warning for @part with text.
* tp/Texinfo/Convert/DocBook.pm: add <partintro> for non empty
@part text. Report from Aharon Robbins.
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Convert/DocBook.pm
trunk/tp/Texinfo/Parser.pm
trunk/tp/Texinfo/Structuring.pm
trunk/tp/t/results/sectioning/double_part.pl
trunk/tp/t/results/sectioning/section_before_part.pl
trunk/tp/t/test_utils.pl
trunk/tp/tests/indices/res_parser/printindex_between_part_chapter/printindex_between_part_chapter.2
trunk/tp/tests/indices/res_parser_info/printindex_between_part_chapter/printindex_between_part_chapter.2
trunk/tp/texi2any.pl
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-05-11 19:09:27 UTC (rev 5555)
+++ trunk/ChangeLog 2014-05-11 19:37:36 UTC (rev 5556)
@@ -1,3 +1,10 @@
+2014-05-11 Patrice Dumas <address@hidden>
+
+ * Texinfo/Parser.pm, Texinfo/Structuring.pm(warn_non_empty_parts),
+ t/test_utils.pl, texi2any.pl: warning for @part with text.
+ * tp/Texinfo/Convert/DocBook.pm: add <partintro> for non empty
+ @part text. Report from Aharon Robbins.
+
2014-05-11 Gavin Smith <address@hidden>
* info/info.c (add_initial_nodes): When following menus, start at
Modified: trunk/tp/Texinfo/Convert/DocBook.pm
===================================================================
--- trunk/tp/Texinfo/Convert/DocBook.pm 2014-05-11 19:09:27 UTC (rev 5555)
+++ trunk/tp/Texinfo/Convert/DocBook.pm 2014-05-11 19:37:36 UTC (rev 5556)
@@ -631,6 +631,9 @@
chomp ($result);
$result .= "\n";
}
+ if ($command eq 'part' and
!Texinfo::Common::is_content_empty($root)) {
+ $result .= "<partintro>\n";
+ }
} elsif ($Texinfo::Common::sectioning_commands{$root->{'cmdname'}}) {
if ($root->{'args'} and $root->{'args'}->[0]) {
my ($arg, $end_line)
@@ -1306,6 +1309,9 @@
$root = $root->{'extra'}->{'element_command'};
}
my $command = $self->_docbook_section_element($root);
+ if ($command eq 'part' and !Texinfo::Common::is_content_empty($root)) {
+ $result .= "</partintro>\n";
+ }
my $command_texi = $self->_level_corrected_section($root);
if (!($root->{'section_childs'} and scalar(@{$root->{'section_childs'}}))
or $command_texi eq 'top') {
Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm 2014-05-11 19:09:27 UTC (rev 5555)
+++ trunk/tp/Texinfo/Parser.pm 2014-05-11 19:37:36 UTC (rev 5556)
@@ -278,7 +278,7 @@
my %global_multiple_commands;
foreach my $global_multiple_command (
'author', 'footnote', 'hyphenation', 'insertcopying', 'printindex',
- 'subtitle','titlefont', 'listoffloats', 'detailmenu',
+ 'subtitle','titlefont', 'listoffloats', 'detailmenu', 'part',
keys(%Texinfo::Common::document_settable_at_commands), ) {
$global_multiple_commands{$global_multiple_command} = 1;
}
Modified: trunk/tp/Texinfo/Structuring.pm
===================================================================
--- trunk/tp/Texinfo/Structuring.pm 2014-05-11 19:09:27 UTC (rev 5555)
+++ trunk/tp/Texinfo/Structuring.pm 2014-05-11 19:37:36 UTC (rev 5556)
@@ -61,6 +61,7 @@
split_by_node
split_by_section
split_pages
+ warn_non_empty_parts
) ] );
@EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
@@ -249,7 +250,7 @@
}
} else {
my $up = $previous_section->{'section_up'};
- my $new_upper_element;
+ my $new_upper_part_element;
if ($previous_section->{'level'} != $level) {
# means it is above the previous command, the up is to be found
while ($up->{'section_up'} and $up->{'level'} >= $level) {
@@ -257,7 +258,7 @@
}
if ($level <= $up->{'level'}) {
if ($content->{'cmdname'} eq 'part') {
- $new_upper_element = 1;
+ $new_upper_part_element = 1;
if ($level < $up->{'level'}) {
$self->line_warn(sprintf($self->__(
"no chapter-level command before address@hidden"),
@@ -276,7 +277,7 @@
and $up->{'cmdname'} and $up->{'cmdname'} eq 'part') {
$up = $up->{'section_up'};
}
- if ($new_upper_element) {
+ if ($new_upper_part_element) {
# In that case the root has to be updated because the first
# 'part' just appeared
$content->{'section_up'} = $sec_root;
@@ -496,6 +497,20 @@
return (address@hidden, address@hidden);
}
+sub warn_non_empty_parts($)
+{
+ my $self = shift;
+ my $global_commands = $self->global_commands_information();
+ if ($global_commands->{'part'}) {
+ foreach my $part (@{$global_commands->{'part'}}) {
+ if (!Texinfo::Common::is_content_empty($part)) {
+ $self->line_warn(sprintf($self->__("address@hidden not empty"),
+ $part->{'cmdname'}), $part->{'line_nr'});
+ }
+ }
+ }
+}
+
sub _check_node_same_texinfo_code($$)
{
my $reference_node = shift;
@@ -2215,7 +2230,7 @@
It is also possible to group the top-level contents of the tree, which consist
in nodes and sectioning commands into elements that group together a node and
the next sectioning element. With C<split_by_node> nodes are considered
-to be the main sectionning elements, while with C<split_by_section> the
+to be the main sectioning elements, while with C<split_by_section> the
sectioning command elements are the main elements. The first mode is typical
of Info format, while the second correspond to a traditional book.
The elements may be further split in I<pages>, which are not pages as
@@ -2333,6 +2348,10 @@
Set the I<label> key in the I<extra> hash of the reference tree
element to the associated labeled tree element.
+=item warn_non_empty_parts($parser)
+
+Register a warning in C<$parser> for each C<@part> that is not empty.
+
=item $elements = split_by_node($tree)
Returns a reference array of elements where a node is associated to
Modified: trunk/tp/t/results/sectioning/double_part.pl
===================================================================
--- trunk/tp/t/results/sectioning/double_part.pl 2014-05-11 19:09:27 UTC
(rev 5555)
+++ trunk/tp/t/results/sectioning/double_part.pl 2014-05-11 19:37:36 UTC
(rev 5556)
@@ -765,7 +765,26 @@
};
$result_menus{'double_part'}{'menu_child'}{'menu_up'} =
$result_menus{'double_part'};
-$result_errors{'double_part'} = [];
+$result_errors{'double_part'} = [
+ {
+ 'error_line' => ':8: warning: @part not empty
+',
+ 'file_name' => '',
+ 'line_nr' => 8,
+ 'macro' => '',
+ 'text' => '@part not empty',
+ 'type' => 'warning'
+ },
+ {
+ 'error_line' => ':11: warning: @part not empty
+',
+ 'file_name' => '',
+ 'line_nr' => 11,
+ 'macro' => '',
+ 'text' => '@part not empty',
+ 'type' => 'warning'
+ }
+];
$result_elements{'double_part'} = [
Modified: trunk/tp/t/results/sectioning/section_before_part.pl
===================================================================
--- trunk/tp/t/results/sectioning/section_before_part.pl 2014-05-11
19:09:27 UTC (rev 5555)
+++ trunk/tp/t/results/sectioning/section_before_part.pl 2014-05-11
19:37:36 UTC (rev 5556)
@@ -210,6 +210,15 @@
'macro' => '',
'text' => 'no sectioning command associated with @part',
'type' => 'warning'
+ },
+ {
+ 'error_line' => ':3: warning: @part not empty
+',
+ 'file_name' => '',
+ 'line_nr' => 3,
+ 'macro' => '',
+ 'text' => '@part not empty',
+ 'type' => 'warning'
}
];
Modified: trunk/tp/t/test_utils.pl
===================================================================
--- trunk/tp/t/test_utils.pl 2014-05-11 19:09:27 UTC (rev 5555)
+++ trunk/tp/t/test_utils.pl 2014-05-11 19:37:36 UTC (rev 5556)
@@ -716,6 +716,9 @@
my $floats = $parser->floats_information();
my $structure = Texinfo::Structuring::sectioning_structure($parser, $result);
+ if ($structure) {
+ Texinfo::Structuring::warn_non_empty_parts($parser);
+ }
Texinfo::Structuring::number_floats($floats);
Modified:
trunk/tp/tests/indices/res_parser/printindex_between_part_chapter/printindex_between_part_chapter.2
===================================================================
---
trunk/tp/tests/indices/res_parser/printindex_between_part_chapter/printindex_between_part_chapter.2
2014-05-11 19:09:27 UTC (rev 5555)
+++
trunk/tp/tests/indices/res_parser/printindex_between_part_chapter/printindex_between_part_chapter.2
2014-05-11 19:37:36 UTC (rev 5556)
@@ -0,0 +1 @@
+printindex_between_part_chapter.texi:31: warning: @part not empty
Modified:
trunk/tp/tests/indices/res_parser_info/printindex_between_part_chapter/printindex_between_part_chapter.2
===================================================================
---
trunk/tp/tests/indices/res_parser_info/printindex_between_part_chapter/printindex_between_part_chapter.2
2014-05-11 19:09:27 UTC (rev 5555)
+++
trunk/tp/tests/indices/res_parser_info/printindex_between_part_chapter/printindex_between_part_chapter.2
2014-05-11 19:37:36 UTC (rev 5556)
@@ -0,0 +1 @@
+printindex_between_part_chapter.texi:31: warning: @part not empty
Modified: trunk/tp/texi2any.pl
===================================================================
--- trunk/tp/texi2any.pl 2014-05-11 19:09:27 UTC (rev 5555)
+++ trunk/tp/texi2any.pl 2014-05-11 19:37:36 UTC (rev 5556)
@@ -1213,7 +1213,7 @@
}
if (defined(get_conf('MACRO_EXPAND')) and $file_number == 0) {
- my $texinfo_text = Texinfo::Convert::Texinfo::convert ($tree, 1);
+ my $texinfo_text = Texinfo::Convert::Texinfo::convert($tree, 1);
#print STDERR "$texinfo_text\n";
my $macro_expand_file = get_conf('MACRO_EXPAND');
my $macro_expand_fh = Texinfo::Common::open_out($parser,
@@ -1266,6 +1266,12 @@
# done before dumping the tree?
my $structure = Texinfo::Structuring::sectioning_structure($parser, $tree);
+ if ($structure) {
+ # FIXME allow suppressing this warning, for formats that in fact allow
+ # for non emptyt parts (HTML, DocBook)?
+ Texinfo::Structuring::warn_non_empty_parts($parser);
+ }
+
if ($tree_transformations{'complete_tree_nodes_menus'}) {
Texinfo::Structuring::complete_tree_nodes_menus($parser, $tree);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5556] * Texinfo/Parser.pm, Texinfo/Structuring.pm( warn_non_empty_parts),,
Patrice Dumas <=