[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp MANIFEST texi2any.pl DebugTexinfo/De...
From: |
Patrice Dumas |
Subject: |
texinfo/tp MANIFEST texi2any.pl DebugTexinfo/De... |
Date: |
Sat, 17 Sep 2011 20:24:25 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/09/17 20:24:25
Modified files:
tp : MANIFEST texi2any.pl
Added files:
tp/DebugTexinfo: DebugTree.pm
Log message:
Add a new output, DebugTree that outputs the tree in a simple indented
human-readable form.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/MANIFEST?cvsroot=texinfo&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/DebugTexinfo/DebugTree.pm?cvsroot=texinfo&rev=1.1
Patches:
Index: MANIFEST
===================================================================
RCS file: /sources/texinfo/texinfo/tp/MANIFEST,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- MANIFEST 11 Sep 2011 02:18:23 -0000 1.4
+++ MANIFEST 17 Sep 2011 20:24:24 -0000 1.5
@@ -26,6 +26,7 @@
Texinfo/Convert/Line.pm
Texinfo/Convert/Unicode.pm
DebugTexinfo/DebugCount.pm
+DebugTexinfo/DebugTree.pm
t/27float.t
t/test_count.t
t/03coverage_braces.t
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- texi2any.pl 11 Sep 2011 02:18:23 -0000 1.59
+++ texi2any.pl 17 Sep 2011 20:24:24 -0000 1.60
@@ -189,6 +189,7 @@
require Texinfo::Convert::XML;
require Texinfo::Convert::DocBook;
require DebugTexinfo::DebugCount;
+require DebugTexinfo::DebugTree;
# determine configuration directories.
@@ -698,6 +699,8 @@
$format = set_format('html');
_set_variables_texi2html();
$parser_default_options->{'values'}->{'texi2html'} = 1;
+ } elsif ($var eq 'DEBUGTREE') {
+ $format = 'debugtree';
} else {
set_from_cmdline ($var, $value);
# this is very wrong, but a way to avoid a spurious warning.
@@ -798,6 +801,10 @@
'floats' => 1,
'converter' => sub{DebugTexinfo::DebugCount->converter(@_)},
},
+ 'debugtree' => {
+ 'split' => 1,
+ 'converter' => sub{DebugTexinfo::DebugTree->converter(@_)},
+ },
);
if (!$format_from_command_line and defined($ENV{'TEXINFO_OUTPUT_FORMAT'})
Index: DebugTexinfo/DebugTree.pm
===================================================================
RCS file: DebugTexinfo/DebugTree.pm
diff -N DebugTexinfo/DebugTree.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DebugTexinfo/DebugTree.pm 17 Sep 2011 20:24:25 -0000 1.1
@@ -0,0 +1,97 @@
+# DebugTree.pm: debug a Texinfo::Parser tree.
+#
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License,
+# or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Original author: Patrice Dumas <address@hidden>
+
+# Example of calls
+# with creation of elements and pages:
+# ./texi2any.pl --set DEBUGTREE --set USE_SECTIONS=1 --split section file.texi
+# no elements nor pages
+# ./texi2any.pl --set DEBUGTREE file.texi
+
+use Texinfo::Convert::Converter;
+
+package DebugTexinfo::DebugTree;
+
address@hidden = qw(Texinfo::Convert::Converter);
+
+sub output($$)
+{
+ my $self = shift;
+ my $root = shift;
+ my $elements;
+ if ($self->get_conf('USE_NODES')) {
+ $elements = Texinfo::Structuring::split_by_node($root);
+ } elsif ($self->get_conf('USE_SECTIONS')) {
+ #print STDERR "U USE_SECTIONS\n";
+ $elements = Texinfo::Structuring::split_by_section($root);
+ }
+ my $pages;
+ if ($elements and $self->get_conf('SPLIT')) {
+ #print STDERR "S ".$self->get_conf('SPLIT')."\n";
+ $pages = Texinfo::Structuring::split_pages($elements,
+ $self->get_conf('SPLIT'));
+ }
+ if ($pages) {
+ #print STDERR "PPP $pages\n";
+ $root = {'type' => 'pages_root',
+ 'contents' => $pages };
+ } elsif ($elements) {
+ $root = {'type' => 'elements_root',
+ 'contents' => $elements };
+ }
+ return $self->_print_tree($root);
+}
+
+sub _print_tree($$;$$);
+
+sub _print_tree($$;$$)
+{
+ my $self = shift;
+ my $root = shift;
+ my $level = shift;
+ my $argument = shift;
+ $level = 0 if (!defined($level));
+
+ my $result = ' ' x $level;
+ if ($argument) {
+ $result .= '%';
+ $level++;
+ }
+ if ($root->{'cmdname'}) {
+ $result .= "address@hidden>{'cmdname'} ";
+ }
+ if (defined($root->{'type'})) {
+ $result .= "$root->{'type'} ";
+ }
+ if (defined($root->{'text'})) {
+ my $text = $root->{'text'};
+ $text =~ s/\n/\\n/g;
+ $result .= "|$text|";
+ }
+ print $result ."\n";
+ if ($root->{'args'}) {
+ foreach my $arg (@{$root->{'args'}}) {
+ $self->_print_tree ($arg, $level +1, 1);
+ }
+ }
+ if ($root->{'contents'}) {
+ foreach my $content (@{$root->{'contents'}}) {
+ $self->_print_tree ($content, $level+1);
+ }
+ }
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp MANIFEST texi2any.pl DebugTexinfo/De...,
Patrice Dumas <=