texinfo-commits
[Top][All Lists]
Advanced

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

[6441] new command validatemenus


From: Gavin D. Smith
Subject: [6441] new command validatemenus
Date: Tue, 21 Jul 2015 15:16:31 +0000

Revision: 6441
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6441
Author:   gavin
Date:     2015-07-21 15:16:29 +0000 (Tue, 21 Jul 2015)
Log Message:
-----------
new command validatemenus

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/NEWS
    trunk/tp/Texinfo/Common.pm
    trunk/tp/Texinfo/Parser.pm
    trunk/tp/Texinfo/Structuring.pm
    trunk/tp/texi2any.pl

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2015-07-20 19:26:22 UTC (rev 6440)
+++ trunk/ChangeLog     2015-07-21 15:16:29 UTC (rev 6441)
@@ -1,3 +1,22 @@
+2015-07-21  Gavin Smith  <address@hidden>
+
+       * NEWS: Mention new command @validatemenus.
+       * tp/Texinfo/Common.pm (%default_parser_state_configuration): 
+       Add validatemenus flag.
+       (%misc_commands): Add 'validatemenus'.
+       * tp/Texinfo/Parser.pm (_end_line) <@validatemenus>: Set flag on 
+       parser.
+       (_parse_line_command_args): Accept 'on' and 'off' as the 
+       argument to @validatemenus.
+
+       * tp/Texinfo/Structuring.pm (add_missing_menus): New function, 
+       based on complete_tree_nodes_menus.
+       (add_node_menu_if_missing): New function, based on 
+       complete_node_menu.
+
+       * tp/texi2any.pl: Call add_missing_menus if 'validatemenus' flag 
+       is not turned on in parser object.
+
 2015-07-20  Gavin Smith  <address@hidden>
 
        * info/man.c (xrefs_of_manpage): An open parenthesis precededed 

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS  2015-07-20 19:26:22 UTC (rev 6440)
+++ trunk/NEWS  2015-07-21 15:16:29 UTC (rev 6441)
@@ -22,6 +22,13 @@
   
http://www.gnu.org/software/texinfo/manual/texinfo/html_node/Document-Permissions.html
 
 -------------------------------------------------------------------------------
+* Language:
+  . You can now optionally miss out the @menu from nodes with other
+    nodes below them in the document structure.  The new command 
+    @validatemenus controls whether to check that @menu is given in 
+    these circumstances.  For Info and HTML output, makeinfo will, when 
+    needed, create a menu for nodes lacking one given explicitly.
+
 * makeinfo
   . quotation marks are left out for node names and index entries in
     Info output where they would have been produced by commands such

Modified: trunk/tp/Texinfo/Common.pm
===================================================================
--- trunk/tp/Texinfo/Common.pm  2015-07-20 19:26:22 UTC (rev 6440)
+++ trunk/tp/Texinfo/Common.pm  2015-07-21 15:16:29 UTC (rev 6441)
@@ -71,7 +71,7 @@
 @EXPORT = qw(
 );
 
-$VERSION = '6.0';
+$VERSION = '6.0dev';
 
 # i18n
 sub N__($)
@@ -127,6 +127,7 @@
                               # as obtained by parsing the @macro
   'merged_indices' => {},     # the key is merged in the value
   'novalidate' => 0,          # same as setting @novalidate.
+  'validatemenus' => 0,       # same as setting @validatemenus.
   'sections_level' => 0,      # modified by raise/lowersections
   'values' => {'txicommandconditionals' => 1},
                               # the key is the name, the value the @set name 
@@ -175,6 +176,7 @@
   'fonttextsize' => 11, 
   'footnotestyle' => 'end', 
   'novalidate' => 0,
+  'validatemenus' => 0,
   'oddfootingmarks' => undef,
   'oddheadingmarks' => undef,
   # FIXME not clear here.
@@ -428,6 +430,7 @@
   'setshortcontentsaftertitlepage' => 'skipline', # no arg
   'documentencoding'  => 'text', # or 1?
   'novalidate'        => 'skipline', # no arg
+  'validatemenus'     => 1, # on off
   'dircategory'       => 'line', # line. Position with regard 
                                  # with direntry is significant
   'pagesizes'         => 'line', # can have 2 args 

Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm  2015-07-20 19:26:22 UTC (rev 6440)
+++ trunk/tp/Texinfo/Parser.pm  2015-07-21 15:16:29 UTC (rev 6441)
@@ -92,7 +92,7 @@
 @EXPORT = qw(
 );
 
-$VERSION = '6.0';
+$VERSION = '6.0dev';
 
 sub N__($)
 {
@@ -3270,6 +3270,16 @@
     if ($self->{'misc_commands'}->{$command} =~ /^\d$/) {
       my $args = _parse_line_command_args($self, $current, $line_nr);
       $current->{'extra'}->{'misc_args'} = $args if (defined($args));
+      if ($command eq 'validatemenus') {
+        if ($args and $args->[0]) {
+          my $arg = $args->[0];
+          if ($arg eq 'on') {
+            $self->{'validatemenus'} = 1;
+          } elsif ($arg eq 'off') {
+            $self->{'validatemenus'} = 0;
+          }
+        }
+      }
     } elsif ($self->{'misc_commands'}->{$command} eq 'text') {
       my $text = Texinfo::Convert::Text::convert($current->{'args'}->[0],
                                                  {'code' => 1, 
@@ -5957,6 +5967,7 @@
            or $command eq 'xrefautomaticsectiontitle'
            or $command eq 'codequoteundirected'
            or $command eq 'codequotebacktick'
+           or $command eq 'validatemenus'
            or $command eq 'deftypefnnewline') {
     if ($line eq 'on' or $line eq 'off') {
       $args = [$line];

Modified: trunk/tp/Texinfo/Structuring.pm
===================================================================
--- trunk/tp/Texinfo/Structuring.pm     2015-07-20 19:26:22 UTC (rev 6440)
+++ trunk/tp/Texinfo/Structuring.pm     2015-07-21 15:16:29 UTC (rev 6441)
@@ -43,6 +43,7 @@
 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
 # will save memory.
 %EXPORT_TAGS = ( 'all' => [ qw(
+  add_missing_menus
   associate_internal_references
   complete_tree_nodes_menus
   elements_directions
@@ -69,7 +70,7 @@
 @EXPORT = qw(
 );
 
-$VERSION = '6.0';
+$VERSION = '6.0dev';
 
 
 my %types_to_enter;
@@ -1683,6 +1684,40 @@
   return $new_block;
 }
 
+sub add_node_menu_if_missing($$)
+{
+  my $self = shift;
+  my $node = shift;
+  
+  if (!$node->{'extra'}->{'associated_section'}->{'section_childs'}
+      or $node->{'menus'} and @{$node->{'menus'}}) {
+    return;
+  }
+
+  my @node_childs;
+  foreach my $child 
(@{$node->{'extra'}->{'associated_section'}->{'section_childs'}}) {
+    if ($child->{'extra'} and $child->{'extra'}->{'associated_node'}) {
+      push @node_childs, $child->{'extra'}->{'associated_node'};
+    }
+  }
+
+  my @pending;
+  for my $child (@node_childs) {
+    my $entry = _new_node_menu_entry($self, 
+                                     $child->{'extra'}->{'node_content'});
+    push @pending, $entry;
+  }
+
+  # Add a menu to this node
+  my $section = $node->{'extra'}->{'associated_section'};
+  my $current_menu = _new_block_command (address@hidden, $section, 'menu');
+  push @{$section->{'contents'}}, $current_menu;
+  push @{$section->{'contents'}}, {'type' => 'empty_line',
+                                   'text' => "\n", 
+                                   'parent' => $section};
+  push @{$node->{'menus'}}, $current_menu;
+}
+
 sub complete_node_menu($$)
 {
   my $self = shift;
@@ -1784,6 +1819,25 @@
 }
 
 # This should be called after sectioning_structure
+sub add_missing_menus($$)
+{
+  my $self = shift;
+  my $root = shift;
+  if (!$root->{'type'} or $root->{'type'} ne 'document_root'
+      or !$root->{'contents'}) {
+    return undef;
+  }
+  foreach my $content (@{$root->{'contents'}}) {
+    if ($content->{'cmdname'} and $content->{'cmdname'} eq 'node'
+        and (scalar(@{$content->{'extra'}->{'nodes_manuals'}}) == 1)
+        and $content->{'extra'} 
+        and $content->{'extra'}->{'associated_section'}) {
+      add_node_menu_if_missing($self, $content);
+    }
+  }
+}
+
+# This should be called after sectioning_structure
 sub complete_tree_nodes_menus($$)
 {
   my $self = shift;

Modified: trunk/tp/texi2any.pl
===================================================================
--- trunk/tp/texi2any.pl        2015-07-20 19:26:22 UTC (rev 6440)
+++ trunk/tp/texi2any.pl        2015-07-21 15:16:29 UTC (rev 6441)
@@ -1302,7 +1302,10 @@
 
   if ($tree_transformations{'complete_tree_nodes_menus'}) {
     Texinfo::Structuring::complete_tree_nodes_menus($parser, $tree);
+  } elsif (!$parser->{'validatemenus'}) {
+    Texinfo::Structuring::add_missing_menus($parser, $tree);
   }
+
   if ($tree_transformations{'indent_menu_descriptions'}) {
     Texinfo::Convert::Plaintext::indent_menu_descriptions(undef, $parser);
   }




reply via email to

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