[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Thu, 18 Jan 2024 18:44:52 -0500 (EST) |
branch: master
commit ec8144b20b459c07e39426a89e90a93a3f8737af
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Jan 18 22:43:08 2024 +0100
* tp/Texinfo/Common.pm (set_output_encodings): use document in input
argument. Update callers.
* tp/Texinfo/Convert/Converter.pm (set_document)
(determine_files_and_directory), tp/Texinfo/Convert/HTML.pm
(_prepare_converted_output_info), tp/Texinfo/Convert/IXIN.pm,
tp/Texinfo/Convert/Info.pm (output, _info_header),
tp/Texinfo/Convert/Utils.pm (encoded_output_file_name)
(encoded_input_file_name): do not set 'document_info', instead use
document global_information to get document information.
---
ChangeLog | 13 +++++++++++++
tp/Texinfo/Common.pm | 8 ++++++--
tp/Texinfo/Convert/Converter.pm | 31 +++++++++++++++----------------
tp/Texinfo/Convert/HTML.pm | 18 ++++++++++++++++--
tp/Texinfo/Convert/IXIN.pm | 9 +++++++--
tp/Texinfo/Convert/Info.pm | 36 ++++++++++++++++++++++++++++++------
tp/Texinfo/Convert/Text.pm | 3 +--
tp/Texinfo/Convert/Utils.pm | 28 ++++++++++++++++++++--------
tp/t/test_sort.t | 3 +--
tp/t/test_utils.pl | 2 +-
tp/texi2any.pl | 2 +-
11 files changed, 111 insertions(+), 42 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7152bcc29a..bf4c72684a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -33,6 +33,19 @@
* tp/Texinfo/Common.pm (debug_print_tree): Also print 'unit_contents'
keys to allow printing an "output unit".
+2024-01-18 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Common.pm (set_output_encodings): use document in input
+ argument. Update callers.
+
+ * tp/Texinfo/Convert/Converter.pm (set_document)
+ (determine_files_and_directory), tp/Texinfo/Convert/HTML.pm
+ (_prepare_converted_output_info), tp/Texinfo/Convert/IXIN.pm,
+ tp/Texinfo/Convert/Info.pm (output, _info_header),
+ tp/Texinfo/Convert/Utils.pm (encoded_output_file_name)
+ (encoded_input_file_name): do not set 'document_info', instead use
+ document global_information to get document information.
+
2024-01-18 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Common.pm (find_parent_root_command),
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 565e4acf73..d4d5e74c2c 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1353,8 +1353,12 @@ sub lookup_index_entry($$)
sub set_output_encodings($$)
{
my $customization_information = shift;
- my $document_information = shift;
+ my $document = shift;
+ my $document_information;
+ if ($document) {
+ $document_information = $document->global_information();
+ }
$customization_information->set_conf('OUTPUT_ENCODING_NAME',
$document_information->{'input_encoding_name'})
if ($document_information
@@ -3018,7 +3022,7 @@ a command that sets some information, such as
C<@documentlanguage>,
C<@contents> or C<@footnotestyle> for example. Return true if the command
argument was found and the customization variable was set.
-=item set_output_encodings($customization_information, $document_information)
+=item set_output_encodings($customization_information, $document)
X<C<set_output_encodings>>
If not already set, set C<OUTPUT_ENCODING_NAME> based on input file
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 5e2d594f38..b7d7c948d8 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -266,7 +266,6 @@ sub set_document($$)
$converter->{'document'} = $document;
if (defined($document)) {
- $converter->{'document_info'} = $document->global_information();
my $floats = $document->floats_information();
my $identifier_target = $document->labels_information();
my $sections_list = $document->sections_list();
@@ -282,8 +281,7 @@ sub set_document($$)
$converter->{'document_descriptor'}
= $document->document_descriptor();
}
- Texinfo::Common::set_output_encodings($converter,
- $converter->{'document_info'});
+ Texinfo::Common::set_output_encodings($converter, $document);
$converter->{'convert_text_options'}
= Texinfo::Convert::Text::copy_options_for_convert_text($converter);
@@ -739,12 +737,18 @@ sub determine_files_and_directory($$)
# determine input file base name
my $input_basefile;
- if (defined($self->{'document_info'}->{'input_file_name'})) {
+ my $document_info;
+
+ if ($self->{'document'}) {
+ $document_info = $self->{'document'}->global_information();
+ }
+
+ if ($document_info and defined($document_info->{'input_file_name'})) {
# 'input_file_name' is not decoded, as it is derived from input
# file which is not decoded either. We want to return only
# decoded character strings such that they can easily be mixed
# with other character strings, so we decode here.
- my $input_file_name = $self->{'document_info'}->{'input_file_name'};
+ my $input_file_name = $document_info->{'input_file_name'};
my $encoding = $self->get_conf('COMMAND_LINE_ENCODING');
if (defined($encoding)) {
$input_file_name = decode($encoding, $input_file_name, sub { '?' });
@@ -2117,23 +2121,18 @@ C<Texinfo::Convert::Converter>.
=item $converter = MyConverter->converter($options)
-The I<$options> hash reference holds options for the converter. In
-this option hash reference a L<document|Texinfo::Document>
-may be associated with the I<document> key. The other options
-are Texinfo customization options and a few other options that can
+The I<$options> hash reference holds options for the converter.
+These options are Texinfo customization options and a few other options that
can
be passed to the converter. Most of the customization options
are described in the Texinfo manual.
Those customization options, when appropriate, override the document content.
B<TODO what about the other options (all are used in converters>
-B<TODO change?
-The document should not be available directly anymore after getting the
-associated information.> B<TODO document this associated information
-('document_info', 'indices_information', 'floats'..., most available
-in HTML converter, either through $converter-E<gt>get_info() or
label_command())>
+B<TODO document this associated information
+('indices_information', 'floats'..., most available
+in HTML converter, either through $converter-E<gt>get_info('document') or
label_command())>
The C<converter> function returns a converter object (a blessed hash
-reference) after checking the options and performing some initializations,
-especially when a document is given among the options.
+reference) after checking the options and performing some initializations.
=back
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 55d2fd6bc3..c8562c39fb 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -12161,13 +12161,27 @@ sub _prepare_converted_output_info($)
$self->{'title_string'} = $self->convert_tree_new_formatting_context(
{'type' => '_string', 'contents' => [$self->{'title_tree'}]},
'title_string');
+
+ my $input_file_name;
+ if ($self->{'document'}) {
+ my $document_info = $self->{'document'}->global_information();
+ if ($document_info) {
+ $input_file_name = $document_info->{'input_file_name'};
+ }
+ }
+
# TODO it is not clear that a filename without line number is ok
# for line_warn. Not clear what is the right way to do. There is
# no file level warn, as in general document_warn is used for messages
# for other files than the main file name.
- $self->converter_line_warn(__(
+ if (defined($input_file_name)) {
+ $self->converter_line_warn(__(
"must specify a title with a title command or \@top"),
- {'file_name' => $self->{'document_info'}->{'input_file_name'}});
+ {'file_name' => $input_file_name});
+ } else {
+ $self->converter_document_warn(__(
+ "must specify a title with a title command or
\@top"));
+ }
} else {
$self->{'title_string'} = $html_title_string;
}
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index d3a1107a8f..d25a4e674e 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -380,10 +380,15 @@ sub output_ixin($$)
$result .= $self->ixin_list_element('lang', [['name', $lang]]);
# FIXME title: use simpletitle or fulltitle
- if ($self->{'document_info'}->{'dircategory_direntry'}) {
+ my $document_info;
+ if ($self->->{'document'}) {
+ $document_info = $self->{'document'}->global_information();
+ }
+
+ if ($document_info and $document_info->{'dircategory_direntry'}) {
my $current_category;
foreach my $dircategory_direntry
- (@{$self->{'document_info'}->{'dircategory_direntry'}}) {
+ (@{$document_info->{'dircategory_direntry'}}) {
if ($dircategory_direntry->{'cmdname'}
and $dircategory_direntry->{'cmdname'} eq 'dircategory') {
if ($current_category) {
diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm
index 0e68ef4ea8..1816e9245e 100644
--- a/tp/Texinfo/Convert/Info.pm
+++ b/tp/Texinfo/Convert/Info.pm
@@ -121,8 +121,19 @@ sub output($$)
my @indirect_files;
if (!defined($tree_units) or not defined($tree_units->[0])
or not defined($tree_units->[0]->{'unit_command'})) {
- $self->converter_line_warn(__("document without nodes"),
- {'file_name' => $self->{'document_info'}->{'input_file_name'}});
+ my $input_file_name;
+ if ($self->{'document'}) {
+ my $document_info = $self->{'document'}->global_information();
+ if ($document_info) {
+ $input_file_name = $document_info->{'input_file_name'};
+ }
+ }
+ if (defined($input_file_name)) {
+ $self->converter_line_warn(__("document without nodes"),
+ {'file_name' => $input_file_name});
+ } else {
+ $self->converter_document_warn(__("document without nodes"));
+ }
my $old_context = $self->{'count_context'}->[-1];
my $new_context =
{'lines' => $old_context->{'lines'}, 'bytes' => $old_context->{'bytes'},
@@ -146,8 +157,19 @@ sub output($$)
} else {
unless ($self->{'identifiers_target'}
and $self->{'identifiers_target'}->{'Top'}) {
- $self->converter_line_warn(__("document without Top node"),
- {'file_name' => $self->{'document_info'}->{'input_file_name'}});
+ my $input_file_name;
+ if ($self->{'document'}) {
+ my $document_info = $self->{'document'}->global_information();
+ if ($document_info) {
+ $input_file_name = $document_info->{'input_file_name'};
+ }
+ }
+ if (defined($input_file_name)) {
+ $self->converter_line_warn(__("document without Top node"),
+ {'file_name' => $input_file_name});
+ } else {
+ $self->converter_document_warn(__("document without Top node"));
+ }
}
$out_file_nr = 1;
my $first_node_seen = 0;
@@ -405,8 +427,10 @@ sub _info_header($$$)
$self->_stream_output($paragraph, $result);
my $global_commands;
+ my $document_info;
if ($self->{'document'}) {
$global_commands = $self->{'document'}->global_commands_information();
+ $document_info = $self->{'document'}->global_information();
}
# format @copying using the last value of the preamble.
my @informative_global_commands = $self->get_informative_global_commands();
@@ -422,10 +446,10 @@ sub _info_header($$$)
}
$self->set_global_document_commands('before', \@informative_global_commands);
- if ($self->{'document_info'}->{'dircategory_direntry'}) {
+ if ($document_info->{'dircategory_direntry'}) {
my $dir_section = '';
$self->{'ignored_commands'}->{'direntry'} = 0;
- foreach my $command
(@{$self->{'document_info'}->{'dircategory_direntry'}}) {
+ foreach my $command (@{$document_info->{'dircategory_direntry'}}) {
if ($command->{'cmdname'} eq 'dircategory') {
if ($command->{'args'} and @{$command->{'args'}}
and defined($command->{'args'}->[0]->{'contents'})) {
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 46a0ba9a18..46949ce610 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -926,8 +926,7 @@ sub output($$)
$global_commands = $document->global_commands_information();
}
- Texinfo::Common::set_output_encodings($self, $document_info)
- if ($document_info);
+ Texinfo::Common::set_output_encodings($self, $document);
# Text options and converter are of different nature.
# It could have been possible to set up the options by calling
diff --git a/tp/Texinfo/Convert/Utils.pm b/tp/Texinfo/Convert/Utils.pm
index 24e0eaa2f4..2784317281 100644
--- a/tp/Texinfo/Convert/Utils.pm
+++ b/tp/Texinfo/Convert/Utils.pm
@@ -174,7 +174,7 @@ sub definition_category_tree($$)
'parent' => $arg_class_code};
$arg_class_code->{'args'} = [$brace_arg];
}
-
+
my $def_command = $current->{'extra'}->{'def_command'};
if ($def_command eq 'defop'
or $def_command eq 'deftypeop'
@@ -466,9 +466,15 @@ sub encoded_output_file_name($$)
if ($output_file_name_encoding) {
$encoding = $output_file_name_encoding;
} elsif ($self->get_conf('DOC_ENCODING_FOR_OUTPUT_FILE_NAME')) {
- $encoding = $self->{'document_info'}->{'input_perl_encoding'}
- if ($self->{'document_info'}
- and defined($self->{'document_info'}->{'input_perl_encoding'}));
+ my $document_info;
+
+ if ($self->{'document'}) {
+ $document_info = $self->{'document'}->global_information();
+ }
+
+ $encoding = $document_info->{'input_perl_encoding'}
+ if ($document_info
+ and defined($document_info->{'input_perl_encoding'}));
} else {
$encoding = $self->get_conf('LOCALE_ENCODING');
}
@@ -503,9 +509,15 @@ sub encoded_input_file_name($$;$)
if (defined($input_file_encoding)) {
$encoding = $input_file_encoding;
} else {
- $encoding = $self->{'document_info'}->{'input_perl_encoding'}
- if ($self->{'document_info'}
- and defined($self->{'document_info'}->{'input_perl_encoding'}));
+ my $document_info;
+
+ if ($self->{'document'}) {
+ $document_info = $self->{'document'}->global_information();
+ }
+
+ $encoding = $document_info->{'input_perl_encoding'}
+ if ($document_info
+ and defined($document_info->{'input_perl_encoding'}));
}
} else {
$encoding = $self->get_conf('LOCALE_ENCODING');
@@ -542,7 +554,7 @@ Texinfo::Convert::Utils - miscellaneous functions usable in
all converters
=head1 SYNOPSIS
use Texinfo::Convert::Utils;
-
+
my $today_tree = Texinfo::Convert::Utils::expand_today($converter);
my $verbatiminclude_tree
= Texinfo::Convert::Utils::expand_verbatiminclude($converter,
diff --git a/tp/t/test_sort.t b/tp/t/test_sort.t
index 05ccb7556d..10e53f4e2e 100644
--- a/tp/t/test_sort.t
+++ b/tp/t/test_sort.t
@@ -47,9 +47,8 @@ $tree = $document->tree();
my $registrar = $parser->registered_errors();
my $indices_information = $document->indices_information();
my $index_entries = Texinfo::Indices::merge_indices($indices_information);
-my $document_information = $document->global_information();
my $main_configuration = Texinfo::MainConfig::new({'ENABLE_ENCODING' => 1});
-Texinfo::Common::set_output_encodings($main_configuration,
$document_information);
+Texinfo::Common::set_output_encodings($main_configuration, $document);
$main_configuration->{'document_descriptor'}
= $document->document_descriptor();
$main_configuration->register_XS_document_main_configuration($document);
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 14a68c5123..653359971d 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1061,7 +1061,7 @@ sub test($$)
my $document_information = $document->global_information();
Texinfo::Common::set_output_encodings($main_configuration,
- $document_information);
+ $document);
my $global_commands = $document->global_commands_information();
if ($document_information->{'novalidate'}) {
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index b4dd04872d..1226d286f3 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1507,7 +1507,7 @@ while(@input_files) {
my $document_information = $document->global_information();
# encoding is needed for output files
# encoding and documentlanguage are needed for gdt() in
regenerate_master_menu
- Texinfo::Common::set_output_encodings($main_configuration,
$document_information);
+ Texinfo::Common::set_output_encodings($main_configuration, $document);
if (not defined($main_configuration->get_conf('documentlanguage'))
and defined ($document_information->{'documentlanguage'})) {
$main_configuration->set_conf('documentlanguage',
- master updated (be96e0d57e -> 54faad841f), Patrice Dumas, 2024/01/18
- [no subject], Patrice Dumas, 2024/01/18
- [no subject],
Patrice Dumas <=
- [no subject], Patrice Dumas, 2024/01/18
- [no subject], Patrice Dumas, 2024/01/18
- [no subject], Patrice Dumas, 2024/01/18
- [no subject], Patrice Dumas, 2024/01/18
- [no subject], Patrice Dumas, 2024/01/18