summaryrefslogtreecommitdiff
path: root/d/dev/sys/lampion/scripts/extractdoc
diff options
context:
space:
mode:
Diffstat (limited to 'd/dev/sys/lampion/scripts/extractdoc')
-rwxr-xr-xd/dev/sys/lampion/scripts/extractdoc49
1 files changed, 49 insertions, 0 deletions
diff --git a/d/dev/sys/lampion/scripts/extractdoc b/d/dev/sys/lampion/scripts/extractdoc
new file mode 100755
index 0000000..5d1c8ff
--- /dev/null
+++ b/d/dev/sys/lampion/scripts/extractdoc
@@ -0,0 +1,49 @@
+#!/usr/bin/perl -w
+use strict;
+
+while (<>)
+{
+ if (/^\/\*\*/)
+ {
+ my @doc;
+ my @def;
+ my $stop;
+ # Capture comments.
+ INNER: {
+ do {
+ chomp;
+ $stop = 1 if (/\*\//);
+ s/^\/? *\*+ ?//;
+ s/^ +/\t/;
+ s/^\t- *([^:-]+) *:/\t[$1]/;
+ s/ *\*\///;
+ push @doc, $_;
+ last INNER if defined $stop;
+ } while (<>);
+ }
+ # Capture definition.
+ $_ = <>;
+ if (/^# *define /)
+ {
+ INNER: {
+ do {
+ chomp;
+ push @def, $_;
+ last unless /\\$/;
+ } while (<>);
+ }
+ }
+ else
+ {
+ INNER: {
+ do {
+ chomp;
+ s/\).*/);/;
+ push @def, $_;
+ last if /\)/;
+ } while (<>);
+ }
+ }
+ print join "\n", @doc, '', '^<<', @def, '^>>', '', '';
+ }
+}