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_set_format_from_i


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Config.pm (texinfo_set_format_from_init_file) (GNUT_get_format_from_init_file), tp/texi2any.pl, tp/init/chm.pm: use a propoer API in Texinfo::Config to set format from init file with texinfo_set_format_from_init_file() and retrieve from main program with GNUT_get_format_from_init_file().
Date: Wed, 08 Sep 2021 15:25:19 -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 0f8ea1e  * tp/Texinfo/Config.pm (texinfo_set_format_from_init_file) 
(GNUT_get_format_from_init_file), tp/texi2any.pl, tp/init/chm.pm: use a propoer 
API in Texinfo::Config to set format from init file with 
texinfo_set_format_from_init_file() and retrieve from main program with 
GNUT_get_format_from_init_file().
0f8ea1e is described below

commit 0f8ea1e8fbcba6f3b683f2cadbe657897374977d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Sep 8 21:25:11 2021 +0200

    * tp/Texinfo/Config.pm (texinfo_set_format_from_init_file)
    (GNUT_get_format_from_init_file), tp/texi2any.pl,
    tp/init/chm.pm: use a propoer API in Texinfo::Config
    to set format from init file with texinfo_set_format_from_init_file()
    and retrieve from main program with GNUT_get_format_from_init_file().
---
 ChangeLog            |  8 ++++++++
 tp/TODO              |  4 ----
 tp/Texinfo/Config.pm | 57 ++++++++++++++++++++++++++++++++++++++++------------
 tp/init/chm.pm       |  2 +-
 tp/texi2any.pl       | 12 ++++-------
 5 files changed, 57 insertions(+), 26 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b3f75a2..7726170 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2021-09-08  Patrice Dumas  <pertusus@free.fr>
 
+       * tp/Texinfo/Config.pm (texinfo_set_format_from_init_file)
+       (GNUT_get_format_from_init_file), tp/texi2any.pl,
+       tp/init/chm.pm: use a propoer API in Texinfo::Config
+       to set format from init file with texinfo_set_format_from_init_file()
+       and retrieve from main program with GNUT_get_format_from_init_file().
+
+2021-09-08  Patrice Dumas  <pertusus@free.fr>
+
        * tp/Texinfo/Convert/Convert/Texinfo.pm (convert_to_texinfo):
        rename $root as $element if not a root element.
 
diff --git a/tp/TODO b/tp/TODO
index 4c730c3..12a9803 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -13,14 +13,10 @@ xmllint --nonet --noout --valid commands.xml
 Before next release
 ===================
 
-allowcodebreaks needed in HTML?  Change docs?
 
 Bugs
 ====
 
-review interface in texi2any.pl of
-set_global_format()
-See comment there
 
 Profiling
 =========
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index 86462b2..b2c0a6b 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -26,23 +26,27 @@
 
 package Texinfo::Config;
 
+use strict;
+
 # for __( and p__(
 use Texinfo::Common;
 
 # for carp
 use Carp;
 
-# not that there is no use strict to avoid warnings for users code
-
+# for error messages, passed from main program through initialization
+# function.
 my $real_command_name;
 
+# customization API, used from main program and from init files
 my $cmdline_options;
 my $main_program_default_options;
 my $init_files_options = {};
 
-# list options are not handled like string options.  Indeed,
-# the lists need to be defined in the main program, therefore
-# the main program list options would always take precedence
+# list options that can be set from main program are not
+# handled like string options.  Indeed, the lists need
+# to be defined in the main program, therefore the main
+# program list options would always take precedence
 # if there is a precedence, and the list options set from
 # init file would not have any effect. For list options, items
 # are added and removed by calls to texinfo_add_to_option_list
@@ -91,7 +95,7 @@ sub GNUT_load_init_file($) {
 }
 
 # L2H removed in 2021
-# return undef for var there is nothing to set.
+# return undef var when there is nothing to set.
 sub _GNUT_map_obsolete_options($$)
 {
   my $input_var = shift;
@@ -136,8 +140,10 @@ sub texinfo_set_from_init_file($$) {
   return 1;
 }
 
-# set option from the command line.  Highest precedence.
-sub GNUT_set_from_cmdline($$) {
+# set option from the command line, called from main program.
+# Highest precedence.
+sub GNUT_set_from_cmdline($$)
+{
   my $var = shift;
   my $value = shift;
 
@@ -158,7 +164,8 @@ sub GNUT_set_from_cmdline($$) {
 }
 
 # add default based, for instance, on the format.
-sub GNUT_set_main_program_default($$) {
+sub GNUT_set_main_program_default($$)
+{
   my $var = shift;
   my $value = shift;
 
@@ -173,8 +180,8 @@ sub GNUT_set_main_program_default($$) {
   return 1;
 }
 
-
-# called both from main program and init files.
+# called both from main program and init files, for %options_as_lists
+# options with lists set un main program.
 sub texinfo_add_to_option_list($$)
 {
   my $var = shift;
@@ -207,7 +214,8 @@ sub texinfo_remove_from_option_list($$)
 # This also could get and set some @-command results.
 # FIXME But it does not take into account what happens during conversion,
 # for that something like $converter->get_conf(...) has to be used.
-sub texinfo_get_conf($) {
+sub texinfo_get_conf($)
+{
   my $var = shift;
   if (exists($cmdline_options->{$var})) {
     return $cmdline_options->{$var};
@@ -228,6 +236,25 @@ sub texinfo_add_valid_option($)
 }
 
 
+#####################################################################
+# format API.  Handled differently from customization option because
+# a function from main program need to be called on formats, so
+# there is a function to get the value from main program.
+
+my $init_file_format;
+sub texinfo_set_format_from_init_file($)
+{
+  $init_file_format = shift;
+}
+
+sub GNUT_get_format_from_init_file()
+{
+  return $init_file_format;
+}
+
+
+#####################################################################
+# stages handlers API.  Used in HTML only.
 
 my @possible_stages = ('setup', 'structure', 'init', 'finish');
 my %possible_stages;
@@ -262,6 +289,8 @@ sub GNUT_get_stage_handlers()
   return $GNUT_stage_handlers;
 }
 
+#####################################################################
+# API used to override formatting.  Used in HTML only.
 
 my $GNUT_formatting_references = {};
 my $GNUT_commands_conversion = {};
@@ -392,13 +421,15 @@ sub GNUT_get_style_command_formatting($;$)
   return undef;
 }
 
-package Texinfo::MainConfig;
 
+
+#####################################################################
 # the objective of this small package is to be in another
 # scope than init files, still have access to configuration
 # options, and setup blessed object that can call a
 # get_conf() and set_conf() method like parser or converter
 # that return the same as Texinfo::Config::texinfo_get_conf
+package Texinfo::MainConfig;
 
 # this is used in tests too.  In the tests nothing from
 # Texinfo::Config is used, and it is assumed that the
diff --git a/tp/init/chm.pm b/tp/init/chm.pm
index 273b826..0a67edd 100644
--- a/tp/init/chm.pm
+++ b/tp/init/chm.pm
@@ -37,7 +37,7 @@ use Texinfo::Convert::Utils;
 use Texinfo::Convert::Text;
 use Texinfo::Structuring;
 
-main::set_global_format('html');
+texinfo_set_format_from_init_file('html');
 
 texinfo_set_from_init_file('TOP_FILE', undef);
 
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index adaba05..3dda708 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -549,14 +549,6 @@ sub set_format($;$$)
   return $new_format;
 }
 
-# FIXME used in init/chm.pm main::set_global_format('html'); but this
-# is not a sane interface, should be modified.
-sub set_global_format($)
-{
-  my $set_format = shift;
-  $format = set_format($set_format);
-}
-
 sub document_warn($) {
   return if (get_conf('NO_WARN'));
   my $text = shift;
@@ -992,6 +984,10 @@ sub format_name($)
   }
 }
 
+my $init_file_format = Texinfo::Config::GNUT_get_format_from_init_file();
+if (defined($init_file_format)) {
+  $format = set_format($init_file_format, $format, 1);
+}
 
 if (defined($ENV{'TEXINFO_OUTPUT_FORMAT'}) 
     and $ENV{'TEXINFO_OUTPUT_FORMAT'} ne '') {



reply via email to

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