texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Separate directory and loading function for init


From: Patrice Dumas
Subject: branch master updated: Separate directory and loading function for init files used internally
Date: Sat, 30 Jul 2022 11:06:37 -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 9853f86e4e Separate directory and loading function for init files used 
internally
9853f86e4e is described below

commit 9853f86e4e22ed9872d03b4266ad770953f8160a
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jul 30 17:06:24 2022 +0200

    Separate directory and loading function for init files used internally
    
    * tp/texi2any.pl (locate_and_load_extension_file), tp/Makefile.am
    (extensionsdir): use a different function to load init files used
    in texi2any, to search only in code directory.  Put those init
    files in tp/ext, installed in $(datadir)/texinfo/.  Use the directory
    last in user init files search such that the files can still be
    loaded with --init.  Call those init files 'extensions'.
---
 ChangeLog                      | 11 +++++++++++
 tp/Makefile.am                 | 10 +++++++---
 tp/{init => ext}/epub3.pm      |  0
 tp/{init => ext}/latex2html.pm |  0
 tp/{init => ext}/tex4ht.pm     |  0
 tp/tests/layout/list-of-tests  |  2 +-
 tp/texi2any.pl                 | 45 +++++++++++++++++++++++++++++++-----------
 7 files changed, 53 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bf5ad70a6a..4e79ff71e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-07-30  Patrice Dumas  <pertusus@free.fr>
+
+       Separate directory and loading function for init files used internally
+
+       * tp/texi2any.pl (locate_and_load_extension_file), tp/Makefile.am
+       (extensionsdir): use a different function to load init files used
+       in texi2any, to search only in code directory.  Put those init
+       files in tp/ext, installed in $(datadir)/texinfo/.  Use the directory
+       last in user init files search such that the files can still be
+       loaded with --init.  Call those init files 'extensions'.
+
 2022-07-30  Gavin Smith  <gavinsmith0123@gmail.com>
 
        * doc/texinfo.tex (\makedefun): Edit comment.  No functional change.
diff --git a/tp/Makefile.am b/tp/Makefile.am
index d5cd05ebad..0fdda3fd97 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -110,14 +110,18 @@ debugmodulesdir = $(pkgdatadir)/DebugTexinfo
 dist_debugmodules_DATA = \
  DebugTexinfo/DebugTree.pm
 
+# extensions used in main program
+extensionsdir = $(datadir)/texinfo/ext
+dist_extensions_DATA = \
+ ext/epub3.pm \
+ ext/tex4ht.pm \
+ ext/latex2html.pm
+
 initdir = $(datadir)/texinfo/init
 dist_init_DATA = \
  init/book.pm \
  init/chm.pm \
- init/epub3.pm \
  init/html32.pm \
- init/tex4ht.pm \
- init/latex2html.pm \
  init/highlight_syntax.pm
 
 test_files = \
diff --git a/tp/init/epub3.pm b/tp/ext/epub3.pm
similarity index 100%
rename from tp/init/epub3.pm
rename to tp/ext/epub3.pm
diff --git a/tp/init/latex2html.pm b/tp/ext/latex2html.pm
similarity index 100%
rename from tp/init/latex2html.pm
rename to tp/ext/latex2html.pm
diff --git a/tp/init/tex4ht.pm b/tp/ext/tex4ht.pm
similarity index 100%
rename from tp/init/tex4ht.pm
rename to tp/ext/tex4ht.pm
diff --git a/tp/tests/layout/list-of-tests b/tp/tests/layout/list-of-tests
index 1ba9640acc..45b635e77a 100644
--- a/tp/tests/layout/list-of-tests
+++ b/tp/tests/layout/list-of-tests
@@ -39,7 +39,7 @@ formatting_exotic formatting.texi --split section --no-header 
--no-number-sectio
 formatting_inline_css formatting.texi -c 'INLINE_CSS_STYLE 1' -c 
DOCTYPE='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";>'
 formatting_fr_icons formatting.texi --document-language fr --init icons.init
 formatting_chm formatting.texi -c FORMAT_MENU=nomenu --init chm.pm
-formatting_epub formatting.texi --init epub3.pm -c 'EPUB_CREATE_CONTAINER 0'
+formatting_epub formatting.texi --epub3 -c 'EPUB_CREATE_CONTAINER 0'
 formatting_epub_nodes formatting.texi --split node --init epub3.pm -c 
'EPUB_CREATE_CONTAINER 0' -c INFO_JS_DIR=js
 formatting formatting.texi 
--internal-links=@OUT_DIR@internal_links_formatting.txt
 
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 0acccf3a43..8ad4daa759 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -173,6 +173,15 @@ if ((defined($ENV{"LC_ALL"}) and $ENV{"LC_ALL"} =~ 
/^(C|POSIX)$/)
   delete $ENV{"LANGUAGE"} if defined($ENV{"LANGUAGE"});
 }
 
+my $extensions_dir;
+if ($Texinfo::ModulePath::texinfo_uninstalled) {
+  $extensions_dir = File::Spec->catdir($Texinfo::ModulePath::top_srcdir,
+                                       'tp', 'ext');
+} else {
+  $extensions_dir = File::Spec->catdir($Texinfo::ModulePath::pkgdatadir, 
'ext');
+}
+
+my $internal_extension_dirs = [$extensions_dir];
 
 #my $messages_textdomain = 'texinfo';
 my $messages_textdomain = '@PACKAGE@';
@@ -357,6 +366,10 @@ foreach my $texinfo_config_dir (@language_config_dirs) {
   push @program_init_dirs, File::Spec->catdir($texinfo_config_dir, 'init');
 }
 
+# add texi2any extensions dir too, such as the init files there
+# can also be loaded as regular init files.
+push @program_init_dirs, $extensions_dir;
+
 sub _decode_i18n_string($$)
 {
   my $string = shift;
@@ -412,6 +425,24 @@ sub locate_and_load_init_file($$)
   }
 }
 
+# arguments are binary strings.
+# Init files that are used in texi2any, considered
+# as internal extensions code.
+sub locate_and_load_extension_file($$)
+{
+  my $filename = shift;
+  my $directories = shift;
+
+  my $file = Texinfo::Common::locate_init_file($filename, $directories, 0);
+  if (defined($file)) {
+    # evaluate the code in the Texinfo::Config namespace
+    Texinfo::Config::GNUT_load_init_file($file);
+  } else {
+    die _encode_message(sprintf(__("could not read extension file %s"),
+                                 _decode_input($filename)));
+  }
+}
+
 sub set_from_cmdline($$) {
   return &Texinfo::Config::GNUT_set_from_cmdline(@_);
 }
@@ -1036,7 +1067,7 @@ There is NO WARRANTY, to the extent permitted by 
law.\n"), "2021");
  'epub3' => sub {
    $format = set_format('html');
    my $epub_file = 'epub3.pm';
-   locate_and_load_init_file($epub_file, [ @conf_dirs, @program_init_dirs ]);
+   locate_and_load_extension_file($epub_file, $internal_extension_dirs);
  },
  'latex' => sub {$format = set_format($_[0].'');},
  'info' => sub {$format = set_format($_[0].'');},
@@ -1051,7 +1082,6 @@ There is NO WARRANTY, to the extent permitted by 
law.\n"), "2021");
 );
 
 
-
 exit 1 if (!$result_options);
 
 # those are strings combined with output so decode
@@ -1073,23 +1103,16 @@ sub process_config {
 
 process_config($cmdline_options);
 
-# The configuration API is setup such that the loading of init
-# files can be done here and not in format specific code.  There is
-# only one format, HTML, with use of complex customization (besides setting
-# customization options), so maybe this would need to be revisited
-# if another format uses complex customization.
 my $latex2html_file = 'latex2html.pm';
 if (defined($cmdline_options->{'HTML_MATH'})
       and $cmdline_options->{'HTML_MATH'} eq 'l2h') {
-  locate_and_load_init_file($latex2html_file, 
-                        [ @conf_dirs, @program_init_dirs ]);
+  locate_and_load_extension_file($latex2html_file, $internal_extension_dirs);
 }
 
 my $tex4ht_file = 'tex4ht.pm';
 if (defined($cmdline_options->{'HTML_MATH'})
       and $cmdline_options->{'HTML_MATH'} eq 't4h') {
-  locate_and_load_init_file($tex4ht_file, 
-                        [ @conf_dirs, @program_init_dirs ]);
+  locate_and_load_extension_file($tex4ht_file, $internal_extension_dirs);
 }
 
 # For tests, set some strings to values not changing with releases



reply via email to

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