#! /usr/bin/perl # 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 Cwd 'abs_path'; use File::Copy; use File::Find; use File::Path; use Text::Wrap; my $inputdir; if ($#ARGV >= 0) { $inputdir = $ARGV[0]; } else { $inputdir = "."; } $inputdir = abs_path($inputdir); my $outputdir; if ($#ARGV >= 1) { $outputdir = $ARGV[1]; } else { $outputdir = $inputdir; } $outputdir = abs_path($outputdir); my %scripts = (); print "Parsing .meta files in $inputdir...\n"; find(\&parse_meta_files, $inputdir); my $meta; 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"; # Don't output these, the description mentions all these in general. #print $file "output: $scripts{$meta}{output}, "; #print $file "exits: $scripts{$meta}{exit}, "; #print $file "status: $scripts{$meta}{status}\n"; 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"; # Don't output these, the description mentions all these in general. #print $file "output: $scripts{$meta}{output}, "; #print $file "exits: $scripts{$meta}{exit}, "; #print $file "status: $scripts{$meta}{status}
    \n"; print $file "keywords: "; foreach $keyword (split(/ /, $scripts{$meta}{keywords})) { print $file '' . (uc $keyword) . " "; } print $file "
    \n"; print $file "

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

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