From 8e240a4630a01acca467d74fa8a984fef4ed4277 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Thu, 17 Nov 2011 23:52:55 +0100 Subject: corrected texinfo and manpage generation of documentation. --- doc/scripts/gdoc | 95 ++++++++++++++++++++++++-------------------------------- 1 file changed, 40 insertions(+), 55 deletions(-) (limited to 'doc/scripts') diff --git a/doc/scripts/gdoc b/doc/scripts/gdoc index 91d76c0205..8e05ce6e51 100755 --- a/doc/scripts/gdoc +++ b/doc/scripts/gdoc @@ -134,55 +134,57 @@ eval '(exit $?0)' && eval 'exec perl "$0" ${1+"$@"}' use POSIX qw(strftime); # match expressions used to find embedded type information -$type_constant = "((?\$2", - $type_func, "\$1", - $type_struct, "\$1", - $type_param, "\$1" ); +%highlights_html = ( $type_constant, '"$1"', + $type_func, '"$1"', + $type_struct, '"$1"', + $type_param, '" $1"' ); $blankline_html = "

"; -%highlights_texinfo = ( $type_constant, "\\\@code{\$2}", - $type_func, "\\\@code{\$1}", - $type_struct, "\\\@code{\$1}", - $type_param, "\\\@code{\$1}" ); +%highlights_texinfo = ( $type_param, '" \@code{$1}"', + $type_constant, '"\@code{$1}"', + $type_func, '"\@code{$1}"', + $type_struct, '"\@code{$1}"', + ); $blankline_texinfo = ""; -%highlights_tex = ( $type_constant, "{\\\\it \$2}", - $type_func, "{\\\\bf \$1}", - $type_struct, "{\\\\it \$1}", - $type_param, "{\\\\bf \$1}" ); +%highlights_tex = ( $type_param, '" {\bf $1}"', + $type_constant, '"{\it $1}"', + $type_func, '"{\bf $1}"', + $type_struct, '"{\it $1}"', + ); $blankline_tex = "\\\\"; # sgml, docbook format -%highlights_sgml = ( $type_constant, "\$2", - $type_func, "\$1", - $type_struct, "\$1", - $type_env, "\$1", - $type_param, "\$1" ); +%highlights_sgml = ( $type_constant, '"$1"', + $type_func, '"$1"', + $type_struct, '"$1"', + $type_env, '"$1"', + $type_param, '" $1"' ); $blankline_sgml = "\n"; # these are pretty rough -%highlights_man = ( $type_constant, "\\\\fB\$2\\\\fP", - $type_func, "\\\\fB\$1\\\\fP", - $type_struct, "\\\\fB\$1\\\\fP", - $type_param, "\\\\fI\$1\\\\fP" ); +%highlights_man = ( $type_constant, '"\\\fB$1\\\fP"', + $type_func, '"\\\fB$1\\\fP"', + $type_struct, '"\\\fB$1\\\fP"', + $type_param, '" \\\fI$1\\\fP"' ); $blankline_man = ""; # text-mode -%highlights_text = ( $type_constant, "\$2", - $type_func, "\$1", - $type_struct, "\$1", - $type_param, "\$1" ); +%highlights_text = ( $type_constant, '"$1"', + $type_func, '"$1"', + $type_struct, '"$1"', + $type_param, '"$1"' ); $blankline_text = ""; my $lineprefix = ""; @@ -272,6 +274,8 @@ sub dump_section { my $name = shift @_; my $contents = join "\n", @_; + $name = " $name"; + if ($name =~ m/$type_constant/) { $name = $1; # print STDERR "constant section '$1' = '$contents'\n"; @@ -298,35 +302,15 @@ sub dump_section { # sections => %descriont descriptions # -sub repstr { - $pattern = shift; - $repl = shift; - $match1 = shift; - $match2 = shift; - $match3 = shift; - $match4 = shift; - - $output = $repl; - $output =~ s,\$1,$match1,g; - $output =~ s,\$2,$match2,g; - $output =~ s,\$3,$match3,g; - $output =~ s,\$4,$match4,g; - - eval "\$return = qq/$output/"; - -# print "pattern $pattern matched 1=$match1 2=$match2 3=$match3 4=$match4 replace $repl yielded $output interpolated $return\n"; - - return; -} - sub just_highlight { my $contents = join "\n", @_; my $line; my $ret = ""; foreach $pattern (keys %highlights) { -# print "scanning pattern $pattern ($highlights{$pattern})\n"; - $contents =~ s:$pattern:repstr($pattern, $highlights{$pattern}, $1, $2, $3, $4):gse; + #print "scanning pattern $pattern ($highlights{$pattern})\n"; + my $replace = $highlights{$pattern}; + $contents =~ s/$pattern/$replace/gees; } foreach $line (split "\n", $contents) { if ($line eq ""){ @@ -372,6 +356,7 @@ sub output_texinfo { } } foreach $section (@{$args{'sectionlist'}}) { + $section =~ s/\@//g; print "\n\@strong{$section:} " if $section ne $section_default; $args{'sections'}{$section} =~ s:([{}]):\@$1:gs; output_highlight($args{'sections'}{$section}); @@ -980,7 +965,7 @@ foreach $file (@ARGV) { $newsection = $1; $newcontents = $2; - if ($contents ne "") { + if ($contents ne '') { dump_section($section, $contents); $section = $section_default; } @@ -1003,7 +988,7 @@ foreach $file (@ARGV) { } elsif ($line =~ /$doc_content/) { # miguel-style comment kludge, look for blank lines after # @parameter line to signify start of description - if ($1 eq "" && $section =~ m/^@/) { + if ($1 eq '' && $section =~ m/^@/) { dump_section($section, $contents); $section = $section_default; $contents = ""; -- cgit v1.2.1