diff --git a/tutorial/Makefile b/tutorial/Makefile index ea10c7015d922f941ffd856c1bd496f45159232a..ed1fbe69a2d8418e3f391b49ff68398929748aed 100644 --- a/tutorial/Makefile +++ b/tutorial/Makefile @@ -2,18 +2,23 @@ all: tutorial.html tutorial_onepage.html # lenna.gif lenna-mirrorx.gif lenna-mirrory.gif lenna-rotate.gif lenna-skewx.gif lenna-skewy.gif -.DUMMY: Image.wmml +SRCFILES=tutorial.wmml Image.wmml -tutorial.html: .DUMMY +.DUMMY: + +tutorial.html: .DUMMY $(SRCFILES) ./wmmltohtml2 <tutorial.wmml html tutorial -tutorial_onepage.html: .DUMMY +tutorial_onepage.html: .DUMMY $(SRCFILES) ./wmmltohtml2 <tutorial.wmml html_onepage tutorial_onepage -tut.html: .DUMMY +tut.html: .DUMMY $(SRCFILES) ./wmmltohtml2 <tutorial.wmml sitebuilder tut -Image.wmml : +manpages: .DUMMY $(SRCFILES) + ./wmmltohtml2 <tutorial.wmml man man3P + +Image.wmml : (cd ../src/modules/Image; make wmml) the_image_module_onepage.html: Image.wmml the_image_module.wmml diff --git a/tutorial/man.pike b/tutorial/man.pike index 8e9cc7d20fbf20fadd1f4e94942edbfc537e7143..b99102e95d95d788b1585e4ad3d8b79d52937ef3 100644 --- a/tutorial/man.pike +++ b/tutorial/man.pike @@ -1,13 +1,69 @@ #include "types.h" inherit Stdio.File : out; -void make_pages(string base, SGML data, string ind); +void make_page(string base, TAG tag, string ind, string fbase); + +string make_manpage(string base, SGML data, string ind, string fbase) +{ + string res=""; + + if (stringp(data)) + res+=data; + else if(arrayp(data)) + foreach (data, TAG tag) + if (objectp(tag)) + { + switch (tag->tag) + { + case "method": + case "function": + case "class": + case "module": + make_page(base,tag,ind,fbase); + continue; + + case "man_title": + res+="\n.SH "+tag->params->title+"\n"; + break; + } + res+=make_manpage(base,tag->data,ind,fbase); + } + else if (stringp(tag)) + res+=tag; + + return res; +} void make_page(string base, TAG tag, string ind, string fbase) { - ind=""; werror(ind+tag->tag+" "+tag->params->name+"\n"); - make_pages(base,tag->data,ind+" "); + + string *outfiles; + + outfiles=Array.map(tag->params->name/",", + lambda(string s,string t,string u) + { + sscanf(replace(s,"->","."),t+".%s",s); + return u+"/"+s; + },fbase,base); + + werror("files: "+outfiles*", "+"\n"); + + if (tag->params->mansuffix) + { + base+=tag->params->mansuffix; + fbase=(tag->params->name/",")[0]; + } + + string page=""; + + page+=".TH "+(tag->params->name/",")[0]+" "+base[3..]+"\n"; + + page+=make_manpage(base,tag->data,ind+" ",fbase); + + werror(page); + + exit(0); } void make_pages(string base, SGML data, string ind, string fbase) @@ -16,9 +72,9 @@ void make_pages(string base, SGML data, string ind, string fbase) foreach (data, TAG tag) if (objectp(tag)) if ((<"method","function","class","module">)[tag->tag]) - make_page(base,tag,ind); + make_page(base,tag,ind,fbase); else - make_pages(base,tag->data,ind+" "); + make_pages(base,tag->data,ind,fbase); } void output(string base, WMML data)