mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
Code2doc v2.0
This commit is contained in:
parent
9699396658
commit
9799a66710
@ -17,45 +17,35 @@ getopts("hv") or usage($HELP);
|
|||||||
$opt_v and usage("Copyleft (c) 2006, Russ Rowan (See `COPYING')");
|
$opt_v and usage("Copyleft (c) 2006, Russ Rowan (See `COPYING')");
|
||||||
usage($HELP) if $opt_h or @ARGV < 1;
|
usage($HELP) if $opt_h or @ARGV < 1;
|
||||||
|
|
||||||
my ($found, $indent, $idpath);
|
my ($header, $indent, $idpath);
|
||||||
$idpath = ''; $indent = '';
|
$idpath = ''; $indent = '';
|
||||||
while (<>)
|
while (<>)
|
||||||
{
|
{
|
||||||
my $end = s/\s*\*+\//\n/ ? 'yes' : undef;
|
my $end = s/\s*\*+\//\n/ ? 'yes' : undef;
|
||||||
|
|
||||||
# Match:
|
if ($end and /[^=]*[\s*](\w+)[\s,;].*\/\*::\s*(.*)/) {
|
||||||
# IDENT, /*:: ... */
|
# Implicit id for enum values and struct members.
|
||||||
# IDENT = value, /*:: ... */
|
$_ = "\nid:[$idpath$1]::\n\t$2\n";
|
||||||
# type ident; /*:: ... */
|
|
||||||
if ($end and /^(\s|[^\s=]+)*[\s*]([A-Za-z0-9_]+)(\s+=\s+[^,;]+)?[,;]\s*\/\*::\s*(.*)/)
|
} elsif ($header) {
|
||||||
{
|
# Redo the indentation, preserve empty lines.
|
||||||
print "\nid:[$idpath$2]::\n\t$4\n";
|
s/^(\s|\*)*/$indent/;
|
||||||
|
s/^$indent$/\n/;
|
||||||
|
|
||||||
|
} elsif (s/^\s*\/\*\*\s(.*)$/$1/) {
|
||||||
|
# Found magic header; record idpath and underline title.
|
||||||
|
$header = "$1";
|
||||||
|
$idpath = /struct:[[]([^\]]+)[\]]/ ? "$1." : "";
|
||||||
|
$indent = /::/ ? "\t" : "";
|
||||||
|
|
||||||
|
$_ = '' if $indent;
|
||||||
|
s/[^-]/-/g; chop;
|
||||||
|
$_ = "\n$header\n$_\n";
|
||||||
|
|
||||||
|
} else {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($found)
|
$header = undef if $end;
|
||||||
{
|
|
||||||
s/^(\s|\*)*/$indent/;
|
|
||||||
s/^$indent$/\n/;
|
|
||||||
}
|
|
||||||
elsif (/^\s*\/\*\*\s(.*)/)
|
|
||||||
{
|
|
||||||
$_ = $1;
|
|
||||||
if (/struct:[[]([^\]]+)[\]]/) { $idpath = "$1."; } else { $idpath = ''; }
|
|
||||||
if (/::/)
|
|
||||||
{
|
|
||||||
$_ = "\n$_\n\n";
|
|
||||||
$indent = "\t";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
my $dash; for (my $x = 0; $x < length($_); $x++) { $dash .= '-'; }
|
|
||||||
$_ = "\n$_\n$dash\n";
|
|
||||||
$indent = "";
|
|
||||||
}
|
|
||||||
$found = 'jep';
|
|
||||||
}
|
|
||||||
next if not $found;
|
|
||||||
$found = undef if $end;
|
|
||||||
print STDOUT $_;
|
print STDOUT $_;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user