On Sat, Jul 05, 2025 at 10:29:00AM +0200, Patrice Dumas wrote:
> On Sat, Jul 05, 2025 at 01:06:29AM +0100, Gavin Smith wrote:
> > On Fri, Jul 04, 2025 at 10:18:05PM +0100, Gavin Smith wrote:
> > > All these nodes (in the Sphinx output) have explicit pointers on the
> > > node lines, just like the affected part of the libc manual.
> > >
> > > So I expect we will have to take some account of node pointers
> > > when generating these warnings. (We could still give 1 or 2 warnings if
> > > there is a simple way of doing so, but not 197.)
> >
> > Here's my current version (done in both Perl and C). Only the first block
> > of code is new in each file; the second ("check consistency..."") is
> > just moved from later in the function.
> >
> > As with the existing warnings, node pointers can be used to get the next
> > expected node to appear in a menu.
> >
> > I just need to check through all the changes in the test suite to check
> > if they are satisfactory and tidy up the patch a bit. I probably need
> > one or two more test cases for explicit node pointers.
> >
> >
> > diff --git a/tta/perl/Texinfo/Structuring.pm
> > b/tta/perl/Texinfo/Structuring.pm
> > index 5f79484786..5345b28026 100644
> > --- a/tta/perl/Texinfo/Structuring.pm
> > +++ b/tta/perl/Texinfo/Structuring.pm
> > @@ -844,12 +844,133 @@ sub check_node_tree_menu_structure($)
> > }
> > }
> >
> > + # Go through all the menus and check if they match subordinate
> > + # nodes.
> > + if ($customization_information->get_conf('CHECK_NORMAL_MENU_STRUCTURE'))
> > {
> > + foreach my $node_relations (@{$nodes_list}) {
> > + if ($node_relations->{'menus'}) {
> > + next if !$node_relations->{'associated_section'};
> > + my $section_childs = $node_relations->{'associated_section'}
> > + ->{'section_childs'};
> > + next if !defined($section_childs) or !@{$section_childs};
> > +
>
> In the following code, and also maybe below in the main loop, I think
> that the next section should be used instead of going out of the loop.
> That way, a structure like the following will have checks:
>
> @node chap
> @chapter Chap
>
> @menu
> * with node::
> * ...
> @end menu
>
> @section no node
>
> @node with node
> @section a section with node
Thanks for the suggestion.
>
> ....
>
> > + my $first_child_node_relations =
> > $section_childs->[0]->{'associated_node'};
> > + next if !defined($first_child_node_relations);
> > +
> > + # Set to the first subordinate section, which should appear first
> > in the
> > + # menu.
> > + my ($section_node, $last_menu_node_relations);
> > + $section_node = $first_child_node_relations->{'element'};
> > + next if !defined($section_node);
I used a loop like this:
# Find the first subordinate section, which should appear first
# in the menu.
my $first_child = $section_children->[0];
while (!defined($first_child->{'associated_node'})
and defined($first_child->{'section_directions'})
and defined($first_child->{'section_directions'}->{'next'})) {
$first_child = $first_child->{'section_directions'}->{'next'};
}
my $first_child_node_relations = $first_child->{'associated_node'};
next if !defined($first_child_node_relations);