mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-03 16:10:50 +00:00
markdown-like
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@77 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -63,6 +63,7 @@ examples: $(EXAMPLES)
|
|||||||
|
|
||||||
format:
|
format:
|
||||||
clang-format --verbose -i $(shell find src include examples tools -name "*.c" -or -name "*.h")
|
clang-format --verbose -i $(shell find src include examples tools -name "*.c" -or -name "*.h")
|
||||||
|
perltidy -b -bext='/' --paren-tightness=2 $(shell find tools -name "*.pl")
|
||||||
|
|
||||||
src/libMw$(SO): $(L_OBJS)
|
src/libMw$(SO): $(L_OBJS)
|
||||||
$(CC) $(L_LDFLAGS) -shared -o $@ $^ $(L_LIBS)
|
$(CC) $(L_LDFLAGS) -shared -o $@ $^ $(L_LIBS)
|
||||||
|
|||||||
282
tools/doc.pl
282
tools/doc.pl
@@ -1,165 +1,177 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
our $html = "";
|
our $html = "";
|
||||||
our $title = "Milsko GUI Toolkit Documentation";
|
our $title = "Milsko GUI Toolkit Documentation";
|
||||||
our @pathlist = ("include");
|
our @pathlist = ("include");
|
||||||
our @notes = ("warning", "unsure", "note");
|
our @notes = ("warning", "unsure", "note");
|
||||||
|
|
||||||
sub sentence {
|
sub sentence {
|
||||||
my $str = $_[0];
|
my $str = $_[0];
|
||||||
$str =~ s/([^\.])$/\1./g;
|
$str =~ s/([^\.])$/\1./g;
|
||||||
$str =~ s/`([^`]+)`/<code>\1<\/code>/g;
|
$str =~ s/`(.+?)`/<code>\1<\/code>/g;
|
||||||
return $str;
|
$str =~ s/\*\*\*(.+?)\*\*\*/<b><i>\1<\/i><\/b>/g;
|
||||||
|
$str =~ s/\*\*(.+?)\*\*/<b>\1<\/b>/g;
|
||||||
|
$str =~ s/\*(.+?)\*/<i>\1<\/i>/g;
|
||||||
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub out {
|
sub out {
|
||||||
$html = $html . "$_[0]\n";
|
$html = $html . "$_[0]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub arguments {
|
sub arguments {
|
||||||
my ($args) = @_;
|
my ($args) = @_;
|
||||||
my $out = "";
|
my $out = "";
|
||||||
my @arglist = split(/[ \t]*,[ \t]*/, $args);
|
my @arglist = split(/[ \t]*,[ \t]*/, $args);
|
||||||
|
|
||||||
$out = $out . " (\n";
|
$out = $out . " (\n";
|
||||||
foreach my $str (@arglist){
|
foreach my $str (@arglist) {
|
||||||
$out = $out . "\t$str";
|
$out = $out . "\t$str";
|
||||||
if($str eq $arglist[0+@arglist - 1]){
|
if ($str eq $arglist[ 0 + @arglist - 1 ]) {
|
||||||
$out = $out . "\n";
|
$out = $out . "\n";
|
||||||
}else{
|
}
|
||||||
$out = $out . ",\n";
|
else {
|
||||||
}
|
$out = $out . ",\n";
|
||||||
}
|
}
|
||||||
$out = $out . ")";
|
}
|
||||||
|
$out = $out . ")";
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub scan_dir {
|
sub scan_dir {
|
||||||
my ($first, $path) = @_;
|
my ($first, $path) = @_;
|
||||||
$path =~ s/\/+$//g;
|
$path =~ s/\/+$//g;
|
||||||
|
|
||||||
if(opendir(my $dh, $path)){
|
if (opendir(my $dh, $path)) {
|
||||||
print(STDERR "Scanning $path\n");
|
print(STDERR "Scanning $path\n");
|
||||||
my @paths = sort(readdir($dh));
|
my @paths = sort(readdir($dh));
|
||||||
foreach my $p (@paths){
|
foreach my $p (@paths) {
|
||||||
if($p eq '.' || $p eq '..'){
|
if ($p eq '.' || $p eq '..') {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
scan_dir($first, $path . "/" . $p);
|
scan_dir($first, $path . "/" . $p);
|
||||||
}
|
}
|
||||||
closedir($dh);
|
closedir($dh);
|
||||||
}else{
|
}
|
||||||
my $spaces = "";
|
else {
|
||||||
my $in = 0;
|
my $spaces = "";
|
||||||
my $out = 0;
|
my $in = 0;
|
||||||
my $file = 0;
|
my $out = 0;
|
||||||
my $has_file = 0;
|
my $file = 0;
|
||||||
my %kv = ();
|
my $has_file = 0;
|
||||||
my %param = ();
|
my %kv = ();
|
||||||
my @paramlist = ();
|
my %param = ();
|
||||||
|
my @paramlist = ();
|
||||||
|
|
||||||
print(STDERR "$path is a file\n");
|
print(STDERR "$path is a file\n");
|
||||||
open(IN, "<", "$path");
|
open(IN, "<", "$path");
|
||||||
while(my $l = <IN>){
|
while (my $l = <IN>) {
|
||||||
my $l2 = $l;
|
my $l2 = $l;
|
||||||
$l =~ s/[\r\n]+$//g;
|
$l =~ s/[\r\n]+$//g;
|
||||||
|
|
||||||
$l2 =~ s/[\r\n \t]+//g;
|
$l2 =~ s/[\r\n \t]+//g;
|
||||||
if(length($l2) == 0){
|
if (length($l2) == 0) {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($out){
|
if ($out) {
|
||||||
my $para = "p";
|
my $para = "p";
|
||||||
my $brief = $kv{brief} or "";
|
my $brief = $kv{brief} or "";
|
||||||
|
|
||||||
$brief = sentence($brief);
|
$brief = sentence($brief);
|
||||||
|
|
||||||
$out = 0;
|
$out = 0;
|
||||||
if(!$has_file){
|
if (!$has_file) {
|
||||||
print(STDERR "Warning: missing comment with %file, ignoring\n");
|
print(STDERR
|
||||||
next;
|
"Warning: missing comment with %file, ignoring\n");
|
||||||
}
|
next;
|
||||||
if(!defined($kv{brief})){
|
}
|
||||||
print(STDERR "Warning: comment missing %brief, ignoring\n");
|
if (!defined($kv{brief})) {
|
||||||
next;
|
print(STDERR "Warning: comment missing %brief, ignoring\n");
|
||||||
}
|
next;
|
||||||
if(!$file && defined($kv{brief})){
|
}
|
||||||
$para = "dd";
|
if (!$file && defined($kv{brief})) {
|
||||||
|
$para = "dd";
|
||||||
|
|
||||||
$l =~ s/[ \t]*\\$//g;
|
$l =~ s/[ \t]*\\$//g;
|
||||||
$l =~ s/[ \t]*(?:;|\{.+)[ \t]*$/;/g;
|
$l =~ s/[ \t]*(?:;|\{.+)[ \t]*$/;/g;
|
||||||
if(!($l =~ /^#/)){
|
if (!($l =~ /^#/)) {
|
||||||
$l =~ s/\(([^\)]+)\)/arguments($1)/ge;
|
$l =~ s/\(([^\)]+)\)/arguments($1)/ge;
|
||||||
}
|
}
|
||||||
|
|
||||||
out("<pre><code>$l</code></pre>");
|
out("<pre><code>$l</code></pre>");
|
||||||
}
|
}
|
||||||
out("<$para>");
|
out("<$para>");
|
||||||
out(" $brief");
|
out(" $brief");
|
||||||
out("</$para>");
|
out("</$para>");
|
||||||
|
|
||||||
foreach my $note (@notes){
|
foreach my $note (@notes) {
|
||||||
if(defined($kv{$note})){
|
if (defined($kv{$note})) {
|
||||||
out("<dt>");
|
out("<dt>");
|
||||||
out(" <img src=\"$note.gif\" alt=\"$note\">");
|
out(" <img src=\"$note.gif\" alt=\"$note\">");
|
||||||
out("</dt>");
|
out("</dt>");
|
||||||
out("<dd>");
|
out("<dd>");
|
||||||
out(" " . sentence($kv{$note}));
|
out(" " . sentence($kv{$note}));
|
||||||
out("</dd>");
|
out("</dd>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $p (@paramlist){
|
foreach my $p (@paramlist) {
|
||||||
out("<dt>");
|
out("<dt>");
|
||||||
out(" Parameter <code>$p</code>");
|
out(" Parameter <code>$p</code>");
|
||||||
out("</dt>");
|
out("</dt>");
|
||||||
out("<dd>");
|
out("<dd>");
|
||||||
out(" " . sentence($param{$p}));
|
out(" " . sentence($param{$p}));
|
||||||
out("</dd>");
|
out("</dd>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(defined($kv{return})){
|
|
||||||
out("<dt>");
|
|
||||||
out(" Returns");
|
|
||||||
out("</dt>");
|
|
||||||
out("<dd>");
|
|
||||||
out(" " . sentence($kv{return}));
|
|
||||||
out("</dd>");
|
|
||||||
}
|
|
||||||
out("<hr>");
|
|
||||||
}elsif($l =~ /^([ \t]*)\/\*\!/){
|
|
||||||
$spaces = $1;
|
|
||||||
$in = 1;
|
|
||||||
$file = 0;
|
|
||||||
%kv = ();
|
|
||||||
%param = ();
|
|
||||||
@paramlist = ();
|
|
||||||
}elsif($in && ($l =~ /^$spaces \*\//)){
|
|
||||||
$in = 0;
|
|
||||||
$out = 1;
|
|
||||||
}elsif($in && ($l =~ /^$spaces \*[ \t]+%([^ ]+)(?:[ \t]+(.+))?$/)){
|
|
||||||
$kv{$1} = $2;
|
|
||||||
if($1 eq "file"){
|
|
||||||
if(!$has_file){
|
|
||||||
out("<h2 align=\"center\">$2</h2>");
|
|
||||||
}
|
|
||||||
|
|
||||||
$file = 1;
|
if (defined($kv{return})) {
|
||||||
$has_file = 1;
|
out("<dt>");
|
||||||
}elsif($1 eq "param"){
|
out(" Returns");
|
||||||
my $p = $2;
|
out("</dt>");
|
||||||
$p =~ /^([^ ]+)(?:[ \t]+(.+))?$/;
|
out("<dd>");
|
||||||
|
out(" " . sentence($kv{return}));
|
||||||
|
out("</dd>");
|
||||||
|
}
|
||||||
|
out("<hr>");
|
||||||
|
}
|
||||||
|
elsif ($l =~ /^([ \t]*)\/\*\!/) {
|
||||||
|
$spaces = $1;
|
||||||
|
$in = 1;
|
||||||
|
$file = 0;
|
||||||
|
%kv = ();
|
||||||
|
%param = ();
|
||||||
|
@paramlist = ();
|
||||||
|
}
|
||||||
|
elsif ($in && ($l =~ /^$spaces \*\//)) {
|
||||||
|
$in = 0;
|
||||||
|
$out = 1;
|
||||||
|
}
|
||||||
|
elsif ($in
|
||||||
|
&& ($l =~ /^$spaces \*[ \t]+%([^ ]+)(?:[ \t]+(.+))?$/))
|
||||||
|
{
|
||||||
|
$kv{$1} = $2;
|
||||||
|
if ($1 eq "file") {
|
||||||
|
if (!$has_file) {
|
||||||
|
out("<h2 align=\"center\">$2</h2>");
|
||||||
|
}
|
||||||
|
|
||||||
$param{$1} = $2;
|
$file = 1;
|
||||||
push(@paramlist, $1);
|
$has_file = 1;
|
||||||
}
|
}
|
||||||
}
|
elsif ($1 eq "param") {
|
||||||
}
|
my $p = $2;
|
||||||
close(IN);
|
$p =~ /^([^ ]+)(?:[ \t]+(.+))?$/;
|
||||||
}
|
|
||||||
|
$param{$1} = $2;
|
||||||
|
push(@paramlist, $1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(IN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out("<html>");
|
out("<html>");
|
||||||
@@ -171,8 +183,8 @@ out(" <body>");
|
|||||||
out(" <h1 align=\"center\">$title</h1>");
|
out(" <h1 align=\"center\">$title</h1>");
|
||||||
out(" <hr>");
|
out(" <hr>");
|
||||||
|
|
||||||
foreach my $f (@pathlist){
|
foreach my $f (@pathlist) {
|
||||||
scan_dir($f, $f);
|
scan_dir($f, $f);
|
||||||
}
|
}
|
||||||
|
|
||||||
out(" </body>");
|
out(" </body>");
|
||||||
|
|||||||
Reference in New Issue
Block a user