[svn:parrot] r46214 - in trunk: . config/gen/makefiles tools/docs

gerd at svn.parrot.org gerd at svn.parrot.org
Sun May 2 04:27:21 UTC 2010


Author: gerd
Date: Sun May  2 04:27:20 2010
New Revision: 46214
URL: https://trac.parrot.org/parrot/changeset/46214

Log:
Replace the sed command with perl code. Move the writing of TEX-code form the file book-to-latex.pl to the file filename_and_chapter.pl, so the commands in the Makefile can be reduced

Deleted:
   trunk/tools/docs/book-to-latex.pl
Modified:
   trunk/MANIFEST
   trunk/config/gen/makefiles/docs.in
   trunk/tools/docs/filename_and_chapter.pl

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	Sun May  2 04:24:29 2010	(r46213)
+++ trunk/MANIFEST	Sun May  2 04:27:20 2010	(r46214)
@@ -1,12 +1,12 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Sun Apr 25 21:39:46 2010 UT
+# generated by ./tools/dev/mk_manifest_and_skip.pl Sun May  2 04:09:12 2010 UT
 #
 # See below for documentation on the format of this file.
 #
 # See docs/submissions.pod and the documentation in
-# tools/dev/mk_manifest_and_skip.pl on how to recreate this file after SVN
+# ./tools/dev/mk_manifest_and_skip.pl on how to recreate this file after SVN
 # has been told about new or deleted files.
 .gitignore                                                  []
 CREDITS                                                     [main]doc
@@ -2119,7 +2119,6 @@
 tools/dev/vgp_darwin                                        []
 tools/dev/vms-patch                                         []
 tools/dev/vtablize.pl                                       []
-tools/docs/book-to-latex.pl                                 []
 tools/docs/filename_and_chapter.pl                          []
 tools/docs/mk_chm.pl                                        []
 tools/docs/ops_summary.pl                                   []

Modified: trunk/config/gen/makefiles/docs.in
==============================================================================
--- trunk/config/gen/makefiles/docs.in	Sun May  2 04:24:29 2010	(r46213)
+++ trunk/config/gen/makefiles/docs.in	Sun May  2 04:27:20 2010	(r46214)
@@ -11,9 +11,6 @@
 PERLDOC_BIN = @perldoc@
 VERSION = @VERSION@@DEVEL@
 
-# chapters in the generated PDF parrot book
-CHAPTERS = $(PERL) ../tools/docs/filename_and_chapter.pl --b_out
-
 # long list of .pod files
 POD = @TEMP_pod@
 
@@ -54,12 +51,11 @@
 	$(PERL) -I../lib ../tools/docs/write_docs.pl --silent --version=$(VERSION)
 
 # The pdf target is to generate a parrot PDF document.
-# It will not work on Windows. It call a script which use a specific Unix
-# command. May be that will be changed.
-pdf: ../tools/docs/book-to-latex.pl ../tools/docs/filename_and_chapter.pl
+# It will not work on Windows. It use the Unix syntax to specify the 
+# path of files. May be that will be changed.
+pdf: ../tools/docs/filename_and_chapter.pl
 	$(MKPATH) build/modified_pod
 	$(PERL) ../tools/docs/filename_and_chapter.pl
-	$(PERL) ../tools/docs/book-to-latex.pl `$(CHAPTERS)` > build/parrot-book.tex
 	cd build && pdflatex parrot-book.tex && pdflatex parrot-book.tex
 
 #pdf-release: build/parrot-book.pdf

Deleted: trunk/tools/docs/book-to-latex.pl
==============================================================================
--- trunk/tools/docs/book-to-latex.pl	Sun May  2 04:27:20 2010	(r46213)
+++ /dev/null	00:00:00 1970	(deleted)
@@ -1,34 +0,0 @@
-#! perl
-# Copyright (C) 2010, Parrot Foundation.
-# $Id$
-
-use strict;
-use warnings;
-
-use Pod::PseudoPod::LaTeX;
-
-print <<'HEADER';
-\documentclass[11pt,a4paper,oneside]{report}
-\usepackage{graphics,graphicx}
-\usepackage{colortbl}
-
-\begin{document}
-\tableofcontents
-HEADER
-
-for (@ARGV) {
-    my $parser = Pod::PseudoPod::LaTeX->new();
-    $parser->output_fh( *STDOUT );
-    $parser->parse_file( $_ );
-}
-
-print <<'FOOTER';
-\end{document}
-FOOTER
-
-# Local Variables:
-#   mode: cperl
-#   cperl-indent-level: 4
-#   fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:

Modified: trunk/tools/docs/filename_and_chapter.pl
==============================================================================
--- trunk/tools/docs/filename_and_chapter.pl	Sun May  2 04:24:29 2010	(r46213)
+++ trunk/tools/docs/filename_and_chapter.pl	Sun May  2 04:27:20 2010	(r46214)
@@ -2,13 +2,20 @@
 # Copyright (C) 2010, Parrot Foundation.
 # $Id$
 #
-# perl script that deliver all filenames and the associated chapters
+# perl script that writes modified POD files to the directory 
+# 'build/modified_pod'. Then this script generates a latex file from
+# this POD.
 #
 
 use strict;
 use warnings;
 
+# prototype
+sub write_mod($);
+
+
 use Getopt::Long ();
+use Pod::PseudoPod::LaTeX;
 
 my $item_list_ref = [ ['intro.pod', 'Introduction to Parrot'],
                       ['overview.pod', 'Overview'],
@@ -16,29 +23,70 @@
                     ];
 
 my $lang = @$item_list_ref;
+my $MOD_BUILD_PATH='build/modified_pod/';
 
-my ( $result, $give_out, $b_out);
+my ( $result, $give_out );
 
 $result = Getopt::Long::GetOptions (
     "print" => \$give_out,
-    "b_out" => \$b_out,
 );
 
 if ($give_out)  {
     for ( my $i=0; $i<$lang; $i++ )
-        { print $$item_list_ref[$i][0], ' ' }
-    exit;
-};
-
-if ($b_out) {
-    for ( my $i=0; $i<$lang; $i++ )
-        { print 'build/modified_pod/', $$item_list_ref[$i][0], ' ' }
+        { print $$item_list_ref[$i][0], "\n" }
     exit;
 };
 
 
-for (my $i=0; $i<$lang; $i++)
-    { `sed -e '4,6c\=head0 $$item_list_ref[$i][1]' $$item_list_ref[$i][0] > build/modified_pod/$$item_list_ref[$i][0]` }
+for ( my $i=0; $i<$lang; $i++ ) {
+    write_mod( $i );
+}
+
+
+open( TEX_FH, '>build/parrot-book.tex');
+
+print TEX_FH <<'HEADER';
+\documentclass[11pt,a4paper,oneside]{report}
+\usepackage{graphics,graphicx}
+\usepackage{colortbl}
+
+\begin{document}
+\tableofcontents
+HEADER
+
+for ( my $i=0; $i<$lang; $i++ ) {
+    my $parser = Pod::PseudoPod::LaTeX->new();
+    $parser->output_fh( *TEX_FH );
+    $parser->parse_file( "${MOD_BUILD_PATH}$$item_list_ref[$i][0]" );
+}
+
+print TEX_FH <<'FOOTER';
+\end{document}
+FOOTER
+
+close( TEX_FH );
+
+
+sub write_mod( $ ) {
+    my $icnt;
+
+    open( IN_FH, "<$$item_list_ref[$_[0]][0]" ) ||
+        die( "$0: can't open $$item_list_ref[$_[0]][0] for reading ($!)\n" );
+    open( OUT_FH, ">${MOD_BUILD_PATH}$$item_list_ref[$_[0]][0]" );
+
+    # do the same as: sed -e '4,6c\=head0 $$item_list_ref[$i][1]'
+    while( <IN_FH> ) {
+        if ( $icnt = (4..6) ) {
+            if ( $icnt =~ /E0$/ ) {
+                print( OUT_FH "=head0 $$item_list_ref[$_[0]][1]\n");
+            }
+        }
+        else { print( OUT_FH ); }
+    }
+
+    close( IN_FH );
+    close( OUT_FH );
+}
 
 
 # Local Variables:


More information about the parrot-commits mailing list