[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[8252] move htmlxref.cnf code to HTML.pm
From: |
gavinsmith0123 |
Subject: |
[8252] move htmlxref.cnf code to HTML.pm |
Date: |
Sun, 30 Sep 2018 06:26:36 -0400 (EDT) |
Revision: 8252
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8252
Author: gavin
Date: 2018-09-30 06:26:36 -0400 (Sun, 30 Sep 2018)
Log Message:
-----------
move htmlxref.cnf code to HTML.pm
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Common.pm
trunk/tp/Texinfo/Convert/Converter.pm
trunk/tp/Texinfo/Convert/HTML.pm
trunk/tp/texi2any.pl
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2018-09-30 09:12:53 UTC (rev 8251)
+++ trunk/ChangeLog 2018-09-30 10:26:36 UTC (rev 8252)
@@ -1,5 +1,20 @@
2018-09-30 Gavin Smith <address@hidden>
+ * tp/Texinfo/Converter/Converter.pm (%all_converter_defaults):
+ Remove 'htmlxref_files' and 'FIX_TEXINFO'. Add
+ 'language_config_dirs'.
+
+ * tp/texi2any.pl: Do not set an 'htmlxref_files' configuration
+ value. Save the 'language_config_dirs' array in the converter
+ options.
+ * tp/Texinfo/Convert/HTML.pm (_load_htmlxref_files): Move code
+ here from texi2any.pl.
+
+ * tp/texi2any.pl, tp/Texinfo/Common.pm (locate_init_file):
+ Move to Common.pm.
+
+2018-09-30 Gavin Smith <address@hidden>
+
* tp/texi2any.pl: Get class of converter from string value,
rather than calling ref on a subroutine. This subroutine would
actually be called, which is not the intention.
Modified: trunk/tp/Texinfo/Common.pm
===================================================================
--- trunk/tp/Texinfo/Common.pm 2018-09-30 09:12:53 UTC (rev 8251)
+++ trunk/tp/Texinfo/Common.pm 2018-09-30 10:26:36 UTC (rev 8252)
@@ -994,6 +994,36 @@
'November', 'December'
);
+# file: file name to locate. It can be a file path.
+# directories: a reference on a array containing a list of directories to
+# search the file in.
+# all_files: if true collect all the files with that name, otherwise stop
+# at first match.
+sub locate_init_file($$$)
+{
+ my $file = shift;
+ my $directories = shift;
+ my $all_files = shift;
+
+ if (File::Spec->file_name_is_absolute($file)) {
+ return $file if (-e $file and -r $file);
+ } else {
+ my @files;
+ foreach my $dir (@$directories) {
+ next unless (-d $dir);
+ my $possible_file = File::Spec->catfile($dir, $file);
+ if ($all_files) {
+ push (@files, $possible_file)
+ if (-e $possible_file and -r $possible_file);
+ } else {
+ return $possible_file if (-e $possible_file and -r $possible_file);
+ }
+ }
+ return @files if ($all_files);
+ }
+ return undef;
+}
+
sub locate_include_file($$)
{
my $self = shift;
Modified: trunk/tp/Texinfo/Convert/Converter.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Converter.pm 2018-09-30 09:12:53 UTC (rev
8251)
+++ trunk/tp/Texinfo/Convert/Converter.pm 2018-09-30 10:26:36 UTC (rev
8252)
@@ -73,7 +73,7 @@
# 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.
our %all_converters_defaults = (
- 'htmlxref_files' => undef,
+ 'language_config_dirs' => undef,
'output_format' => undef,
'SPLIT_SIZE' => 300000,
'paragraphindent' => 3,
@@ -90,8 +90,6 @@
'footnotestyle' => 'end',
'deftypefnnewline' => 'off',
'BASEFILENAME_LENGTH' => 255 - 10,
-# This is not used much as converters do their best to give a sane output
- 'FIX_TEXINFO' => 1,
# This is the default, mainly for tests; the caller should set them. These
# values are what is used in tests of the Converters.
'PACKAGE_AND_VERSION' => 'texinfo',
Modified: trunk/tp/Texinfo/Convert/HTML.pm
===================================================================
--- trunk/tp/Texinfo/Convert/HTML.pm 2018-09-30 09:12:53 UTC (rev 8251)
+++ trunk/tp/Texinfo/Convert/HTML.pm 2018-09-30 10:26:36 UTC (rev 8252)
@@ -4735,6 +4735,46 @@
return $htmlxref;
}
+sub _load_htmlxref_files {
+ my ($self) = @_;
+
+ my @htmlxref_dirs = ();
+ if ($self->get_conf('TEST')) {
+ my $curdir = File::Spec->curdir();
+ # to have reproducible tests, do not use system or user
+ # directories if TEST is set.
+ @htmlxref_dirs = File::Spec->catdir($curdir, '.texinfo');
+ } elsif ($self->{'language_config_dirs'}
+ and @{$self->{'language_config_dirs'}}) {
+ @htmlxref_dirs = @{$self->{'language_config_dirs'}};
+ }
+ my $input_directory = $self->{'info'}->{'input_directory'}
+ if $self->{'info'}->{'input_directory'};
+ if (defined($input_directory)
+ and $input_directory ne '.' and $input_directory ne '') {
+ unshift @htmlxref_dirs, $input_directory;
+ }
+ unshift @htmlxref_dirs, '.';
+
+ my @texinfo_htmlxref_files;
+ my $init_file_from_conf = $self->get_conf('HTMLXREF');
+ if ($init_file_from_conf) {
+ @texinfo_htmlxref_files = ( $init_file_from_conf );
+ } else {
+ @texinfo_htmlxref_files
+ = Texinfo::Common::locate_init_file ('htmlxref.cnf',
+ address@hidden, 1);
+ }
+ $self->{'htmlxref_files'} = address@hidden;
+
+ $self->{'htmlxref'} = {};
+ if ($self->{'htmlxref_files'}) {
+ $self->{'htmlxref'} = _parse_htmlxref_files($self,
+ $self->{'htmlxref_files'});
+ }
+}
+
+
sub converter_initialize($)
{
my $self = shift;
@@ -4749,11 +4789,7 @@
%{$self->{'css_map'}} = %css_map;
- $self->{'htmlxref'} = {};
- if ($self->{'htmlxref_files'}) {
- $self->{'htmlxref'} = _parse_htmlxref_files($self,
- $self->{'htmlxref_files'});
- }
+ _load_htmlxref_files($self);
foreach my $type (keys(%default_types_conversion)) {
if (exists($Texinfo::Config::texinfo_types_conversion{$type})) {
Modified: trunk/tp/texi2any.pl
===================================================================
--- trunk/tp/texi2any.pl 2018-09-30 09:12:53 UTC (rev 8251)
+++ trunk/tp/texi2any.pl 2018-09-30 10:26:36 UTC (rev 8252)
@@ -318,7 +318,6 @@
# determine configuration directories.
my $conf_file_name = 'Config' ;
-my $texinfo_htmlxref = 'htmlxref.cnf';
# directories for texinfo configuration files
my @language_config_dirs = File::Spec->catdir($curdir, '.texinfo');
@@ -433,42 +432,12 @@
}
# back in main program namespace
-# file: file name to locate. It can be a file path.
-# directories: a reference on a array containing a list of directories to
-# search the file in.
-# all_files: if true collect all the files with that name, otherwise stop
-# at first match.
-sub locate_init_file($$$)
-{
- my $file = shift;
- my $directories = shift;
- my $all_files = shift;
-
- if (File::Spec->file_name_is_absolute($file)) {
- return $file if (-e $file and -r $file);
- } else {
- my @files;
- foreach my $dir (@$directories) {
- next unless (-d $dir);
- my $possible_file = File::Spec->catfile($dir, $file);
- if ($all_files) {
- push (@files, $possible_file)
- if (-e $possible_file and -r $possible_file);
- } else {
- return $possible_file if (-e $possible_file and -r $possible_file);
- }
- }
- return @files if ($all_files);
- }
- return undef;
-}
-
sub locate_and_load_init_file($$)
{
my $filename = shift;
my $directories = shift;
- my $file = locate_init_file($filename, $directories, 0);
+ my $file = Texinfo::Common::locate_init_file($filename, $directories, 0);
if (defined($file)) {
Texinfo::Config::_load_init_file($file);
} else {
@@ -477,7 +446,7 @@
}
# read initialization files
-foreach my $file (locate_init_file($conf_file_name,
+foreach my $file (Texinfo::Common::locate_init_file($conf_file_name,
[ reverse(@program_config_dirs) ], 1)) {
Texinfo::Config::_load_init_file($file);
}
@@ -1163,28 +1132,6 @@
my $input_file_base = $input_file_name;
$input_file_base =~ s/\.te?x(i|info)?$//;
- my @htmlxref_dirs;
- if (get_conf('TEST')) {
- # to have reproducible tests, do not use system or user
- # directories if TEST is set.
- @htmlxref_dirs = File::Spec->catdir($curdir, '.texinfo');
- } else {
- @htmlxref_dirs = @language_config_dirs;
- }
- if ($input_directory ne '.' and $input_directory ne '') {
- unshift @htmlxref_dirs, $input_directory;
- }
- unshift @htmlxref_dirs, '.';
-
- my @texinfo_htmlxref_files;
- my $init_file_from_conf = get_conf('HTMLXREF');
- if ($init_file_from_conf) {
- @texinfo_htmlxref_files = ( $init_file_from_conf );
- } else {
- @texinfo_htmlxref_files
- = locate_init_file ($texinfo_htmlxref, address@hidden, 1);
- }
-
my $parser_options = { %$parser_default_options };
$parser_options->{'include_directories'} = address@hidden;
@@ -1329,7 +1276,9 @@
$converter_options->{'parser'} = $parser;
$converter_options->{'output_format'} = $format;
- $converter_options->{'htmlxref_files'} = address@hidden;
+ $converter_options->{'language_config_dirs'} = address@hidden;
+
+
my $converter =
&{$formats_table{$format}->{'converter'}}($converter_options);
$converter->output($tree);
push @opened_files, $converter->converter_opened_files();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [8252] move htmlxref.cnf code to HTML.pm,
gavinsmith0123 <=