texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Mon, 15 Apr 2024 16:46:35 -0400 (EDT)

branch: master
commit 9643be6fd824c27fa4ea331180ae7f2f42fe9bf3
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Apr 15 21:41:18 2024 +0200

    * tp/Makefile.tres, tp/t/transformations.t
    (regenerate_master_menu_with_menu_comment): add test of
    regenerate_master_menu with a menu comment at the end of the Top node.
    
    Change in comments and spacing.
---
 ChangeLog                                          |   8 +
 tp/Makefile.tres                                   |   1 +
 tp/Texinfo/Structuring.pm                          |   3 +-
 tp/Texinfo/Transformations.pm                      |  12 +-
 .../XS/structuring_transfo/transformations.c       |   5 -
 .../regenerate_master_menu_with_menu_comment.pl    | 653 +++++++++++++++++++++
 tp/t/transformations.t                             |  19 +
 7 files changed, 692 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 92a9831c39..79d8817699 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-04-15  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Makefile.tres, tp/t/transformations.t
+       (regenerate_master_menu_with_menu_comment): add test of
+       regenerate_master_menu with a menu comment at the end of the Top node.
+
+       Change in comments and spacing.
+
 2024-04-15  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/converter.c
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 85424000f1..84c20d79e0 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -2021,6 +2021,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/transformations/protect_hashchar_at_line_beginning_source_mark.pl \
   
t/results/transformations/protect_node_after_label_source_mark_in_protected.pl \
   t/results/transformations/regenerate_master_menu_no_need_for_master_menu.pl \
+  t/results/transformations/regenerate_master_menu_with_menu_comment.pl \
   t/results/value/bad_syntax.pl \
   t/results/value/begin_like_comment_on_set_line.pl \
   t/results/value/clear_no_end_of_line.pl \
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 2d396ff275..cbd21b00b0 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -1442,7 +1442,8 @@ sub new_detailmenu($$$$;$)
         = Texinfo::ManipulateTree::normalized_entry_associated_internal_node(
                                                   $entry, $identifier_target);
           if ($node) {
-            push @{$new_detailmenu->{'contents'}}, _print_down_menus($node, 
undef,
+            push @{$new_detailmenu->{'contents'}},
+                         _print_down_menus($node, undef,
                                            $customization_information,
                                            $registrar,
                                            $identifier_target, $use_sections);
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index f520fb8242..44558ac4cf 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -677,7 +677,14 @@ sub regenerate_master_menu($;$)
           splice (@$global_detailmenu, $global_detailmenu_index, 1,
                   $new_detailmenu);
         }
-        # FIXME use an API to register a new internal reference?
+        # NOTE the menu entries added in @detailmenu are not added as
+        # internal references.  However, this is not an issue, as the
+        # menu entries in @detailmenu are also in regular menus.
+        # As long as internal references are only used to check if all
+        # the nodes are referenced, not having @detailmenu entries
+        # added is not an issue at all.
+
+        # remove internal refs of removed entries
         my $internal_references = $document->internal_references_information();
         foreach my $detailmenu_entry (@{$entry->{'contents'}}) {
           if ($detailmenu_entry->{'type'}
@@ -723,8 +730,7 @@ sub regenerate_master_menu($;$)
         and $last_element->{'contents'}->[-1]->{'type'}
         and $last_element->{'contents'}->[-1]->{'type'} eq 'preformatted') {
       {
-      # there is already a menu comment at the end of the menu, add an empty 
line
-        # FIXME this case is not covered in tests
+        # already a menu comment at the end of the menu, add an empty line
         my $preformatted = $last_element->{'contents'}->[-1];
         my $empty_line = {'type' => 'empty_line', 'text' => "\n",
                           'parent' => $preformatted};
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c 
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index d02065833e..f89d4923a7 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -1175,11 +1175,6 @@ regenerate_master_menu (DOCUMENT *document, int 
use_sections)
               ELEMENT *removed = remove_from_contents (menu, detailmenu_index);
               replace_element_in_list (&document->global_commands->detailmenu,
                                        removed, new_detailmenu_e);
-              /* TODO are the new entries added to internal refs?
-                 Note that if they are not, it is possible that this has
-                 no impact as the associated entry in menu may be
-                 in internal refs, and maybe it is enough.
-               */
               /* remove internal refs of removed entries */
               for (j = 0; j < removed->contents.number; j++)
                 {
diff --git 
a/tp/t/results/transformations/regenerate_master_menu_with_menu_comment.pl 
b/tp/t/results/transformations/regenerate_master_menu_with_menu_comment.pl
new file mode 100644
index 0000000000..643d93281f
--- /dev/null
+++ b/tp/t/results/transformations/regenerate_master_menu_with_menu_comment.pl
@@ -0,0 +1,653 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'regenerate_master_menu_with_menu_comment'} = {
+  'contents' => [
+    {
+      'type' => 'before_node_section'
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'Top'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'node',
+      'extra' => {
+        'is_target' => 1,
+        'normalized' => 'Top'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 1
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'top'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'top',
+      'contents' => [
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'args' => [
+            {
+              'info' => {
+                'spaces_after_argument' => {
+                  'text' => '
+'
+                }
+              },
+              'type' => 'block_line_arg'
+            }
+          ],
+          'cmdname' => 'menu',
+          'contents' => [
+            {
+              'contents' => [
+                {
+                  'text' => '* ',
+                  'type' => 'menu_entry_leading_text'
+                },
+                {
+                  'contents' => [
+                    {
+                      'text' => 'chap'
+                    }
+                  ],
+                  'extra' => {
+                    'node_content' => {
+                      'contents' => [
+                        {}
+                      ]
+                    },
+                    'normalized' => 'chap'
+                  },
+                  'type' => 'menu_entry_node'
+                },
+                {
+                  'text' => '::',
+                  'type' => 'menu_entry_separator'
+                },
+                {
+                  'contents' => [
+                    {
+                      'contents' => [
+                        {
+                          'text' => '
+'
+                        }
+                      ],
+                      'type' => 'preformatted'
+                    }
+                  ],
+                  'type' => 'menu_entry_description'
+                }
+              ],
+              'source_info' => {
+                'line_nr' => 5
+              },
+              'type' => 'menu_entry'
+            },
+            {
+              'contents' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => '
+',
+                      'type' => 'after_menu_description_line'
+                    },
+                    {
+                      'text' => 'A MC.
+'
+                    },
+                    {
+                      'text' => '
+',
+                      'type' => 'empty_line'
+                    }
+                  ],
+                  'type' => 'preformatted'
+                }
+              ],
+              'type' => 'menu_comment'
+            },
+            {
+              'args' => [
+                {
+                  'info' => {
+                    'spaces_after_argument' => {
+                      'text' => '
+'
+                    }
+                  },
+                  'type' => 'block_line_arg'
+                }
+              ],
+              'cmdname' => 'detailmenu',
+              'contents' => [
+                {
+                  'contents' => [
+                    {
+                      'contents' => [
+                        {
+                          'text' => ' --- The Detailed Node Listing ---'
+                        },
+                        {
+                          'text' => '
+'
+                        },
+                        {
+                          'text' => '
+',
+                          'type' => 'empty_line'
+                        },
+                        {
+                          'text' => 'Chapter'
+                        },
+                        {
+                          'text' => '
+',
+                          'type' => 'empty_line'
+                        },
+                        {
+                          'text' => '
+',
+                          'type' => 'empty_line'
+                        }
+                      ],
+                      'type' => 'preformatted'
+                    }
+                  ],
+                  'type' => 'menu_comment'
+                },
+                {
+                  'contents' => [
+                    {
+                      'text' => '* ',
+                      'type' => 'menu_entry_leading_text'
+                    },
+                    {
+                      'contents' => [
+                        {
+                          'text' => 'sec'
+                        }
+                      ],
+                      'extra' => {
+                        'node_content' => {
+                          'contents' => [
+                            {}
+                          ]
+                        },
+                        'normalized' => 'sec'
+                      },
+                      'type' => 'menu_entry_node'
+                    },
+                    {
+                      'text' => '::',
+                      'type' => 'menu_entry_separator'
+                    },
+                    {
+                      'contents' => [
+                        {
+                          'contents' => [
+                            {
+                              'text' => '
+'
+                            }
+                          ],
+                          'type' => 'preformatted'
+                        }
+                      ],
+                      'type' => 'menu_entry_description'
+                    }
+                  ],
+                  'type' => 'menu_entry'
+                },
+                {
+                  'args' => [
+                    {
+                      'contents' => [
+                        {
+                          'text' => 'detailmenu'
+                        }
+                      ],
+                      'info' => {
+                        'spaces_after_argument' => {
+                          'text' => '
+'
+                        }
+                      },
+                      'type' => 'line_arg'
+                    }
+                  ],
+                  'cmdname' => 'end',
+                  'extra' => {
+                    'text_arg' => 'detailmenu'
+                  },
+                  'info' => {
+                    'spaces_before_argument' => {
+                      'text' => ' '
+                    }
+                  }
+                }
+              ]
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'menu'
+                    }
+                  ],
+                  'info' => {
+                    'spaces_after_argument' => {
+                      'text' => '
+'
+                    }
+                  },
+                  'type' => 'line_arg'
+                }
+              ],
+              'cmdname' => 'end',
+              'extra' => {
+                'text_arg' => 'menu'
+              },
+              'info' => {
+                'spaces_before_argument' => {
+                  'text' => ' '
+                }
+              },
+              'source_info' => {
+                'line_nr' => 8
+              }
+            }
+          ],
+          'source_info' => {
+            'line_nr' => 4
+          }
+        },
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        }
+      ],
+      'extra' => {},
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 2
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'chap'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'node',
+      'extra' => {
+        'is_target' => 1,
+        'normalized' => 'chap'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 10
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'Chapter'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'chapter',
+      'contents' => [
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        }
+      ],
+      'extra' => {
+        'section_number' => '1'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 11
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'sec'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'node',
+      'extra' => {
+        'is_target' => 1,
+        'normalized' => 'sec'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 13
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'Sec'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'section',
+      'extra' => {
+        'section_number' => '1.1'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 14
+      }
+    }
+  ],
+  'type' => 'document_root'
+};
+$result_trees{'regenerate_master_menu_with_menu_comment'}{'contents'}[2]{'contents'}[1]{'contents'}[0]{'contents'}[1]{'extra'}{'node_content'}{'contents'}[0]
 = 
$result_trees{'regenerate_master_menu_with_menu_comment'}{'contents'}[2]{'contents'}[1]{'contents'}[0]{'contents'}[1]{'contents'}[0];
+$result_trees{'regenerate_master_menu_with_menu_comment'}{'contents'}[2]{'contents'}[1]{'contents'}[2]{'contents'}[1]{'contents'}[1]{'extra'}{'node_content'}{'contents'}[0]
 = 
$result_trees{'regenerate_master_menu_with_menu_comment'}{'contents'}[2]{'contents'}[1]{'contents'}[2]{'contents'}[1]{'contents'}[1]{'contents'}[0];
+
+$result_texis{'regenerate_master_menu_with_menu_comment'} = '@node Top
+@top top
+
+@menu
+* chap::
+
+A MC.
+
+@detailmenu
+ --- The Detailed Node Listing ---
+
+Chapter
+
+* sec::
+@end detailmenu
+@end menu
+
+@node chap
+@chapter Chapter
+
+@node sec
+@section Sec
+';
+
+
+$result_texts{'regenerate_master_menu_with_menu_comment'} = 'top
+***
+
+* chap::
+
+A MC.
+
+ -- The Detailed Node Listing --
+
+Chapter
+
+* sec::
+
+1 Chapter
+*********
+
+1.1 Sec
+=======
+';
+
+$result_sectioning{'regenerate_master_menu_with_menu_comment'} = {
+  'extra' => {
+    'section_childs' => [
+      {
+        'cmdname' => 'top',
+        'extra' => {
+          'associated_node' => {
+            'cmdname' => 'node',
+            'extra' => {
+              'normalized' => 'Top'
+            }
+          },
+          'section_childs' => [
+            {
+              'cmdname' => 'chapter',
+              'extra' => {
+                'associated_node' => {
+                  'cmdname' => 'node',
+                  'extra' => {
+                    'normalized' => 'chap'
+                  }
+                },
+                'section_childs' => [
+                  {
+                    'cmdname' => 'section',
+                    'extra' => {
+                      'associated_node' => {
+                        'cmdname' => 'node',
+                        'extra' => {
+                          'normalized' => 'sec'
+                        }
+                      },
+                      'section_directions' => {
+                        'up' => {}
+                      },
+                      'section_level' => 2,
+                      'section_number' => '1.1'
+                    }
+                  }
+                ],
+                'section_directions' => {
+                  'up' => {}
+                },
+                'section_level' => 1,
+                'section_number' => '1',
+                'toplevel_directions' => {
+                  'prev' => {},
+                  'up' => {}
+                }
+              }
+            }
+          ],
+          'section_level' => 0,
+          'sectioning_root' => {},
+          'toplevel_directions' => {}
+        }
+      }
+    ],
+    'section_level' => -1
+  }
+};
+$result_sectioning{'regenerate_master_menu_with_menu_comment'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'section_directions'}{'up'}
 = 
$result_sectioning{'regenerate_master_menu_with_menu_comment'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0];
+$result_sectioning{'regenerate_master_menu_with_menu_comment'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'section_directions'}{'up'}
 = 
$result_sectioning{'regenerate_master_menu_with_menu_comment'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'regenerate_master_menu_with_menu_comment'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'toplevel_directions'}{'prev'}
 = 
$result_sectioning{'regenerate_master_menu_with_menu_comment'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'regenerate_master_menu_with_menu_comment'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'toplevel_directions'}{'up'}
 = 
$result_sectioning{'regenerate_master_menu_with_menu_comment'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'regenerate_master_menu_with_menu_comment'}{'extra'}{'section_childs'}[0]{'extra'}{'sectioning_root'}
 = $result_sectioning{'regenerate_master_menu_with_menu_comment'};
+
+$result_nodes{'regenerate_master_menu_with_menu_comment'} = [
+  {
+    'cmdname' => 'node',
+    'extra' => {
+      'associated_section' => {
+        'cmdname' => 'top',
+        'extra' => {}
+      },
+      'node_directions' => {
+        'next' => {
+          'cmdname' => 'node',
+          'extra' => {
+            'associated_section' => {
+              'cmdname' => 'chapter',
+              'extra' => {
+                'section_number' => '1'
+              }
+            },
+            'node_directions' => {
+              'prev' => {},
+              'up' => {}
+            },
+            'normalized' => 'chap'
+          }
+        }
+      },
+      'normalized' => 'Top'
+    }
+  },
+  {},
+  {
+    'cmdname' => 'node',
+    'extra' => {
+      'associated_section' => {
+        'cmdname' => 'section',
+        'extra' => {
+          'section_number' => '1.1'
+        }
+      },
+      'node_directions' => {
+        'up' => {}
+      },
+      'normalized' => 'sec'
+    }
+  }
+];
+$result_nodes{'regenerate_master_menu_with_menu_comment'}[0]{'extra'}{'node_directions'}{'next'}{'extra'}{'node_directions'}{'prev'}
 = $result_nodes{'regenerate_master_menu_with_menu_comment'}[0];
+$result_nodes{'regenerate_master_menu_with_menu_comment'}[0]{'extra'}{'node_directions'}{'next'}{'extra'}{'node_directions'}{'up'}
 = $result_nodes{'regenerate_master_menu_with_menu_comment'}[0];
+$result_nodes{'regenerate_master_menu_with_menu_comment'}[1] = 
$result_nodes{'regenerate_master_menu_with_menu_comment'}[0]{'extra'}{'node_directions'}{'next'};
+$result_nodes{'regenerate_master_menu_with_menu_comment'}[2]{'extra'}{'node_directions'}{'up'}
 = 
$result_nodes{'regenerate_master_menu_with_menu_comment'}[0]{'extra'}{'node_directions'}{'next'};
+
+$result_menus{'regenerate_master_menu_with_menu_comment'} = [
+  {
+    'extra' => {
+      'menus' => [
+        {}
+      ],
+      'normalized' => 'Top'
+    }
+  },
+  {
+    'extra' => {
+      'menu_directions' => {
+        'up' => {}
+      },
+      'normalized' => 'chap'
+    }
+  },
+  {
+    'extra' => {
+      'normalized' => 'sec'
+    }
+  }
+];
+$result_menus{'regenerate_master_menu_with_menu_comment'}[1]{'extra'}{'menu_directions'}{'up'}
 = $result_menus{'regenerate_master_menu_with_menu_comment'}[0];
+
+$result_errors{'regenerate_master_menu_with_menu_comment'} = [];
+
+
+$result_floats{'regenerate_master_menu_with_menu_comment'} = {};
+
+
+1;
diff --git a/tp/t/transformations.t b/tp/t/transformations.t
index c9f13d1638..ec2bbfa0cd 100644
--- a/tp/t/transformations.t
+++ b/tp/t/transformations.t
@@ -63,6 +63,25 @@ undef,
    'FORMAT_MENU' => 'menu'},
   {'FORMAT_MENU' => 'menu'},
 ],
+['regenerate_master_menu_with_menu_comment',
+'@node Top
+@top top
+
+@menu
+* chap::
+
+A MC.
+@end menu
+
+@node chap
+@chapter Chapter
+
+@node sec
+@section Sec
+',{'TREE_TRANSFORMATIONS' => 'regenerate_master_menu',
+   'FORMAT_MENU' => 'menu'},
+  {'FORMAT_MENU' => 'menu'},
+],
 );
 
 



reply via email to

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