From 1cfd2143ecabdf664b2d61f6d46bfab6fdd77816 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 7 Aug 2008 15:18:14 +0200 Subject: Add new examples-index-gen.pl script and support files. --- testsuite/systemtap.examples/examples-index-gen.pl | 290 +++++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 testsuite/systemtap.examples/examples-index-gen.pl (limited to 'testsuite/systemtap.examples/examples-index-gen.pl') diff --git a/testsuite/systemtap.examples/examples-index-gen.pl b/testsuite/systemtap.examples/examples-index-gen.pl new file mode 100644 index 00000000..bc12577e --- /dev/null +++ b/testsuite/systemtap.examples/examples-index-gen.pl @@ -0,0 +1,290 @@ +# Generates index files from examples .meta file info. +# Copyright (C) 2008 Red Hat Inc. +# +# This file is part of systemtap, and is free software. You can +# redistribute it and/or modify it under the terms of the GNU General +# Public License (GPL); either version 2, or (at your option) any +# later version. + +use strict; +use warnings; + +use File::Copy; +use File::Find; +use File::Path; +use Text::Wrap; + +my $inputdir; +if ($#ARGV >= 0) { + $inputdir = $ARGV[0]; +} else { + $inputdir = "."; +} + +my $outputdir; +if ($#ARGV >= 1) { + $outputdir = $ARGV[1]; +} else { + $outputdir = $inputdir; +} + +my %scripts = (); +print "Parsing .meta files in $inputdir...\n"; +find(\&parse_meta_files, $inputdir); + +my $meta; +my $subsystem; +my %subsystems; +my $keyword; +my %keywords; + +# Adds a formatted meta entry to a given file handle as text. +sub add_meta_txt(*;$) { + my($file,$meta) = @_; + + print $file "$scripts{$meta}{name} - $scripts{$meta}{title}\n"; + + print $file "output: $scripts{$meta}{output}, "; + print $file "exits: $scripts{$meta}{exit}, "; + print $file "status: $scripts{$meta}{status}\n"; + + print $file "subsystem: $scripts{$meta}{subsystem}, "; + print $file "keywords: $scripts{$meta}{keywords}\n\n"; + + $Text::Wrap::columns = 72; + my $description = wrap(' ', ' ', $scripts{$meta}{description}); + print $file "$description\n\n\n"; +} + +# Adds a formatted meta entry to a given file handle as text. +sub add_meta_html(*;$) { + my($file,$meta) = @_; + + my $name = $scripts{$meta}{name}; + print $file "
  • $name "; + print $file "- $scripts{$meta}{title}
    \n"; + + print $file "output: $scripts{$meta}{output}, "; + print $file "exits: $scripts{$meta}{exit}, "; + print $file "status: $scripts{$meta}{status}
    \n"; + + print $file "subsystem: $scripts{$meta}{subsystem}, "; + print $file "keywords: $scripts{$meta}{keywords}
    \n"; + + print $file "

    $scripts{$meta}{description}"; + print $file "

  • \n"; +} + +my $HEADER = "SYSTEMTAP EXAMPLES INDEX\n" + . "(see also subsystem-index.txt, keyword-index.txt)\n\n"; + +my $header_tmpl = "$inputdir/html_header.tmpl"; +open(TEMPLATE, "<$header_tmpl") + || die "couldn't open $header_tmpl, $!"; +my $HTMLHEADER = do { local $/;