texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Convert/Utils.


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Convert/Utils.pm (definition_category_tree), tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/maintain/regenerate_commands_perl_info.pl: define %command_index in ParserNonXS.pm, not in Common.pm. Update definition_category_tree() to use directly the command names. Remove %deprecated_commands from Common.pm, do not use values of %deprecated_commands, only the keys. Generate %index_names in regenerate_commands_perl_info.pl and output code that a [...]
Date: Sun, 02 Oct 2022 13:11:59 -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 e75e27f8ca * tp/Texinfo/Common.pm, tp/Texinfo/Convert/Utils.pm 
(definition_category_tree), tp/Texinfo/ParserNonXS.pm 
(_process_remaining_on_line), tp/maintain/regenerate_commands_perl_info.pl: 
define %command_index in ParserNonXS.pm, not in Common.pm.  Update 
definition_category_tree() to use directly the command names. Remove 
%deprecated_commands from Common.pm, do not use values of %deprecated_commands, 
only the keys.  Generate %index_names in regenerate_commands_perl_info.pl a 
[...]
e75e27f8ca is described below

commit e75e27f8ca88602a8a27dc0b714c0f9bfaaac1a0
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Oct 2 19:11:48 2022 +0200

    * tp/Texinfo/Common.pm, tp/Texinfo/Convert/Utils.pm
    (definition_category_tree), tp/Texinfo/ParserNonXS.pm
    (_process_remaining_on_line),
    tp/maintain/regenerate_commands_perl_info.pl: define %command_index
    in ParserNonXS.pm, not in Common.pm.  Update
    definition_category_tree() to use directly the command names.
    Remove %deprecated_commands from Common.pm, do not use values
    of %deprecated_commands, only the keys.  Generate %index_names
    in regenerate_commands_perl_info.pl and output code that adds
    default index commands to %line_commands.
    
    * util/txixml2texi.pl, tp/Texinfo/ParserNonXS.pm: use information
    from Texinfo::Commands.
---
 ChangeLog                                    | 16 ++++++
 tp/Texinfo/Common.pm                         | 34 +----------
 tp/Texinfo/Convert/Utils.pm                  | 12 +++-
 tp/Texinfo/ParserNonXS.pm                    | 85 ++++++++++++++++++----------
 tp/maintain/regenerate_commands_perl_info.pl | 35 ++++++++++++
 util/txixml2texi.pl                          | 24 ++++----
 6 files changed, 130 insertions(+), 76 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 626dd6b6f5..d99209c051 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2022-10-02  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm, tp/Texinfo/Convert/Utils.pm
+       (definition_category_tree), tp/Texinfo/ParserNonXS.pm
+       (_process_remaining_on_line),
+       tp/maintain/regenerate_commands_perl_info.pl: define %command_index
+       in ParserNonXS.pm, not in Common.pm.  Update
+       definition_category_tree() to use directly the command names.
+       Remove %deprecated_commands from Common.pm, do not use values
+       of %deprecated_commands, only the keys.  Generate %index_names
+       in regenerate_commands_perl_info.pl and output code that adds
+       default index commands to %line_commands.
+
+       * util/txixml2texi.pl, tp/Texinfo/ParserNonXS.pm: use information
+       from Texinfo::Commands.
+
 2022-10-02  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Makefile.am, maintain/regenerate_commands_perl_info.pl:
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 181465332f..fbc420628a 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -667,13 +667,6 @@ foreach my $in_index_command ('sortas', 'seeentry', 
'seealso', 'subentry') {
   $in_index_commands{$in_index_command} = 1;
 }
 
-
-# Keys are commmands, values are names of indices.
-our %command_index;
-
-$command_index{'vtable'} = 'vr';
-$command_index{'ftable'} = 'fn';
-
 our %index_names = (
  'cp' => {'in_code' => 0},
  'fn' => {'in_code' => 1},
@@ -693,8 +686,7 @@ foreach my $index_name (keys (%index_names)) {
   my $one_letter_prefix = substr($index_name, 0, 1);
   foreach my $prefix ($index_name, $one_letter_prefix) {
     $line_commands{$prefix.'index'} = 'line';
-    $default_index_commands{$prefix.'index'} = 1;
-    $command_index{$prefix.'index'} = $index_name;
+    $default_index_commands{$prefix.'index'} = $index_name;
   }
 }
 
@@ -890,19 +882,6 @@ our %def_map = (
     'deftypemethod', {'deftypeop' => gdt('Method')},
 );
 
-# the type of index, fn: function, vr: variable, tp: type
-my %index_type_def = (
- 'fn' => ['deffn', 'deftypefn', 'deftypeop', 'defop'],
- 'vr' => ['defvr', 'deftypevr', 'defcv', 'deftypecv' ],
- 'tp' => ['deftp']
-);
-
-foreach my $index_type (keys %index_type_def) {
-  foreach my $def (@{$index_type_def{$index_type}}) {
-    $command_index{$def} = $index_type;
-  }
-}
-
 our %def_commands;
 our %def_aliases;
 # consistent with XS parser flag
@@ -912,7 +891,6 @@ our %def_no_var_arg_commands;
 foreach my $def_command(keys %def_map) {
   if (ref($def_map{$def_command}) eq 'HASH') {
     my ($real_command) = keys (%{$def_map{$def_command}});
-    $command_index{$def_command} = $command_index{$real_command};
     $def_aliases{$def_command} = $real_command;
     $def_aliases{$def_command.'x'} = $real_command.'x';
     $def_alias_commands{$def_command} = 1;
@@ -921,7 +899,6 @@ foreach my $def_command(keys %def_map) {
   $line_commands{$def_command.'x'} = 'line';
   $def_commands{$def_command} = 1;
   $def_commands{$def_command.'x'} = 1;
-  $command_index{$def_command.'x'} = $command_index{$def_command};
   $def_no_var_arg_commands{$def_command} = 1 if ($def_command =~ /^deftype/);
 }
 
@@ -1038,13 +1015,6 @@ foreach my $close_paragraph_command 
(keys(%def_commands)) {
   $close_paragraph_commands{$close_paragraph_command} = 1;
 }
 
-our %deprecated_commands = (
-  'definfoenclose' => '',
-  'refill' => '',
-  'inforef' => '',
-  'centerchap' => '',
-);
-
 my %unformatted_block_commands;
 foreach my $unformatted_block_command ('ignore', 'macro', 'rmacro') {
   $unformatted_block_commands{$unformatted_block_command} = 1;
@@ -2942,7 +2912,7 @@ Hashes are defined as C<our> variables, and are therefore 
available
 outside of the module.
 
 TODO: undocumented
-%null_device_file %default_parser_customization_values 
%document_settable_multiple_at_commands %document_settable_unique_at_commands 
%default_converter_command_line_options 
%default_main_program_customization_options %default_converter_customization 
@variable_string_settables %document_settable_at_commands %def_map 
%command_index %close_paragraph_commands %command_structuring_level 
%level_to_structuring_command
+%null_device_file %default_parser_customization_values 
%document_settable_multiple_at_commands %document_settable_unique_at_commands 
%default_converter_command_line_options 
%default_main_program_customization_options %default_converter_customization 
@variable_string_settables %document_settable_at_commands %def_map 
%close_paragraph_commands %command_structuring_level 
%level_to_structuring_command
 
 =over
 
diff --git a/tp/Texinfo/Convert/Utils.pm b/tp/Texinfo/Convert/Utils.pm
index f4c6357b5a..d55e0dc633 100644
--- a/tp/Texinfo/Convert/Utils.pm
+++ b/tp/Texinfo/Convert/Utils.pm
@@ -126,15 +126,21 @@ sub definition_category_tree($$)
        'args' => [{'type' => 'brace_command_arg', 'contents' => 
[$arg_class]}]};
   }
   
-  my $style = 
$Texinfo::Common::command_index{$current->{'extra'}->{'def_command'}};
-  if ($style eq 'fn') {
+  my $def_command = $current->{'extra'}->{'def_command'};
+  if ($def_command eq 'defop'
+      or $def_command eq 'deftypeop'
+      or $def_command eq 'defmethod'
+      or $def_command eq 'deftypemethod') {
     if ($self) {
       return $self->gdt('{category} on @code{{class}}', { 'category' => 
$arg_category,
                                           'class' => $arg_class });
     } else {
       return {'contents' => [$arg_category, {'text' => ' on '}, 
$arg_class_code]};
     }
-  } elsif ($style eq 'vr') {
+  } elsif ($def_command eq 'defivar'
+           or $def_command eq 'deftypeivar'
+           or $def_command eq 'defcv'
+           or $def_command eq 'deftypecv') {
     if ($self) {
       return $self->gdt('{category} of @code{{class}}', { 'category' => 
$arg_category,
                                           'class' => $arg_class });
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index e09927c161..f1ca5c25b9 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -263,35 +263,69 @@ my %initialization_overrides = (
   'documentlanguage' => 1,
 );
 
-my %nobrace_commands          = %Texinfo::Common::nobrace_commands;
-my %line_commands             = %Texinfo::Common::line_commands;
-my %brace_commands            = %Texinfo::Common::brace_commands;
+my %nobrace_commands          = %Texinfo::Commands::nobrace_commands;
+my %line_commands             = %Texinfo::Commands::line_commands;
+my %brace_commands            = %Texinfo::Commands::brace_commands;
 my %commands_args_number      = %Texinfo::Common::commands_args_number;
-my %accent_commands           = %Texinfo::Common::accent_commands;
+my %accent_commands           = %Texinfo::Commands::accent_commands;
 my %context_brace_commands    = %Texinfo::Common::context_brace_commands;
-my %contain_plain_text_commands = 
%Texinfo::Common::contain_plain_text_commands;
+my %contain_plain_text_commands = 
%Texinfo::Commands::contain_plain_text_commands;
 my %contain_simple_text_commands = 
%Texinfo::Commands::contain_simple_text_commands;
-my %block_commands            = %Texinfo::Common::block_commands;
-my %blockitem_commands        = %Texinfo::Common::blockitem_commands;
+my %block_commands            = %Texinfo::Commands::block_commands;
+my %blockitem_commands        = %Texinfo::Commands::blockitem_commands;
 my %close_paragraph_commands  = %Texinfo::Common::close_paragraph_commands;
+my %def_commands              = %Texinfo::Commands::def_commands;
 my %def_map                   = %Texinfo::Common::def_map;
-my %def_commands              = %Texinfo::Common::def_commands;
 my %def_aliases               = %Texinfo::Common::def_aliases;
-my %def_alias_commands        = %Texinfo::Common::def_alias_commands;
-my %preformatted_commands     = %Texinfo::Common::preformatted_commands;
-my %math_commands             = %Texinfo::Common::math_commands;
-my %deprecated_commands       = %Texinfo::Common::deprecated_commands;
-my %root_commands             = %Texinfo::Common::root_commands;
-my %sectioning_heading_commands     = 
%Texinfo::Common::sectioning_heading_commands;
-my %command_index             = %Texinfo::Common::command_index;
-my %ref_commands              = %Texinfo::Common::ref_commands;
-my %heading_spec_commands     = %Texinfo::Common::heading_spec_commands;
-my %in_heading_spec_commands  = %Texinfo::Common::in_heading_spec_commands;
+my %def_alias_commands        = %Texinfo::Commands::def_alias_commands;
+my %preformatted_commands     = %Texinfo::Commands::preformatted_commands;
+my %math_commands             = %Texinfo::Commands::math_commands;
+my %deprecated_commands       = %Texinfo::Commands::deprecated_commands;
+my %root_commands             = %Texinfo::Commands::root_commands;
+my %sectioning_heading_commands     = 
%Texinfo::Commands::sectioning_heading_commands;
+my %ref_commands              = %Texinfo::Commands::ref_commands;
+my %heading_spec_commands     = %Texinfo::Commands::heading_spec_commands;
+my %in_heading_spec_commands  = %Texinfo::Commands::in_heading_spec_commands;
 my %in_index_commands         = %Texinfo::Common::in_index_commands;
 my %explained_commands        = %Texinfo::Common::explained_commands;
 my %inline_format_commands    = %Texinfo::Common::inline_format_commands;
-my %variadic_commands         = %Texinfo::Common::variadic_commands;
+my %variadic_commands         = %Texinfo::Commands::variadic_commands;
 my %all_commands              = %Texinfo::Common::all_commands;
+my %default_index_commands    = %Texinfo::Commands::default_index_commands;
+
+
+# Keys are commmands, values are names of indices.  User-defined
+# index commands are added dynamically.
+my %command_index;
+
+$command_index{'vtable'} = 'vr';
+$command_index{'ftable'} = 'fn';
+
+foreach my $index_command (keys(%default_index_commands)) {
+  $command_index{$index_command} = $default_index_commands{$index_command};
+}
+
+# the type of index, fn: function, vr: variable, tp: type
+my %index_type_def = (
+ 'fn' => ['deffn', 'deftypefn', 'deftypeop', 'defop'],
+ 'vr' => ['defvr', 'deftypevr', 'defcv', 'deftypecv' ],
+ 'tp' => ['deftp']
+);
+
+foreach my $index_type (keys %index_type_def) {
+  foreach my $def (@{$index_type_def{$index_type}}) {
+    $command_index{$def} = $index_type;
+  }
+}
+
+foreach my $def_command(keys %def_map) {
+  if (ref($def_map{$def_command}) eq 'HASH') {
+    my ($real_command) = keys (%{$def_map{$def_command}});
+    $command_index{$def_command} = $command_index{$real_command};
+  }
+  $command_index{$def_command.'x'} = $command_index{$def_command};
+}
+
 
 # equivalence between a @set flag and an @@-command
 my %set_flag_command_equivalent = (
@@ -542,7 +576,7 @@ foreach my $command (keys(%block_commands)) {
 }
 
 # default indices
-my %index_names = %Texinfo::Common::index_names;
+my %index_names = %Texinfo::Commands::index_names;
 
 # index names that cannot be set by the user.
 my %forbidden_index_name = ();
@@ -4527,15 +4561,8 @@ sub _process_remaining_on_line($$$$)
     }
 
     if (defined($deprecated_commands{$command})) {
-      if ($deprecated_commands{$command} eq '') {
-        $self->_line_warn(sprintf(__("%c%s is obsolete"),
-                            ord('@'), $command), $source_info);
-      } else {
-        $self->_line_warn(sprintf(__("%c%s is obsolete; %s"),
-                                  ord('@'), $command,
-                                  __($deprecated_commands{$command})),
-                          $source_info);
-      }
+      $self->_line_warn(sprintf(__("%c%s is obsolete"),
+                          ord('@'), $command), $source_info);
     }
 
     # special case with @ followed by a newline protecting end of lines
diff --git a/tp/maintain/regenerate_commands_perl_info.pl 
b/tp/maintain/regenerate_commands_perl_info.pl
index 05fd832f0a..fc0e696bc2 100755
--- a/tp/maintain/regenerate_commands_perl_info.pl
+++ b/tp/maintain/regenerate_commands_perl_info.pl
@@ -26,6 +26,16 @@ BEGIN
   $^W = 1;
 }
 
+# need this information to fill in automatically the index commands
+my %index_in_code = (
+ 'cp' => 0,
+ 'fn' => 1,
+ 'vr' => 1,
+ 'ky' => 1,
+ 'pg' => 1,
+ 'tp' => 1,
+);
+
 my %command_categories;
 my %flags_hashes;
 
@@ -105,4 +115,29 @@ foreach my $hash_flag (sort(keys(%flags_hashes))) {
   print OUT ");\n\n";
 }
 
+print OUT "\n";
+print OUT "# indices\n";
+print OUT "our %index_names = (\n";
+foreach my $index_name (sort(keys(%index_in_code))) {
+  my $in_code = $index_in_code{$index_name};
+  print OUT "'$index_name' => {'in_code' => $in_code},\n";
+}
+print OUT ");\n\n";
+
+# add code that sets %line_commands for index commands based on %index_names
+print OUT 'foreach my $index (keys(%index_names)) {
+  $index_names{$index}->{"name"} = $index;
+  $index_names{$index}->{"contained_indices"} = {$index => 1};
+}
+
+our %default_index_commands;
+foreach my $index_name (keys (%index_names)) {
+  my $one_letter_prefix = substr($index_name, 0, 1);
+  foreach my $prefix ($index_name, $one_letter_prefix) {
+    $line_commands{$prefix."index"} = "line";
+    $default_index_commands{$prefix."index"} = $index_name;
+  }
+}
+';
+
 print OUT "1;\n";
diff --git a/util/txixml2texi.pl b/util/txixml2texi.pl
index d42733ca48..8ff5119a59 100755
--- a/util/txixml2texi.pl
+++ b/util/txixml2texi.pl
@@ -81,8 +81,8 @@ BEGIN
 
 use XML::LibXML::Reader;
 
+use Texinfo::Commands;
 # gather information on Texinfo markup language elements
-use Texinfo::Common;
 use Texinfo::Convert::TexinfoMarkup;
 
 my $debug = 0;
@@ -307,14 +307,14 @@ while ($reader->read) {
             
$element_at_commands{$name}->{$attribute}->{$reader->getAttribute($attribute)};
         }
       }
-    } elsif (exists($Texinfo::Common::brace_commands{$name})) {
+    } elsif (exists($Texinfo::Commands::brace_commands{$name})) {
       print "\@${name}\{";
       if ($name eq 'verb' and $reader->hasAttributes()
           and defined($reader->getAttribute('delimiter'))) {
         print $reader->getAttribute('delimiter');
       }
       print "$spaces";
-    } elsif (exists($Texinfo::Common::block_commands{$name})) {
+    } elsif (exists($Texinfo::Commands::block_commands{$name})) {
       print "\@$name";
       if ($name eq 'macro' or $name eq 'rmacro') {
         if ($reader->hasAttributes() and 
defined($reader->getAttribute('line'))) {
@@ -325,8 +325,8 @@ while ($reader->read) {
         # leading spaces are already in the line attribute for (r)macro
         print "$spaces";
       }
-    } elsif (defined($Texinfo::Common::line_commands{$name})
-             or defined($Texinfo::Common::nobrace_commands{$name})
+    } elsif (defined($Texinfo::Commands::line_commands{$name})
+             or defined($Texinfo::Commands::nobrace_commands{$name})
              or $user_defined_index_command) {
       if ($reader->hasAttributes()
           and defined($reader->getAttribute('originalcommand'))) {
@@ -440,8 +440,8 @@ while ($reader->read) {
         print $reader->getAttribute('leadingtext');
       }
     }
-    if ($Texinfo::Common::block_commands{$name}
-        and $Texinfo::Common::block_commands{$name} eq 'item_line'
+    if ($Texinfo::Commands::block_commands{$name}
+        and $Texinfo::Commands::block_commands{$name} eq 'item_line'
         and $reader->hasAttributes()
         and defined($reader->getAttribute('commandarg'))) {
       print '@'.$reader->getAttribute('commandarg');
@@ -463,13 +463,13 @@ while ($reader->read) {
         print '}';
       }
     }
-    if (exists ($Texinfo::Common::brace_commands{$name})) {
+    if (exists ($Texinfo::Commands::brace_commands{$name})) {
       if ($name eq 'verb' and $reader->hasAttributes()
           and defined($reader->getAttribute('delimiter'))) {
         print $reader->getAttribute('delimiter');
       }
       print '}';
-    } elsif (exists($Texinfo::Common::block_commands{$name})) {
+    } elsif (exists($Texinfo::Commands::block_commands{$name})) {
       my $end_spaces;
       if ($reader->hasAttributes()
           and defined($reader->getAttribute('endspaces'))) {
@@ -477,9 +477,9 @@ while ($reader->read) {
       }
       $end_spaces = ' ' if (!defined($end_spaces) or $end_spaces eq '');
       print "\@end".$end_spaces."$name";
-    } elsif (defined($Texinfo::Common::line_commands{$name})
-             or defined($Texinfo::Common::nobrace_commands{$name})) {
-      if ($Texinfo::Common::root_commands{$name} and $name ne 'node') {
+    } elsif (defined($Texinfo::Commands::line_commands{$name})
+             or defined($Texinfo::Commands::nobrace_commands{$name})) {
+      if ($Texinfo::Commands::root_commands{$name} and $name ne 'node') {
         $eat_space = 1;
       }
       print "$trailingspaces";



reply via email to

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