NAME

Term::GnuplotTerminals - documentation of gnuplot output devices

EOP

for my $file (sort <gnuterm/term/*.trm>) { open F, $file or die "Cannot open '$file': $!"; my $name; while (<F>) { $name = $1, last if /^\s*START_HELP\s*\(\s*(.*?)\s*\)/; } my $got = ""; while (<F>) { last if /^\s*(END_HELP\s*\(|\#\s*endif)/; # Malformed: mac $got .= $_; # print "$file: $_" } close F or die "Cannot close '$file': $!";

  $got or warn("No docs found in '$file'\n");
  $got or next;
  $got .= ",";
  my $help = "";
  $help .= "$1\n"
    while $got =~ s!^\s*(?:/\*.*?\*/\s*)*\"(((?>[^\"\\]+)|\\[\\\"])*)\"\s*,\s*!!s;
  $got and warn("Malformed docs in '$file':\n$got\n");

  $help =~ s/\\([\\\"])/$1/g;
  $help =~ s/^\t/        /mg;		# Do not like leading TABs

  # First line = level name, then lines starting with '?', then text
  my @help = split /^(?>(\d+)(?>\s+)(.+))\n(?:\?(?>.*)\n)+/m, $help;
  $help[0] eq '' or warn "Malformed leader of help: '$help[0]'\n";
  shift @help;

  while (@help) {
    my ($level, $name, $text) = (shift @help, shift @help, shift @help);
    # Process tables:
    $text =~ s/
               ^\@start\s+table\b(?>.*)\n	# First line
               ((?>((\ (?>.*)|)\n)*))		# Interactive form
               [\s\S]*?				# Skip to the ...
	       ^\@end\s+table\b.*		# Last line
              /add_indent($1)/mgxe;
    # Remove extra indentations
    $text =~ s/^ //mg;
    # Add an extra newline on boundary of indented/non-indented text
    $text =~ s/^(\S(?>.*)\n) /$1\n /mg;
    $text =~ s/^( (?>.+)\n)(\S)/$1\n$2/mg;
    # Actual pages have a lot of `foo: <bar>`, we do not translate them correct
    # Need to handle `foo` `bar\nbaz` `bar` correctly, thus anchor at paragraph
    1 while $text =~ s/
			^(?<![^\n]\n)(?=\S)	# Start of text paragraph
			((?:.|\n(?!\n))*?)	# Some part of text paragraph
			`([\s\S]*?)`		# Possibly multiline
		      /${1}C<$2>/mgx;
    print <<EOP;
=head$level $name

$text

EOP } }

print <<EOP; =head1 AUTHOR

Autogenerated from *.trm files in gnuplot terminals subdirectory.

SEE ALSO

Term::Gnuplot.

EOP