texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/Config.pm (texinfo_register_formatti


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Config.pm (texinfo_register_formatting_function), tp/Texinfo/Convert/HTML.pm (converter_initialize, run_stage_handlers): do not check the validity of texinfo_register_formatting_function() registered functions in Texinfo::Config but in Texinfo::Convert::HTML in converter_initialize(). Do not check that the stage handler is valid in Convert::HTML in run_stage_handlers() as it has already been done in Texinfo::Config. This allows to avoid loading the Convert::HTML module early.
Date: Wed, 01 Sep 2021 07:04:02 -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 a7cb7c7  * tp/Texinfo/Config.pm 
(texinfo_register_formatting_function), tp/Texinfo/Convert/HTML.pm 
(converter_initialize, run_stage_handlers): do not check the validity of 
texinfo_register_formatting_function() registered functions in Texinfo::Config 
but in Texinfo::Convert::HTML in converter_initialize().  Do not check that the 
stage handler is valid in Convert::HTML in run_stage_handlers() as it has 
already been done in Texinfo::Config.  This allows to avoid loading the Convert 
[...]
a7cb7c7 is described below

commit a7cb7c770d9c5b1f1b6ff4448e4aeb4a07001468
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Sep 1 13:03:54 2021 +0200

    * tp/Texinfo/Config.pm (texinfo_register_formatting_function),
    tp/Texinfo/Convert/HTML.pm (converter_initialize, run_stage_handlers):
    do not check the validity of texinfo_register_formatting_function()
    registered functions in Texinfo::Config but in Texinfo::Convert::HTML
    in converter_initialize().  Do not check that the stage handler is
    valid in Convert::HTML in run_stage_handlers() as it has already been
    done in Texinfo::Config.  This allows to avoid loading the
    Convert::HTML module early.
---
 ChangeLog                  | 11 +++++++++++
 tp/Texinfo/Config.pm       | 23 ++++-------------------
 tp/Texinfo/Convert/HTML.pm | 29 +++++++++++++++--------------
 tp/texi2any.pl             |  6 ++----
 4 files changed, 32 insertions(+), 37 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4a16c10..205163b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2021-09-01  Patrice Dumas  <pertusus@free.fr>
 
+       * tp/Texinfo/Config.pm (texinfo_register_formatting_function),
+       tp/Texinfo/Convert/HTML.pm (converter_initialize, run_stage_handlers):
+       do not check the validity of texinfo_register_formatting_function()
+       registered functions in Texinfo::Config but in Texinfo::Convert::HTML
+       in converter_initialize().  Do not check that the stage handler is
+       valid in Convert::HTML in run_stage_handlers() as it has already been
+       done in Texinfo::Config.  This allows to avoid loading the
+       Convert::HTML module early.
+
+2021-09-01  Patrice Dumas  <pertusus@free.fr>
+
        * tp/Texinfo/Config.pm (GNUT_get_stage_handlers)
        (GNUT_get_formatting_references, GNUT_get_commands_conversion)
        (GNUT_get_types_conversion), tp/Texinfo/Convert/HTML.pm:
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index d4f2bf4..45753a8 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -20,15 +20,14 @@
 # functions that should not be called by user init files codes are
 # prefixed by GNUT_ while functions that can be called by user init
 # files codes are prefixed by texinfo_.
+# 
+# TODO document all texinfo_ in a pod section, but wait for stabilization
 
 package Texinfo::Config;
 
 # for __(
 use Texinfo::Common;
 
-# for %Texinfo::Convert::HTML::default_formatting_references
-use Texinfo::Convert::HTML;
-
 # for carp
 use Carp;
 
@@ -114,16 +113,7 @@ sub texinfo_add_valid_option($)
   return Texinfo::Common::add_valid_option($option);
 }
 
-# FIXME this is unclean, but it is texi2any.pl that loads init files
-# so it needs to know the %default_formatting_references for
-# texinfo_register_formatting_function when eval'ing files in load_init_file
-# which appears early.
-my %default_formatting_references = 
%Texinfo::Convert::HTML::default_formatting_references;
-
-# FIXME would be better to do the reverse, but Texinfo::Convert::HTML
-# is loaded first
-#our @possible_stages = ('setup', 'structure', 'init', 'finish');
-my @possible_stages = @Texinfo::Convert::HTML::possible_stages;
+my @possible_stages = ('setup', 'structure', 'init', 'finish');
 my %possible_stages;
 foreach my $stage (@possible_stages) {
   $possible_stages{$stage} = 1;
@@ -131,7 +121,7 @@ foreach my $stage (@possible_stages) {
 
 my $default_priority = 'default';
 
-# Thes variables should not be accessed directly by the users who
+# These variables should not be accessed directly by the users who
 # customize formatting and should use the associated functions,
 # such as texinfo_register_handler(), texinfo_register_formatting_function(),
 # texinfo_register_command_formatting() or texinfo_register_type_formatting().
@@ -143,7 +133,6 @@ my $GNUT_formatting_references = {};
 my $GNUT_commands_conversion = {};
 my $GNUT_types_conversion = {};
 
-
 sub texinfo_register_handler($$;$)
 {
   my $stage = shift;
@@ -170,10 +159,6 @@ sub texinfo_register_formatting_function($$)
 {
   my $thing = shift;
   my $handler = shift;
-  if (!$default_formatting_references{$thing}) {
-    carp ("Unknown formatting type $thing\n");
-    return 0;
-  }
   $GNUT_formatting_references->{$thing} = $handler;
 }
 
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 96bc1ba..de58608 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -63,6 +63,8 @@ use Texinfo::Convert::Text;
 use Texinfo::Convert::Unicode;
 use Texinfo::Convert::NodeNameNormalization;
 
+use Texinfo::Config;
+
 use Carp qw(cluck confess);
 
 use File::Copy qw(copy);
@@ -5136,8 +5138,8 @@ sub converter_initialize($)
 
   _load_htmlxref_files($self);
 
+  my $customized_types_conversion = 
Texinfo::Config::GNUT_get_types_conversion();
   foreach my $type (keys(%default_types_conversion)) {
-    my $customized_types_conversion = 
Texinfo::Config::GNUT_get_types_conversion();
     if (exists($customized_types_conversion->{$type})) {
       $self->{'types_conversion'}->{$type}
           = $customized_types_conversion->{$type};
@@ -5158,10 +5160,10 @@ sub converter_initialize($)
   }
 
   # FIXME put value in a category in Texinfo::Common?
+  my $customized_commands_conversion
+     = Texinfo::Config::GNUT_get_commands_conversion();
   foreach my $command (keys(%misc_commands), keys(%brace_commands),
      keys (%block_commands), keys(%no_brace_commands), 'value') {
-    my $customized_commands_conversion
-        = Texinfo::Config::GNUT_get_commands_conversion();
     if (exists($customized_commands_conversion->{$command})) {
       $self->{'commands_conversion'}->{$command} 
           = $customized_commands_conversion->{$command};
@@ -5245,10 +5247,19 @@ sub converter_initialize($)
     }
   }
 
+  my $customized_formatting_references = 
Texinfo::Config::GNUT_get_formatting_references();
+  # first check that all the customized_formatting_references
+  # are in default_formatting_references
+  foreach my $customized_formatting_reference
+       (sort(keys(%{$customized_formatting_references}))) {
+    if (!$default_formatting_references{$customized_formatting_reference}) {
+      $self->document_warn($self, sprintf(__("Unknown formatting function: 
%s"),
+                                          $customized_formatting_reference));
+    }
+  }
   foreach my $formatting_reference (keys(%default_formatting_references)) {
     $self->{'default_formatting_functions'}->{$formatting_reference}
        = $default_formatting_references{$formatting_reference};
-    my $customized_formatting_references = 
Texinfo::Config::GNUT_get_formatting_references();
     if (defined($customized_formatting_references->{$formatting_reference})) {
       $self->{$formatting_reference} 
        =  $customized_formatting_references->{$formatting_reference};
@@ -7286,21 +7297,11 @@ sub output_internal_links($)
   }
 }
 
-use Texinfo::Config;
-
-#my @possible_stages = @Texinfo::Config::possible_stages;
-our @possible_stages = ('setup', 'structure', 'init', 'finish');
-my %possible_stages;
-foreach my $stage (@possible_stages) {
-  $possible_stages{$stage} = 1;
-}
-
 sub run_stage_handlers($$$)
 {
   my $converter = shift;
   my $root = shift;
   my $stage = shift;
-  die if (!$possible_stages{$stage});
 
   my $stage_handlers = Texinfo::Config::GNUT_get_stage_handlers();
   return 1 if (!defined($stage_handlers->{$stage}));
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index faa055e..df51269 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -96,6 +96,8 @@ BEGIN {
 
 use Locale::Messages;
 use Texinfo::Common;
+use Texinfo::Config;
+
 use Texinfo::Convert::Converter;
 
 # this associates the command line options to the arrays set during
@@ -318,10 +320,6 @@ foreach my $texinfo_config_dir (@language_config_dirs) {
   push @program_init_dirs, File::Spec->catdir($texinfo_config_dir, 'init');
 }
 
-# FIXME this in turns uses Texinfo::Convert::HTML which defeats the delayed
-# loading of Texinfo converter modules.
-use Texinfo::Config;
-
 sub locate_and_load_init_file($$)
 {
   my $filename = shift;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]