From 67a89e1454303623c5025c85d9f884d8c639c5e6 Mon Sep 17 00:00:00 2001 From: Russ Rowan Date: Sun, 8 Jan 2006 05:15:08 -0500 Subject: [PATCH] Added a document helper script: code2doc. It's ugly and mean, but it gets the job done. --- doc/tools/code2doc | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 doc/tools/code2doc diff --git a/doc/tools/code2doc b/doc/tools/code2doc new file mode 100755 index 000000000..f5865b338 --- /dev/null +++ b/doc/tools/code2doc @@ -0,0 +1,43 @@ +#!/usr/bin/perl -w +use strict; +use warnings; +use diagnostics; + +print "Usage: $0 [FILE]\n\tParses [FILE], outputing the result to [FILE].out.\n" + and exit if not @ARGV; + +my ($input) = @ARGV; +my ($output) = $input . '.out'; +my ($found, $start); +print "CopyleftŠ 2006, Russ Rowan (See `COPYING')\n" and exit if $input eq '-v'; +open FILEIN, "<$input" or print "File `$input' was not found.\n" and exit; +open FILEOUT, ">$output" or print "Cannot open $output for writing.\n" and exit; +print "Processing $input...\n"; +while () +{ + if ($found) + { + next if $_ =~ /^\s+\*\s$/; + if ($_ =~ /^\s\*+\/$/ or $_ !~ /^\s/) { $found = undef; next; } + $_ =~ s/^(\s*)\s\*\s/$1/; + $found = 'sorta' if $_ =~ s/\s*\*\/$//; + } + elsif ($_ =~ /^\s*\/\*\*\s(.*)/) + { + print FILEOUT "\n\n" if $start; + $_ = $1; + if ($_ =~ s/\s*\*\/$//) { $found = 'sorta'; } else { $found = $.; } + my $dash; for (my $x = 0; $x < length($_); $x++) { $dash .= '-'; } + $_ = "$_\n$dash\n"; + } + elsif ($_ =~ /\s*([A-Z0-9_]+),\s*\/\*::\s*(.*)\s*\*\/$/) + { + $_ =~ s/\s*([A-Z0-9_]+),\s*\/\*::\s*(.*)\s*\*\/$/id[$1]::\n $2/; + $found = 'sorta'; + } + next if not $found; $found = undef if $found eq 'sorta'; + print FILEOUT $_ and $start = 1; +} +close FILEOUT; +close FILEIN; +print "$output completed.\n";