summaryrefslogtreecommitdiff
path: root/d/sys/lampion/local/bin/extractdoc
diff options
context:
space:
mode:
authorschodet2005-06-12 17:34:23 +0000
committerschodet2005-06-12 17:34:23 +0000
commit46d955832a288667dbc940e572f2edccb4b35616 (patch)
treef3046e50e8bc783c8bb73295eeaa24372dd402d3 /d/sys/lampion/local/bin/extractdoc
parent334c98e83322cf64f3766142c2360555e6daed60 (diff)
Ajout des fichiers lampion.
Diffstat (limited to 'd/sys/lampion/local/bin/extractdoc')
-rwxr-xr-xd/sys/lampion/local/bin/extractdoc55
1 files changed, 55 insertions, 0 deletions
diff --git a/d/sys/lampion/local/bin/extractdoc b/d/sys/lampion/local/bin/extractdoc
new file mode 100755
index 0000000..01c0198
--- /dev/null
+++ b/d/sys/lampion/local/bin/extractdoc
@@ -0,0 +1,55 @@
+#!/usr/bin/perl -w
+use strict;
+
+while (<>)
+{
+ if (/^\/\*\*/)
+ {
+ my @doc;
+ my @def;
+ my $stop;
+ # Capture comments.
+ INNER: {
+ do {
+ chomp;
+ last INNER if /^[ \t]*\*\/[ \t]*$/;
+ $stop = 1 if /\*\//;
+ s/^\/?[ \t]*\*+ ?//;
+ s/^[ \t]+/\t/;
+ s/^\t- *([^:-]+) *:/\t[$1]/;
+ s/[ \t]*\*\///;
+ push @doc, $_;
+ last INNER if defined $stop;
+ } while (<>);
+ }
+ # Capture definition.
+ $_ = <>;
+ if (/^# *define /)
+ {
+ INNER: {
+ do {
+ chomp;
+ push @def, $_ . ' ';
+ if ($#def > 5)
+ {
+ push @def, '...';
+ last;
+ }
+ last unless /\\$/
+ } while (<>);
+ }
+ }
+ else
+ {
+ INNER: {
+ do {
+ chomp;
+ s/\)[^)]*$/);/;
+ push @def, $_;
+ last if /\)/;
+ } while (<>);
+ }
+ }
+ print join "\n", @doc, '', '^<<', @def, '^>>', '', '';
+ }
+}