From 218ccc05b9583a6e7bcfdca16f7cf9a201c6ff73 Mon Sep 17 00:00:00 2001 From: "Mirar (Pontus Hagland)" <pike@sort.mirar.org> Date: Sun, 7 Dec 1997 00:42:36 +0100 Subject: [PATCH] man making experiment continues Rev: tutorial/Makefile:1.12 Rev: tutorial/man.pike:1.4 --- tutorial/Makefile | 15 +++++++---- tutorial/man.pike | 66 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 71 insertions(+), 10 deletions(-) diff --git a/tutorial/Makefile b/tutorial/Makefile index ea10c7015d..ed1fbe69a2 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 8e9cc7d20f..b99102e95d 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) -- GitLab