git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@76 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-30 11:43:15 +00:00
parent 31d01d3b79
commit 64534fe712
3 changed files with 175 additions and 17 deletions

View File

@@ -5,22 +5,99 @@
</head>
<body>
<h1 align="center">Milsko GUI Toolkit Documentation</h1>
<hr>
<h2>Mw/Button.h</h2>
<hr>
<h2 align="center">Mw/Button.h</h2>
<p>
Button widget.
</p>
<dt>
<code>MWDECL MwClass MwButtonClass;</code>
</dt>
<hr>
<pre><code>MWDECL MwClass MwButtonClass;</code></pre>
<dd>
Button class.
</dd>
<br>
<hr>
<h2>Mw/Core.h</h2>
<h2 align="center">Mw/Core.h</h2>
<p>
Core.
</p>
<hr>
<pre><code>#define MwDispatch(x, y)</code></pre>
<dd>
Dispatches a handler of widget class.
</dd>
<dt>
<img src="warning.gif" alt="warning">
</dt>
<dd>
Used internally.
</dd>
<dt>
Parameter <code>x</code>
</dt>
<dd>
Widget.
</dd>
<dt>
Parameter <code>y</code>
</dt>
<dd>
Handler name.
</dd>
<hr>
<pre><code>MWDECL MwWidget MwCreateWidget (
MwClass widget_class,
const char* name,
MwWidget parent,
int x,
int y,
unsigned int width,
unsigned int height
);</code></pre>
<dd>
Creates a widget.
</dd>
<dt>
Parameter <code>widget_class</code>
</dt>
<dd>
Widget class.
</dd>
<dt>
Parameter <code>name</code>
</dt>
<dd>
Widget name.
</dd>
<dt>
Parameter <code>parent</code>
</dt>
<dd>
Parent widget or <code>NULL</code>.
</dd>
<dt>
Parameter <code>x</code>
</dt>
<dd>
X.
</dd>
<dt>
Parameter <code>y</code>
</dt>
<dd>
Y.
</dd>
<dt>
Parameter <code>width</code>
</dt>
<dd>
Width.
</dd>
<dt>
Parameter <code>height</code>
</dt>
<dd>
Height.
</dd>
<hr>
</body>
</html>

View File

@@ -9,6 +9,12 @@
#include <Mw/MachDep.h>
#include <Mw/TypeDefs.h>
/*!
* %warning Used internally
* %brief Dispatches a handler of widget class
* %param x Widget
* %param y Handler name
*/
#define MwDispatch(x, y) \
if(x->widget_class != NULL && x->widget_class->y != NULL) x->widget_class->y(x)
@@ -18,6 +24,16 @@
extern "C" {
#endif
/*!
* %brief Creates a widget
* %param widget_class Widget class
* %param name Widget name
* %param parent Parent widget or `NULL`
* %param x X
* %param y Y
* %param width Width
* %param height Height
*/
MWDECL MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height);
MWDECL MwWidget MwVaCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...);
MWDECL MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va);

View File

@@ -6,10 +6,36 @@ our $title = "Milsko GUI Toolkit Documentation";
our @pathlist = ("include");
our @notes = ("warning", "unsure", "note");
sub sentence {
my $str = $_[0];
$str =~ s/([^\.])$/\1./g;
$str =~ s/`([^`]+)`/<code>\1<\/code>/g;
return $str;
}
sub out {
$html = $html . "$_[0]\n";
}
sub arguments {
my ($args) = @_;
my $out = "";
my @arglist = split(/[ \t]*,[ \t]*/, $args);
$out = $out . " (\n";
foreach my $str (@arglist){
$out = $out . "\t$str";
if($str eq $arglist[0+@arglist - 1]){
$out = $out . "\n";
}else{
$out = $out . ",\n";
}
}
$out = $out . ")";
return $out;
}
sub scan_dir {
my ($first, $path) = @_;
$path =~ s/\/+$//g;
@@ -31,30 +57,45 @@ sub scan_dir {
my $file = 0;
my $has_file = 0;
my %kv = ();
my %param = ();
my @paramlist = ();
print(STDERR "$path is a file\n");
open(IN, "<", "$path");
while(my $l = <IN>){
my $l2 = $l;
$l =~ s/[\r\n]+$//g;
$l2 =~ s/[\r\n \t]+//g;
if(length($l2) == 0){
next;
}
if($out){
my $para = "p";
my $brief = $kv{brief} or "";
$brief =~ s/([^\.])$/\1./g;
$brief = sentence($brief);
$out = 0;
if(!$has_file){
print(STDERR "Warning: missing comment with %file, ignoring\n");
next;
}
if(!defined($kv{brief})){
print(STDERR "Warning: comment missing %brief, ignoring\n");
next;
}
if(!$file && defined($kv{brief})){
$para = "dd";
$l =~ s/[ \t]*(?:;|\{.+)[ \t]*$//g;
$l =~ s/[ \t]*\\$//g;
$l =~ s/[ \t]*(?:;|\{.+)[ \t]*$/;/g;
if(!($l =~ /^#/)){
$l =~ s/\(([^\)]+)\)/arguments($1)/ge;
}
out("<dt>");
out(" <code>$l;</code>");
out("</dt>");
out("<pre><code>$l</code></pre>");
}
out("<$para>");
out(" $brief");
@@ -66,18 +107,36 @@ sub scan_dir {
out(" <img src=\"$note.gif\" alt=\"$note\">");
out("</dt>");
out("<dd>");
out(" $kv{$note}");
out(" " . sentence($kv{$note}));
out("</dd>");
}
}
if(!$file){
out("<br>");
foreach my $p (@paramlist){
out("<dt>");
out(" Parameter <code>$p</code>");
out("</dt>");
out("<dd>");
out(" " . sentence($param{$p}));
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;
@@ -85,12 +144,17 @@ sub scan_dir {
$kv{$1} = $2;
if($1 eq "file"){
if(!$has_file){
out("<hr>");
out("<h2>$2</h2>");
out("<h2 align=\"center\">$2</h2>");
}
$file = 1;
$has_file = 1;
}elsif($1 eq "param"){
my $p = $2;
$p =~ /^([^ ]+)(?:[ \t]+(.+))?$/;
$param{$1} = $2;
push(@paramlist, $1);
}
}
}
@@ -105,6 +169,7 @@ out(" <title>$title</title>");
out(" </head>");
out(" <body>");
out(" <h1 align=\"center\">$title</h1>");
out(" <hr>");
foreach my $f (@pathlist){
scan_dir($f, $f);