82 lines
1.4 KiB
Perl
82 lines
1.4 KiB
Perl
|
#! /usr/bin/perl
|
||
|
#
|
||
|
# docs/reference/beautify_docs.pl. Generated from beautify_docs.pl.in by configure.
|
||
|
#
|
||
|
|
||
|
#sub main()
|
||
|
{
|
||
|
my $directory = ".";
|
||
|
$directory = $ARGV[0] unless scalar(@ARGV) == 0;
|
||
|
print "processing directory $directory...\n" unless $directory =~ /^\.?$/;
|
||
|
|
||
|
foreach(`find "$directory" -type f -name '*.html'`)
|
||
|
{
|
||
|
chomp;
|
||
|
/([^\/]+)$/;
|
||
|
print "processing $1...\n";
|
||
|
&process($_);
|
||
|
}
|
||
|
|
||
|
exit 0;
|
||
|
}
|
||
|
|
||
|
sub process($)
|
||
|
{
|
||
|
my ($file) = @_;
|
||
|
my @outbuf;
|
||
|
|
||
|
open(FILE, '<', $file);
|
||
|
|
||
|
while(<FILE>)
|
||
|
{
|
||
|
if(/<a class="el"/)
|
||
|
{
|
||
|
# return value
|
||
|
s/ & /& /;
|
||
|
s/ \* /* /;
|
||
|
|
||
|
# arg list
|
||
|
s/ &/&/g;
|
||
|
s/&\b/& /g;
|
||
|
s/ \*/*/g;
|
||
|
s/\*\b/* /g;
|
||
|
|
||
|
# templates
|
||
|
s/\btemplate<\b/template </;
|
||
|
while(s/(.*<) +(.+) +(>.*)/$1$2$3/) {}
|
||
|
}
|
||
|
elsif(/<td class="md(|name)"/)
|
||
|
{
|
||
|
# left parenthesis
|
||
|
s/\( /(/;
|
||
|
|
||
|
# return value
|
||
|
s/ & /& /g;
|
||
|
s/ \* /* /g;
|
||
|
|
||
|
# arg list
|
||
|
s/ & /& /g;
|
||
|
s/ \* /* /g;
|
||
|
|
||
|
# templates
|
||
|
s/\btemplate<\b/template </;
|
||
|
while(s/(.*<) +(.+) +(>.*)/$1$2$3/) {}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
# template decls
|
||
|
s/^(|<h\d>)template<\b/$1template </;
|
||
|
}
|
||
|
|
||
|
push(@outbuf, $_);
|
||
|
}
|
||
|
|
||
|
open(FILE, '>', $file);
|
||
|
|
||
|
# write the whole buffer back
|
||
|
print FILE "$_" foreach(@outbuf);
|
||
|
|
||
|
close(FILE);
|
||
|
}
|
||
|
|