On Wed, May 28, 2025 at 09:23:15AM +0200, Patrice Dumas wrote: > > It could be possible to write completely new code just checking for > > faults, which doesn't rely on "menu directions" at all. (It may not be > > clear to the user what "menu directions" are as these are an abstraction > > created internally by texi2any.) For example, we could record structural > > flaws that involve groups of nodes, and then output all the warnings in > > one go, rather than reporting the warnings node-by-node. > > I would be more cautious about not using "menu directions". To me menu > directions are a useful abstraction, which is not internal to texi2any, > it is a representation of the tree obtained with menus, it is a property > of the Texinfo manual. The checks can probably be done without the menu > directions, but my feeling is that it is easier with menu directions.
Well, node directions are not uniquely determined from menus, as a node can be referred to in more than one menu. For example, in the following input, "Node 1" occurs in a menu twice: \input texinfo @node Top @top @menu * Foo:: * Bar:: @end menu @node Foo @menu * Node1:: * Node2:: @end menu @node Bar @menu * Node1:: * Node3:: @end menu @node Node1 Node 1 @node Node2 Node 2 @node Node3 Node 3 @bye The directions for Node1 are taken from the menus in other nodes, but the "next" direction could be both Node2 (in Foo) and Node3 (in Bar). Likewise, "up" for Node1 could be both Foo and Bar. I checked that the later node in the input takes priority at present when outputting Info, so "next" for Node1 is Node3, and "up" for Node3 is Bar. I think it's fine and good to deduce such node pointers from the menus, but I think this should be confined to the structuring code. I don't think that "menu directions" are useful beyond that. As far as I can tell they are not used in any output converter. Another issue with reporting on errors with "menu directions" is that the error message does not refer to the location of the menu, but on the node the directions are set for. For example: $ cat test2.texi \input texinfo @node Top @chapter Top @menu * One:: * Three:: @end menu @node One @chapter One @node Two @chapter Two @node Three @chapter Three @bye $ ../tta/perl/texi2any.pl test2.texi test2.texi:11: warning: node `Top' is up for `One' in menu but not in sectioning test2.texi:11: warning: node next pointer for `One' is `Two' but next is `Three' in menu test2.texi:17: warning: node `Top' is up for `Three' in menu but not in sectioning test2.texi:17: warning: node prev pointer for `Three' is `Two' but prev is `One' in menu Here line 11 is "@node One" and line 17 is "@node Three", but the true location of the error is the @menu block starting at line 6 and the defect is located at lines 7 and 8. It would be better to report an error on the menu directly rather indirectly through the menu directions.