texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Structuring.pm (_check_referenced_no


From: Gavin D. Smith
Subject: branch master updated: * tp/Texinfo/Structuring.pm (_check_referenced_nodes): New function to centralize code for checking referenced nodes. (nodes_tree): Call it.
Date: Sat, 20 Feb 2021 17:08:34 -0500

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 0839cef  * tp/Texinfo/Structuring.pm (_check_referenced_nodes): New 
function to centralize code for checking referenced nodes. (nodes_tree): Call 
it.
0839cef is described below

commit 0839cef737c45d4a5b1726477b1a596b212d8cd9
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Feb 20 22:08:17 2021 +0000

    * tp/Texinfo/Structuring.pm (_check_referenced_nodes):
    New function to centralize code for checking referenced nodes.
    (nodes_tree): Call it.
---
 ChangeLog                 |  6 ++++++
 tp/Texinfo/Structuring.pm | 45 +++++++++++++++++++++++++++------------------
 2 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 72a9511..def818d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2021-02-20  Gavin Smith  <gavinsmith0123@gmail.com>
 
+       * tp/Texinfo/Structuring.pm (_check_referenced_nodes):
+       New function to centralize code for checking referenced nodes.
+       (nodes_tree): Call it.
+
+2021-02-20  Gavin Smith  <gavinsmith0123@gmail.com>
+
        No footer for several nodes in a file.
 
        * tp/Texinfo/Convert/HTML.pm (_default_format_element_footer):
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 34658ec..2c6accc 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -400,6 +400,32 @@ sub _check_menu_entry($$$)
   }
 }
 
+sub _check_referenced_nodes
+{
+  my ($self, $top_node) = @_;
+
+  my %referenced_nodes = ($top_node => 1);
+  foreach my $node (@{$self->{'nodes'}}) {
+    # gather referenced nodes based on node pointers
+    foreach my $direction (@node_directions) {
+      if ($node->{'node_'.$direction}
+          and not $node->{'node_'.$direction}->{'extra'}->{'manual_content'}) {
+        $referenced_nodes{$node->{'node_'.$direction}} = 1;
+      }
+    }
+    if ($node->{'menu_up_hash'}) {
+      $referenced_nodes{$node} = 1;
+    }
+  }
+  foreach my $node (@{$self->{'nodes'}}) {
+    if (not exists($referenced_nodes{$node})) {
+      $self->line_warn(sprintf(__("node `%s' unreferenced"),
+          node_extra_to_texi($node->{'extra'})),
+           $node->{'line_nr'});
+    }
+  }
+}
+
 # set node and menu directions, and check consistency
 sub nodes_tree($)
 {
@@ -491,7 +517,6 @@ sub nodes_tree($)
 
   # Go through all the nodes and set directions.
   $top_node = $self->{'nodes'}->[0] if (!$top_node);
-  my %referenced_nodes = ($top_node => 1);
   foreach my $node (@{$self->{'nodes'}}) {
     my $automatic_directions = 
       (scalar(@{$node->{'extra'}->{'nodes_manuals'}}) == 1);
@@ -635,16 +660,6 @@ sub nodes_tree($)
         }
       }
     }
-    # gather referenced nodes based on node pointers
-    foreach my $direction (@node_directions) {
-      if ($node->{'node_'.$direction}
-          and not $node->{'node_'.$direction}->{'extra'}->{'manual_content'}) {
-        $referenced_nodes{$node->{'node_'.$direction}} = 1;
-      }
-    }
-    if ($node->{'menu_up_hash'}) {
-      $referenced_nodes{$node} = 1;
-    }
 
     # check for node up / menu up mismatch
     if ($self->get_conf('CHECK_NORMAL_MENU_STRUCTURE')
@@ -675,13 +690,7 @@ sub nodes_tree($)
       # FIXME check that node_up is not an external node (except for Top)?
     }
   }
-  foreach my $node (@{$self->{'nodes'}}) {
-    if (not exists($referenced_nodes{$node})){
-      $self->line_warn(sprintf(__("node `%s' unreferenced"),
-          node_extra_to_texi($node->{'extra'})),
-           $node->{'line_nr'});
-    }
-  }
+  _check_referenced_nodes($self, $top_node);
   $self->{'structuring'}->{'top_node'} = $top_node;
   return $top_node;
 }



reply via email to

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