texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Convert/Plaintext.pm t/resul...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Convert/Plaintext.pm t/resul...
Date: Sat, 27 Nov 2010 14:41:21 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        10/11/27 14:41:21

Modified files:
        tp/Texinfo/Convert: Plaintext.pm 
        tp/t/results/coverage: def.pl 
        tp/t/results/def: all_commands_delimiters.pl 
                          end_of_lines_protected.pl 
Added files:
        tp/t/results/float: simple.pl 

Log message:
        Format def* line as a paragraph, as it should be.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage/def.pl?cvsroot=texinfo&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/def/all_commands_delimiters.pl?cvsroot=texinfo&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/def/end_of_lines_protected.pl?cvsroot=texinfo&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/float/simple.pl?cvsroot=texinfo&rev=1.1

Patches:
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- Texinfo/Convert/Plaintext.pm        27 Nov 2010 14:12:07 -0000      1.25
+++ Texinfo/Convert/Plaintext.pm        27 Nov 2010 14:41:19 -0000      1.26
@@ -910,50 +910,41 @@
     } elsif ($root->{'type'} eq 'def_line' and $root->{'extra'} and 
$root->{'extra'}->{'def_args'}
              and @{$root->{'extra'}->{'def_args'}}) {
     #print STDERR "$root->{'extra'}->{'def_command'}\n";
-      my @args = @{$root->{'extra'}->{'def_args'}};
-      my ($name, $type) = ('', ''); 
-      # FIXME this is all wrong. The def should be formatted as a paragraph,
-      # see info.init.
-      foreach my $def_item ([\$name, 'name'], [\$type, 'type']) {
-        ${$def_item->[0]} = 
$self->convert_unfilled($root->{'extra'}->{'def_parsed_hash'}->{$def_item->[1]},
-                                                    {'indent_length' => 0})
-          if 
(defined($root->{'extra'}->{'def_parsed_hash'}->{$def_item->[1]}));
+      my $parsed_definition_category = $self->_definition_category ($root, 
+              $root->{'extra'}->{'def_parsed_hash'}->{'category'},
+              $root->{'extra'}->{'def_parsed_hash'}->{'class'});
+      # FIXME need i18n here?
+      my @contents = ($parsed_definition_category, {'text' => ': '});
+      if ($root->{'extra'}->{'def_parsed_hash'}->{'type'}) {
+        push @contents, ($root->{'extra'}->{'def_parsed_hash'}->{'type'}, 
+                         {'text' => ' '});
       }
+      push @contents, $root->{'extra'}->{'def_parsed_hash'}->{'name'};
 
+      my @args = @{$root->{'extra'}->{'def_args'}};
       while (@args) {
         last if ($args[0]->[0] ne 'spaces' 
                 and !$root->{'extra'}->{'def_parsed_hash'}->{$args[0]->[0]});
         shift @args;
       }
-      print STDERR "DEF LINE(parsed) name `$name' type `$type'\n"
-        if ($self->{'debug'});
 
-      my $parsed_definition_category = $self->_definition_category ($root, 
-              $root->{'extra'}->{'def_parsed_hash'}->{'category'},
-              $root->{'extra'}->{'def_parsed_hash'}->{'class'});
-      my $definition_category 
-        = $self->convert_unfilled($parsed_definition_category, 
{'indent_length' => 0});
-      my $type_name = '';
-      $type_name .= "$type " if ($type ne '');
-      $type_name .= $name if ($name ne '');
-
-      my $arguments = '';
-      foreach my $parsed_arg(@args) {
-        my $arg_text;
-        if ($parsed_arg->[0] eq 'spaces') {
-          $arg_text = $parsed_arg->[1]->{'text'};
-        } else {
-          $arg_text 
-          = $self->convert_unfilled($parsed_arg->[1], {'indent_length' => 0});
+      if (@args) {
+        push @contents, {'text' => ' '};
+        foreach my $arg (@args) {
+          push @contents, $arg->[1];
         }
-        $arguments .= $arg_text;
       }
-      $arguments = ' '.$arguments if ($arguments ne '');
-      print STDERR "DEF LINE definition_category `$definition_category' 
arguments `$arguments'\n"
-        if ($self->{'debug'});
-      $result = " -- $definition_category: ${type_name}$arguments";
-      $result =~ s/\s*$//;
-      $result .= "\n";
+
+      my $def_paragraph = $self->new_formatter('paragraph', 
+       { 'indent_length' => ($self->{'format_context'}->[-1]->{'indent_level'} 
-1) *$indent_length,
+         'indent_length_next' => 
(1+$self->{'format_context'}->[-1]->{'indent_level'})*$indent_length});
+      push @{$self->{'formatters'}}, $def_paragraph;
+
+      $result .= $def_paragraph->{'container'}->add_next(" -- ");
+      $result .= $self->convert({'type' => 'code', 'contents' => 
address@hidden);
+      $result .= $def_paragraph->{'container'}->end();
+
+      pop @{$self->{'formatters'}};
       print STDERR "     --> $result" if ($self->{'debug'});
     } elsif ($root->{'type'} eq 'menu_entry') {
       foreach my $arg (@{$root->{'args'}}) {

Index: t/results/coverage/def.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/coverage/def.pl,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30

Index: t/results/def/all_commands_delimiters.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/def/all_commands_delimiters.pl,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- t/results/def/all_commands_delimiters.pl    27 Nov 2010 14:12:08 -0000      
1.16
+++ t/results/def/all_commands_delimiters.pl    27 Nov 2010 14:41:20 -0000      
1.17
@@ -12122,21 +12122,27 @@
 
 
 
-$result_converted{'plaintext'}->{'all_commands_delimiters'} = ' -- Command: 
forward--char nchars argument2 argument3         (arg in brace, [something in 
v--ar, in, b , comma apref p]) last
+$result_converted{'plaintext'}->{'all_commands_delimiters'} = ' -- Command: 
forward--char nchars argument2 argument3 (arg in brace,
+          [something in v--ar, in, b , comma apref p]) last
 
  -- Variable: fill-column
  -- Library Function: int foobar (int foo, float bar)
- -- Library Function: int foobar (int foo, float bar)         (arg in brace, 
[something in v--ar, in, b , comma apref p]) ct
+ -- Library Function: int foobar (int foo, float bar) (arg in brace,
+          [something in v--ar, in, b , comma apref p]) ct
 
  last
  -- Library Function: int foobug [something
- -- stacks: private push (s:in out stack;                  n:in integer) ; 
;barg aarg; ; end
+ -- stacks: private push (s:in out stack; n:in integer) ; ;barg aarg; ;
+          end
  -- Global Flag: int enable
- -- Data type: pair car cdr         (arg in brace, [something in v--ar, in, b 
, comma apref p]) last
+ -- Data type: pair car cdr (arg in brace, [something in v--ar, in, b ,
+          comma apref p]) last
  -- Class Option of Window: border-pattern
  -- Class Option2 of Window: `int\' border-pattern
- -- Operation on windows: expose (arg in brace, [something in v--ar, in, b , 
comma apref p]) last
- -- Operation2 on W,indow: `int\' expose (arg in brace, [something in v--ar, 
in, b , comma apref p]) last
+ -- Operation on windows: expose (arg in brace, [something in v--ar, in,
+          b , comma apref p]) last
+ -- Operation2 on W,indow: `int\' expose (arg in brace, [something in
+          v--ar, in, b , comma apref p]) last
  -- Operation5 on Window: `int\' expose type arg
  -- Operation3 on W,indow: `int\' e,xpose type arg
  -- Operation4 on ,Window: `int\' ,expose type arg

Index: t/results/def/end_of_lines_protected.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/def/end_of_lines_protected.pl,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- t/results/def/end_of_lines_protected.pl     27 Nov 2010 14:12:08 -0000      
1.16
+++ t/results/def/end_of_lines_protected.pl     27 Nov 2010 14:41:21 -0000      
1.17
@@ -282,7 +282,8 @@
 
 
 
-$result_converted{'plaintext'}->{'end_of_lines_protected'} = ' -- category: 
deffn_name arguments    more args   with end of line within with 3 @ @ one last 
arg
+$result_converted{'plaintext'}->{'end_of_lines_protected'} = ' -- category: 
deffn_name arguments more args with end of line within
+          with 3 @ @ one last arg
      deffn
 ';
 

Index: t/results/float/simple.pl
===================================================================
RCS file: t/results/float/simple.pl
diff -N t/results/float/simple.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/float/simple.pl   27 Nov 2010 14:41:21 -0000      1.1
@@ -0,0 +1,216 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted);
+
+$result_trees{'simple'} = {
+  'contents' => [
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => ' ',
+              'type' => 'empty_spaces_after_command'
+            },
+            {
+              'parent' => {},
+              'text' => 'Type'
+            }
+          ],
+          'parent' => {},
+          'type' => 'block_line_arg'
+        },
+        {
+          'contents' => [
+            {
+              'text' => ' ',
+              'type' => 'empty_spaces_before_argument'
+            },
+            {
+              'parent' => {},
+              'text' => 'Label'
+            },
+            {
+              'parent' => {},
+              'text' => '
+',
+              'type' => 'space_at_end_block_command'
+            }
+          ],
+          'parent' => {},
+          'type' => 'block_line_arg'
+        }
+      ],
+      'cmdname' => 'float',
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => 'In float.
+'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'contents' => [
+                        {
+                          'parent' => {},
+                          'text' => 'Caption.'
+                        }
+                      ],
+                      'parent' => {},
+                      'type' => 'paragraph'
+                    }
+                  ],
+                  'parent' => {},
+                  'type' => 'brace_command_context'
+                }
+              ],
+              'cmdname' => 'caption',
+              'contents' => [],
+              'extra' => {
+                'float' => {}
+              },
+              'parent' => {}
+            },
+            {
+              'parent' => {},
+              'text' => '
+'
+            }
+          ],
+          'parent' => {},
+          'type' => 'paragraph'
+        }
+      ],
+      'extra' => {
+        'block_command_line_contents' => [
+          [
+            {}
+          ],
+          [
+            {}
+          ]
+        ],
+        'caption' => {},
+        'node_content' => [
+          {}
+        ],
+        'normalized' => 'Label',
+        'type' => {
+          'content' => [
+            {}
+          ],
+          'normalized' => 'Type'
+        }
+      },
+      'line_nr' => {
+        'file_name' => '',
+        'line_nr' => 1,
+        'macro' => ''
+      },
+      'number' => 1,
+      'parent' => {}
+    },
+    {
+      'parent' => {},
+      'text' => '',
+      'type' => 'empty_line_after_command'
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'simple'}{'contents'}[0]{'args'}[0]{'contents'}[0]{'parent'} = 
$result_trees{'simple'}{'contents'}[0]{'args'}[0];
+$result_trees{'simple'}{'contents'}[0]{'args'}[0]{'contents'}[1]{'parent'} = 
$result_trees{'simple'}{'contents'}[0]{'args'}[0];
+$result_trees{'simple'}{'contents'}[0]{'args'}[0]{'parent'} = 
$result_trees{'simple'}{'contents'}[0];
+$result_trees{'simple'}{'contents'}[0]{'args'}[1]{'contents'}[1]{'parent'} = 
$result_trees{'simple'}{'contents'}[0]{'args'}[1];
+$result_trees{'simple'}{'contents'}[0]{'args'}[1]{'contents'}[2]{'parent'} = 
$result_trees{'simple'}{'contents'}[0]{'args'}[1];
+$result_trees{'simple'}{'contents'}[0]{'args'}[1]{'parent'} = 
$result_trees{'simple'}{'contents'}[0];
+$result_trees{'simple'}{'contents'}[0]{'contents'}[0]{'parent'} = 
$result_trees{'simple'}{'contents'}[0];
+$result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'parent'} 
= $result_trees{'simple'}{'contents'}[0]{'contents'}[1];
+$result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'args'}[0]{'contents'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'args'}[0]{'contents'}[0];
+$result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'args'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'args'}[0];
+$result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'args'}[0]{'parent'}
 = $result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'contents'}[1];
+$result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'extra'}{'float'}
 = $result_trees{'simple'}{'contents'}[0];
+$result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'parent'} 
= $result_trees{'simple'}{'contents'}[0]{'contents'}[1];
+$result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'contents'}[2]{'parent'} 
= $result_trees{'simple'}{'contents'}[0]{'contents'}[1];
+$result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'parent'} = 
$result_trees{'simple'}{'contents'}[0];
+$result_trees{'simple'}{'contents'}[0]{'extra'}{'block_command_line_contents'}[0][0]
 = $result_trees{'simple'}{'contents'}[0]{'args'}[0]{'contents'}[1];
+$result_trees{'simple'}{'contents'}[0]{'extra'}{'block_command_line_contents'}[1][0]
 = $result_trees{'simple'}{'contents'}[0]{'args'}[1]{'contents'}[1];
+$result_trees{'simple'}{'contents'}[0]{'extra'}{'caption'} = 
$result_trees{'simple'}{'contents'}[0]{'contents'}[1]{'contents'}[1];
+$result_trees{'simple'}{'contents'}[0]{'extra'}{'node_content'}[0] = 
$result_trees{'simple'}{'contents'}[0]{'args'}[1]{'contents'}[1];
+$result_trees{'simple'}{'contents'}[0]{'extra'}{'type'}{'content'}[0] = 
$result_trees{'simple'}{'contents'}[0]{'args'}[0]{'contents'}[1];
+$result_trees{'simple'}{'contents'}[0]{'parent'} = $result_trees{'simple'};
+$result_trees{'simple'}{'contents'}[1]{'parent'} = $result_trees{'simple'};
+
+$result_texis{'simple'} = '@float Type, Label
+
+In float.
address@hidden
address@hidden float';
+
+
+$result_texts{'simple'} = '
+In float.
+
+';
+
+$result_errors{'simple'} = [
+  {
+    'error_line' => ':4: warning: @caption should be right below 
address@hidden'
+',
+    'file_name' => '',
+    'line_nr' => 4,
+    'macro' => '',
+    'text' => '@caption should be right below address@hidden'',
+    'type' => 'warning'
+  }
+];
+
+
+$result_floats{'simple'} = {
+  'Type' => [
+    {
+      'cmdname' => 'float',
+      'extra' => {
+        'caption' => {
+          'cmdname' => 'caption',
+          'extra' => {
+            'float' => {}
+          }
+        },
+        'normalized' => 'Label',
+        'type' => {
+          'content' => [
+            {
+              'text' => 'Type'
+            }
+          ],
+          'normalized' => 'Type'
+        }
+      },
+      'number' => 1
+    }
+  ]
+};
+$result_floats{'simple'}{'Type'}[0]{'extra'}{'caption'}{'extra'}{'float'} = 
$result_floats{'simple'}{'Type'}[0];
+
+
+
+$result_converted{'plaintext'}->{'simple'} = '
+In float.
+
+Type 1: Caption.
+';
+
+1;



reply via email to

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