[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Structuring.pm (sectioning_structure
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Structuring.pm (sectioning_structure, nodes_tree), tp/Texinfo/Convert/Converter.pm (%all_converters_defaults) (converter), Pod-Simple-Texinfo/pod2texi.pl, texi2any.pl: Do not set 'structring' keys in Texinfo::Structuring sectioning_structure() and nodes_tree(), return the informations that are set in the caller. The 'structuring' is not associated with parser anymore, but setup in the Texinfo::Structuring function callers. |
Date: |
Tue, 31 Aug 2021 05:18:18 -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 e3f78ed * tp/Texinfo/Structuring.pm (sectioning_structure,
nodes_tree), tp/Texinfo/Convert/Converter.pm (%all_converters_defaults)
(converter), Pod-Simple-Texinfo/pod2texi.pl, texi2any.pl: Do not set
'structring' keys in Texinfo::Structuring sectioning_structure() and
nodes_tree(), return the informations that are set in the caller. The
'structuring' is not associated with parser anymore, but setup in the
Texinfo::Structuring function callers.
e3f78ed is described below
commit e3f78ed688935f0a916085ebb257a650a1c76d39
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Aug 31 11:18:09 2021 +0200
* tp/Texinfo/Structuring.pm (sectioning_structure, nodes_tree),
tp/Texinfo/Convert/Converter.pm (%all_converters_defaults)
(converter), Pod-Simple-Texinfo/pod2texi.pl, texi2any.pl:
Do not set 'structring' keys in Texinfo::Structuring
sectioning_structure() and nodes_tree(), return the
informations that are set in the caller. The 'structuring'
is not associated with parser anymore, but setup in the
Texinfo::Structuring function callers.
---
ChangeLog | 11 +++++++++++
Pod-Simple-Texinfo/pod2texi.pl | 6 ++++--
tp/Texinfo/Convert/Converter.pm | 8 +++++++-
tp/Texinfo/Structuring.pm | 33 +++++++++++++++------------------
tp/t/automatic_menus.t | 6 ++++--
tp/t/test_utils.pl | 21 +++++++++++++++------
tp/texi2any.pl | 27 +++++++++++++++++++--------
7 files changed, 75 insertions(+), 37 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9230243..c731514 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2021-08-31 Patrice Dumas <pertusus@free.fr>
+ * tp/Texinfo/Structuring.pm (sectioning_structure, nodes_tree),
+ tp/Texinfo/Convert/Converter.pm (%all_converters_defaults)
+ (converter), Pod-Simple-Texinfo/pod2texi.pl, texi2any.pl:
+ Do not set 'structring' keys in Texinfo::Structuring
+ sectioning_structure() and nodes_tree(), return the
+ informations that are set in the caller. The 'structuring'
+ is not associated with parser anymore, but setup in the
+ Texinfo::Structuring function callers.
+
+2021-08-31 Patrice Dumas <pertusus@free.fr>
+
* tp/Texinfo/Report.pm (new, gdt),
tp/Texinfo/ParserNonXS.pm (_line_warn, _line_error)
(_setup_parser, simple_parser, parse_texi_file, registered_errors),
diff --git a/Pod-Simple-Texinfo/pod2texi.pl b/Pod-Simple-Texinfo/pod2texi.pl
index f912a5e..440adf5 100755
--- a/Pod-Simple-Texinfo/pod2texi.pl
+++ b/Pod-Simple-Texinfo/pod2texi.pl
@@ -238,6 +238,8 @@ sub _fix_texinfo_tree($$$$;$)
my $parser = Texinfo::Parser::parser();
my $tree = $parser->parse_texi_text($manual_texi);
+ my $registrar = $parser->registered_errors();
+
my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
if ($fill_gaps_in_sectioning) {
@@ -284,8 +286,8 @@ sub _fix_texinfo_tree($$$$;$)
}
}
}
- my $structure = Texinfo::Structuring::sectioning_structure($parser, $parser,
- $parser, $tree);
+ my ($sectioning_root, $sections_list)
+ = Texinfo::Structuring::sectioning_structure($registrar, $parser,
$tree);
Texinfo::Transformations::complete_tree_nodes_menus($tree)
if ($section_nodes);
Texinfo::Transformations::regenerate_master_menu($parser, $labels)
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 00d01fb..99e4e45 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -60,6 +60,12 @@ my %defaults = (
# defaults for all converters. Maybe more could be added, especially what
# can be set with --set and should be the same for all the formats.
+# undef values in general marks information passed by the caller that
+# is valid in the parser configuration initialization hash, but
+# is not considered as "configuration", and is available directly
+# in the converter, not through get_conf().
+# FIXME separate the two types of information and check that those
+# items are not valid options.
our %all_converters_defaults = (
'language_config_dirs' => undef,
'output_format' => undef,
@@ -69,6 +75,7 @@ our %all_converters_defaults = (
'fillcolumn' => 72,
'expanded_formats' => undef,
'include_directories' => undef,
+ 'structuring' => undef,
'IMAGE_LINK_PREFIX' => undef,
'NUMBER_SECTIONS' => 1,
'NUMBER_FOOTNOTES' => 1,
@@ -208,7 +215,6 @@ sub converter(;$)
my $floats = $converter->{'parser'}->floats_information();
my ($labels, $targets_list, $nodes_list)
= $converter->{'parser'}->labels_information();
- $converter->{'structuring'} = $converter->{'parser'}->{'structuring'};
$converter->{'floats'} = $floats if ($floats);
$converter->{'labels'} = $labels if ($labels);
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index b944812..1c028cb 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -127,12 +127,12 @@ sub section_level($)
# 'toplevel_next'
# 'toplevel_prev'
# 'toplevel_up'
-sub sectioning_structure($$$$)
+sub sectioning_structure($$$)
{
- my $self = shift;
my $registrar = shift;
my $configuration_informations = shift;
my $root = shift;
+
if (!$root->{'type'} or $root->{'type'} ne 'document_root'
or !$root->{'contents'}) {
return undef;
@@ -307,9 +307,7 @@ sub sectioning_structure($$$$)
$content->{'cmdname'}), $content->{'line_nr'});
}
}
- $self->{'structuring'}->{'sectioning_root'} = $sec_root;
- $self->{'structuring'}->{'sections_list'} = \@sections_list;
- return $sec_root;
+ return $sec_root, \@sections_list;
}
# for debugging
@@ -714,9 +712,8 @@ sub complete_node_tree_with_menus($$$$)
# set node directions based on sectioning and @node explicit directions
-sub nodes_tree($$$$$$)
+sub nodes_tree($$$$$)
{
- my $self = shift;
my $registrar = shift;
my $configuration_informations = shift;
my $parser_informations = shift;
@@ -816,7 +813,6 @@ sub nodes_tree($$$$$$)
}
}
$top_node = $nodes_list->[0] if (!$top_node);
- $self->{'structuring'}->{'top_node'} = $top_node;
return $top_node;
}
@@ -1770,18 +1766,19 @@ Texinfo::Structuring - information on Texinfo::Parser
tree
merge_indices sort_indices_by_letter sort_indices elements_directions
elements_file_directions);
# $tree is a Texinfo document tree. $parser is a Texinfo::Parser object.
- my $sections_root = sectioning_structure ($parser, $parser, $parser, $tree);
+ my $registrar = $parser->registered_errors();
+ my $sections_root = sectioning_structure ($registart, $parser, $tree);
my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
my $parser_informations = $parser->global_informations();
my $global_commands = $parser->global_commands_information();
- set_menus_node_directions($parser, $parser, $parser_informations,
+ set_menus_node_directions($registrar, $parser, $parser_informations,
$global_commands, $nodes_list, $labels);
- my $top_node = nodes_tree($parser, $parser, $parser, $parser_informations,
$nodes_list, $labels);
- complete_node_tree_with_menus($parser, $parser, $nodes_list, $top_node);
+ my $top_node = nodes_tree($registrar, $parser, $parser_informations,
$nodes_list, $labels);
+ complete_node_tree_with_menus($registrar, $parser, $nodes_list, $top_node);
my $refs = $parser->internal_references_information();
- check_nodes_are_referenced($parser, $parser, $nodes_list, $top_node,
$labels, $refs);
+ check_nodes_are_referenced($registrar, $parser, $nodes_list, $top_node,
$labels, $refs);
number_floats($parser->floats_information());
- associate_internal_references($parser, $parser, $parser_informations,
$labels, $refs);
+ associate_internal_references($registrar, $parser, $parser_informations,
$labels, $refs);
my $elements;
if ($split_at_nodes) {
$elements = split_by_node($tree);
@@ -1844,12 +1841,12 @@ as argument, see L<Texinfo::Parser>.
=over
-=item $sections_root = sectioning_structure ($parser, $registrar,
$configuration_informations, $tree)
+=item $sections_root, $sections_list = sectioning_structure ($registrar,
$configuration_informations, $tree)
This function goes through the tree and gather information on
the document structure for sectioning commands. It returns the
-root of the sectioning commands tree. Errors are registered
-in I<$registrar>.
+root of the sectioning commands tree and a reference on the sections
+elements list. Errors are registered in I<$registrar>.
For section elements, it sets:
@@ -1911,7 +1908,7 @@ Up, next and previous directions as set in menus.
=back
-=item my $top_node = nodes_tree($parser, $registrar,
$configuration_informations, $parser_informations, $nodes_list, $labels)
+=item my $top_node = nodes_tree($registrar, $configuration_informations,
$parser_informations, $nodes_list, $labels)
Goes through nodes and set directions. Returns the top
node. Register errors in C<$registrar>.
diff --git a/tp/t/automatic_menus.t b/tp/t/automatic_menus.t
index 4de819e..1c00c4c 100644
--- a/tp/t/automatic_menus.t
+++ b/tp/t/automatic_menus.t
@@ -24,12 +24,14 @@ sub test($$$;$)
my $parser = Texinfo::Parser::parser();
my $tree = $parser->parse_texi_text($in);
+ my $registrar = $parser->registered_errors();
my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
my $parser_informations = $parser->global_informations();
my $refs = $parser->internal_references_information();
- Texinfo::Structuring::associate_internal_references($parser, $parser,
+ Texinfo::Structuring::associate_internal_references($registrar, $parser,
$parser_informations, $labels, $refs);
- my $sectioning = Texinfo::Structuring::sectioning_structure($parser, $parser,
+ my ($sectioning_root, $sections_list)
+ = Texinfo::Structuring::sectioning_structure($registrar,
$parser, $tree);
if ($complete_missing_menus) {
Texinfo::Transformations::complete_tree_nodes_missing_menu($tree);
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 11d44e5..2699e48 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -867,18 +867,26 @@ sub test($$)
my $floats = $parser->floats_information();
my $global_commands = $parser->global_commands_information();
- my $structure = Texinfo::Structuring::sectioning_structure($parser,
$registrar,
+
+ my $structure_informations = {};
+ my ($sectioning_root, $sections_list)
+ = Texinfo::Structuring::sectioning_structure($registrar,
$parser, $result);
- if ($structure) {
+ if ($sectioning_root) {
Texinfo::Structuring::warn_non_empty_parts($registrar, $parser,
$global_commands);
+ $structure_informations->{'sectioning_root'} = $sectioning_root;
+ $structure_informations->{'sections_list'} = $sections_list;
}
Texinfo::Structuring::number_floats($floats);
Texinfo::Structuring::set_menus_node_directions($registrar, $parser,
$parser_informations, $global_commands, $nodes_list,
$labels);
- my $top_node = Texinfo::Structuring::nodes_tree($parser, $registrar, $parser,
+ my $top_node = Texinfo::Structuring::nodes_tree($registrar, $parser,
$parser_informations, $nodes_list,
$labels);
+ if (defined($top_node)) {
+ $structure_informations->{'top_node'} = $top_node;
+ }
if (defined($nodes_list)) {
Texinfo::Structuring::complete_node_tree_with_menus($registrar, $parser,
@@ -918,6 +926,7 @@ sub test($$)
my %converted;
my %converted_errors;
$converter_options = {} if (!defined($converter_options));
+ $converter_options->{'structuring'} = $structure_informations;
foreach my $format (@tested_formats) {
if (defined($formats{$format})) {
my $format_converter_options = {%$converter_options};
@@ -1074,9 +1083,9 @@ sub test($$)
.protect_perl_string($converted_text)."';\n\n";
{
local $Data::Dumper::Sortkeys = \&filter_sectioning_keys;
- $out_result .= Data::Dumper->Dump([$structure],
+ $out_result .= Data::Dumper->Dump([$sectioning_root],
['$result_sectioning{\''.$test_name.'\'}'])."\n"
- if ($structure);
+ if ($sectioning_root);
}
if ($top_node) {
{
@@ -1129,7 +1138,7 @@ sub test($$)
cmp_trimmed($split_result, $result_trees{$test_name}, \@avoided_keys_tree,
$test_name.' tree');
- cmp_trimmed($structure, $result_sectioning{$test_name},
+ cmp_trimmed($sectioning_root, $result_sectioning{$test_name},
\@avoided_keys_sectioning, $test_name.' sectioning' );
cmp_trimmed($top_node, $result_nodes{$test_name}, \@avoided_keys_nodes,
$test_name.' nodes');
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index c57a8d2..2255755 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1309,16 +1309,24 @@ while(@input_files) {
my $parser_informations = $parser->global_informations();
Texinfo::Structuring::associate_internal_references($registrar, $parser,
$parser_informations, $labels, $refs);
+ # filled with informations obtained through Texinfo::Structuring
+ # and usefull in converters.
+ # FIXME the keys are not documented anywhere. It is unclear where they
+ # should be documented.
+ my $structure_informations = {};
# every format needs the sectioning structure
- # FIXME replace parser as first argument by a structure object
- my $structure = Texinfo::Structuring::sectioning_structure($parser,
$registrar,
+ my ($sectioning_root, $sections_list)
+ = Texinfo::Structuring::sectioning_structure($registrar,
$parser, $tree);
my $global_commands = $parser->global_commands_information();
- if ($structure
- and !$formats_table{$format}->{'no_warn_non_empty_parts'}) {
- Texinfo::Structuring::warn_non_empty_parts($registrar, $parser,
- $global_commands);
+ if ($sectioning_root) {
+ $structure_informations->{'sectioning_root'} = $sectioning_root;
+ $structure_informations->{'sections_list'} = $sections_list;
+ if (!$formats_table{$format}->{'no_warn_non_empty_parts'}) {
+ Texinfo::Structuring::warn_non_empty_parts($registrar, $parser,
+ $global_commands);
+ }
}
if ($tree_transformations{'complete_tree_nodes_menus'}) {
@@ -1347,9 +1355,11 @@ while(@input_files) {
Texinfo::Structuring::set_menus_node_directions($registrar, $parser,
$parser_informations, $global_commands, $nodes_list, $labels);
}
- # FIXME replace parser as first argument by a structure object
- $top_node = Texinfo::Structuring::nodes_tree($parser, $registrar, $parser,
+ $top_node = Texinfo::Structuring::nodes_tree($registrar, $parser,
$parser_informations, $nodes_list, $labels);
+ if (defined($top_node)) {
+ $structure_informations->{'top_node'} = $top_node;
+ }
if (not defined($parser_options->{'FORMAT_MENU'})
or $parser_options->{'FORMAT_MENU'} eq 'menu') {
if (defined($nodes_list)) {
@@ -1383,6 +1393,7 @@ while(@input_files) {
$converter_options->{'expanded_formats'} =
$parser_options->{'EXPANDED_FORMATS'};
$converter_options->{'parser'} = $parser;
+ $converter_options->{'structuring'} = $structure_informations;
$converter_options->{'output_format'} = $format;
$converter_options->{'language_config_dirs'} = \@language_config_dirs;
unshift @{$converter_options->{'include_directories'}},
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Structuring.pm (sectioning_structure, nodes_tree), tp/Texinfo/Convert/Converter.pm (%all_converters_defaults) (converter), Pod-Simple-Texinfo/pod2texi.pl, texi2any.pl: Do not set 'structring' keys in Texinfo::Structuring sectioning_structure() and nodes_tree(), return the informations that are set in the caller. The 'structuring' is not associated with parser anymore, but setup in the Texinfo::Structuring function callers.,
Patrice Dumas <=
- Prev by Date:
[no subject]
- Next by Date:
branch master updated: * tp/Texinfo/Common.pm (open_out, output_files_open_out) (output_files_register_closed, output_files_opened_files) (output_files_unclosed_files), tp/Texinfo/Convert/Converter.pm (register_close_file, converter) (converter_opened_files, converter_unclosed_files, output_files_information) tp/DebugTexinfo/DebugTree.pm, tp/Texinfo/Convert/DocBook.pm, tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/TexinfoXML.pm, tp/Texinfo/Convert/Text.pm, tp/init/chm.pm, tp/texi2an [...]
- Previous by thread:
master updated (f73f236 -> ac04776)
- Next by thread:
branch master updated: * tp/Texinfo/Common.pm (open_out, output_files_open_out) (output_files_register_closed, output_files_opened_files) (output_files_unclosed_files), tp/Texinfo/Convert/Converter.pm (register_close_file, converter) (converter_opened_files, converter_unclosed_files, output_files_information) tp/DebugTexinfo/DebugTree.pm, tp/Texinfo/Convert/DocBook.pm, tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/TexinfoXML.pm, tp/Texinfo/Convert/Text.pm, tp/init/chm.pm, tp/texi2an [...]
- Index(es):