~ubuntu-branches/ubuntu/oneiric/yacas/oneiric

« back to all changes in this revision

Viewing changes to manualmaker/manualmaker

  • Committer: Bazaar Package Importer
  • Author(s): Gopal Narayanan
  • Date: 2002-04-23 13:50:51 UTC
  • Revision ID: james.westby@ubuntu.com-20020423135051-bbd6ov4orr8eufmw
Tags: upstream-1.0.51
ImportĀ upstreamĀ versionĀ 1.0.51

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
Book(title) :=
 
3
[
 
4
WriteString("Creating Book ");
 
5
WriteString(title);NewLine();
 
6
 
 
7
 plain["Title"] := title;
 
8
];
 
9
 
 
10
AddBody(text):=
 
11
[
 
12
  currentBody[2] := currentBody[2]:text;
 
13
  GarbageCollect();
 
14
  True;
 
15
/*TODO remove?
 
16
plain["Chapters"][currentChapter]["Body"]:=
 
17
    plain["Chapters"][currentChapter]["Body"] : text;
 
18
*/
 
19
];
 
20
 
 
21
Chapter(title):=
 
22
[
 
23
GarbageCollect();
 
24
WriteString("  Creating Chapter ");
 
25
WriteString(title);NewLine();
 
26
  currentChapter:=title;
 
27
  currentChapterIndex++;
 
28
  currentSectionIndex:=0;
 
29
  plain["Chapters"][currentChapter]:={};
 
30
  plain["Chapters"][currentChapter]["Sections"]:={};
 
31
  plain["Chapters"][currentChapter]["Body"]:="";
 
32
 
 
33
currentBody := Assoc("Body",plain["Chapters"][currentChapter]);
 
34
 
 
35
  plain["Chapters"][currentChapter]["Index"]:=currentChapterIndex;
 
36
  plain["Chapters"][currentChapter]["Intro"]:=HtmlTag(chapter, title);
 
37
  plain["Chapters"][currentChapter]["Commands"]:={};
 
38
 
 
39
/*TODO remove? AddAnchor(ChapterTag(currentChapterIndex)); */
 
40
];
 
41
 
 
42
ChapterIntro(text) :=
 
43
[
 
44
  plain["Chapters"][currentChapter]["Intro"] :=
 
45
     plain["Chapters"][currentChapter]["Intro"] : text : newline;
 
46
];
 
47
 
 
48
Bodied("ChapterIntro", 60000);
 
49
 
 
50
AddAnchor(aAnchor):=
 
51
[
 
52
  AddBody(HtmlAnchor()aAnchor);
 
53
  plain["Chapters"][currentChapter]["Commands"] :=
 
54
     Concat(plain["Chapters"][currentChapter]["Commands"], 
 
55
            {{ChapterLink(aAnchor), ""}});
 
56
];
 
57
 
 
58
SectionTag(chapterIndex,sectionIndex):=
 
59
  "c" : String(chapterIndex) : "s" : String(sectionIndex) ;
 
60
 
 
61
ChapterTag(chapterIndex):=
 
62
  "c" : String(chapterIndex) ;
 
63
 
 
64
Section(title):=
 
65
[
 
66
WriteString("    Creating Section ");
 
67
WriteString(title);NewLine();
 
68
 
 
69
  currentSectionIndex++;
 
70
  plain["Chapters"][currentChapter]["Sections"][title]:=
 
71
    currentSectionIndex;
 
72
  AddBody(HtmlAnchor()SectionTag(currentChapterIndex,currentSectionIndex));
 
73
  AddBody(HtmlTag(section,"<HR>":title));
 
74
];
 
75
 
 
76
CmdDescription(cmd, desc) :=
 
77
[
 
78
  AddBody(HtmlAnchor() cmd);
 
79
  AddBody(HtmlAnchor() ToLowerCase(cmd));       // add a lowercase version for easier help
 
80
  SubSection(cmd : " -- " : desc);
 
81
  plain["Chapters"][currentChapter]["Commands"] :=
 
82
     Concat(plain["Chapters"][currentChapter]["Commands"], 
 
83
            {{ChapterLink(cmd), desc}});
 
84
];   
 
85
 
 
86
ChapterLink(aLink) := 
 
87
  HtmlLink(aLink, plain["BaseName"] : "chapter" 
 
88
                                    : String(currentChapterIndex) : ".html",
 
89
           aLink, "Chapters");
 
90
 
 
91
SubSection(title):=
 
92
[
 
93
/*
 
94
WriteString("      Sub section ");
 
95
WriteString(title);NewLine();
 
96
*/
 
97
  AddBody(HtmlTag(subsection,"<HR>":title));
 
98
];
 
99
 
 
100
Topical(title):=
 
101
[
 
102
  AddBody(HtmlTag(topical,title));
 
103
];
 
104
 
 
105
 
 
106
Text(text):=
 
107
[
 
108
  AddBody(text : newline);
 
109
];
 
110
 
 
111
 
 
112
Blurb(text):=
 
113
[
 
114
  plain["Blurb"]:=text;
 
115
];
 
116
 
 
117
HtmlCommand(command):=
 
118
[
 
119
HtmlTable(3,"90%",
 
120
"<TR>" : "<TD WIDTH=100% bgcolor=e0e0e0>" : "<PRE>" : command : "</PRE></TR>"
 
121
         );
 
122
];
 
123
 
 
124
HtmlTerm(term):= ("<B><TT>" : EscapeLtGt(term) : "</TT></B>");
 
125
 
 
126
HtmlEmphasis(word) := ("<I>" : word : "</I>");
 
127
 
 
128
HtmlBreak():="<P>  </P>";
 
129
 
 
130
 
 
131
Enumerate(body):=
 
132
[
 
133
  "<UL>" : body : "</UL>";
 
134
];
 
135
Bodied("Enumerate",2);
 
136
 
 
137
Itemize(body):=
 
138
[
 
139
  "<UL>" : body : "</UL>";
 
140
];
 
141
Bodied("Itemize",2);
 
142
 
 
143
Item(body):=
 
144
[
 
145
  "<LI>" : body;
 
146
];
 
147
Bodied("Item",1);
 
148
 
 
149
 
 
150
 
 
151
 
 
152
 
 
153
Bodied("Book",60000);
 
154
 
 
155
Bodied("Title",60000);
 
156
Bodied("Author",60000);
 
157
 
 
158
Bodied("Chapter",60000);
 
159
 
 
160
Bodied("Section",60000);
 
161
Bodied("SubSection",60000);
 
162
Bodied("Topical",60000);
 
163
Bodied("Text",60000);
 
164
 
 
165
Bodied("Blurb",60000);
 
166
Bodied("DocumentationComment",60000);
 
167
 
 
168
 
 
169
RuleBase("WriteItem",{item});
 
170
Rule("WriteItem",1,1,IsString(item)) WriteString(item);
 
171
Rule("WriteItem",1,2,True) Write(item);
 
172
 
 
173
WriteList(list):=
 
174
[
 
175
  ForEach(item,list)
 
176
  [
 
177
    WriteItem(item);
 
178
  ];
 
179
];
 
180
 
 
181
 
 
182
InitBooks():=
 
183
[
 
184
  site["Books"]:={};
 
185
];
 
186
 
 
187
SelectBook(book):=
 
188
[
 
189
  plain:=site["Books"][book];
 
190
];
 
191
 
 
192
InitBook(basename):=
 
193
[
 
194
  /* create a new book */
 
195
  site["Books"][basename]:={};
 
196
  SelectBook(basename);
 
197
  plain["BaseName"]:=basename;
 
198
  plain["Chapters"] := {};
 
199
  plain["Body"]:="";
 
200
  plain["Blurb"]:="";
 
201
  currentChapterIndex:=0;
 
202
  currentSectionIndex:=0;
 
203
];
 
204
 
 
205
 
 
206
 
 
207
SimpleSectionsIndex(filename,chapter,sections):=
 
208
[
 
209
  Local(bl,section,index);
 
210
  bl:="";
 
211
  index:=plain["Chapters"][chapter]["Index"];
 
212
 
 
213
  ForEach(section,sections)
 
214
  [
 
215
    bl := bl:HtmlTag(bullet,
 
216
                     HtmlLink(section,filename,SectionTag(index,
 
217
    plain["Chapters"][chapter]["Sections"][section]),""));
 
218
  ];
 
219
  bl;
 
220
];
 
221
 
 
222
 
 
223
SimpleChapterIndex(filename,chapters):=
 
224
[
 
225
  Local(bl,chapter);
 
226
  bl:="";
 
227
  ForEach(chapter,chapters)
 
228
  [
 
229
    bl := bl:HtmlTag(bullet,
 
230
    HtmlLink(chapter,filename,
 
231
       ChapterTag(plain["Chapters"][chapter]["Index"]),""));
 
232
      );
 
233
    sections:=AssocIndices(plain["Chapters"][chapter]["Sections"]);
 
234
    if (sections != {})
 
235
    [
 
236
      bl:=bl : HtmlTag(bullets,SimpleSectionsIndex(filename,chapter,sections));
 
237
    ];
 
238
  ];
 
239
  bl;
 
240
];
 
241
 
 
242
 
 
243
FramedSectionsIndex(filename,chapter,sections):=
 
244
[
 
245
  Local(bl,section,index);
 
246
  bl:="";
 
247
/*  sections:=AssocIndices(plain["Chapters"][chapter]["Sections"]); */
 
248
  index:=plain["Chapters"][chapter]["Index"];
 
249
 
 
250
  ForEach(section,sections)
 
251
  [
 
252
    bl := bl:HtmlTag(bullet,
 
253
                     HtmlLink(section,filename,SectionTag(index,
 
254
    plain["Chapters"][chapter]["Sections"][section]),"Chapters"));
 
255
  ];
 
256
  bl;
 
257
];
 
258
 
 
259
FramedChapterIndex(chapters):=
 
260
[
 
261
  Local(bl,chapter);
 
262
  bl:="";
 
263
  ForEach(chapter,chapters)
 
264
  [
 
265
    Local(file,index);
 
266
    index:=plain["Chapters"][chapter]["Index"];
 
267
    file:=plain["BaseName"] : "chapter" : String(index) : ".html";
 
268
    bl := bl:HtmlTag(bullet,
 
269
    HtmlLink(chapter,file,
 
270
       ChapterTag(plain["Chapters"][chapter]["Index"]),"Chapters"));
 
271
      );
 
272
 
 
273
    sections:=AssocIndices(plain["Chapters"][chapter]["Sections"]);
 
274
    if (sections != {})
 
275
    [
 
276
      bl:=bl : HtmlTag(bullets,FramedSectionsIndex(file,chapter,sections));
 
277
    ];
 
278
  ];
 
279
  bl;
 
280
];
 
281
 
 
282
 
 
283
/* hier */
 
284
 
 
285
GroupBooks(first,second):=
 
286
[
 
287
  site["Books"][first]["Chapters"] :=
 
288
    Concat(site["Books"][second]["Chapters"], site["Books"][first]["Chapters"]);
 
289
];
 
290
 
 
291
 
 
292
EmitHtmlSimple():=
 
293
[
 
294
  Local(filename);
 
295
  filename:=plain["BaseName"] : ".html";
 
296
 
 
297
WriteString("Writing ");
 
298
WriteString(filename);
 
299
NewLine();
 
300
 
 
301
  ToFile(HtmlFile(filename))
 
302
  [
 
303
    Local(bodytext,chapter,chapters,pcc);
 
304
    bodytext:="";
 
305
    chapters:=AssocIndices(plain["Chapters"]);
 
306
    bodytext:=bodytext : HtmlTag(book,plain["Title"]);
 
307
  
 
308
    bodytext:= bodytext : HtmlTag(bullets,SimpleChapterIndex(filename,chapters));
 
309
  
 
310
    ForEach(chapter,chapters)
 
311
    [
 
312
      pcc := plain["Chapters"][chapter];        
 
313
      bodytext:=bodytext : (HtmlAnchor() ChapterTag(pcc["Index"]))
 
314
                : ChapterHeader(pcc["Commands"]) : pcc["Intro"] : pcc["Body"] 
 
315
                : "<p>  </P><HR>";
 
316
      GarbageCollect();
 
317
    ];
 
318
 
 
319
    WriteString(
 
320
      HtmlTag(html,
 
321
              HtmlTitle(plain["Title"]) :
 
322
              HtmlTag(font,HtmlTag(body,bodytext)) /*hier*/
 
323
             ) );
 
324
  ];
 
325
];
 
326
 
 
327
EmitHtmlFramed():=
 
328
[
 
329
  Local(chapter,chapters);
 
330
  chapters:=AssocIndices(plain["Chapters"]);
 
331
 
 
332
  ToFile(HtmlFile(plain["BaseName"] : "manual.html"))
 
333
  [
 
334
    WriteString(
 
335
 
 
336
    HtmlTag(html,
 
337
        HtmlFrameSetCols("240,*",
 
338
          HtmlFrameSetRows("110,*",
 
339
            HtmlFrame("manicon.html","") : 
 
340
            HtmlFrame(plain["BaseName"] : "chapters.html","")
 
341
                  ) :
 
342
          HtmlFrame(plain["BaseName"] : "chapter1.html","Chapters")
 
343
                )
 
344
           )
 
345
    );
 
346
  ];
 
347
 
 
348
 
 
349
WriteString("Writing ");
 
350
WriteString(plain["BaseName"]);
 
351
NewLine();
 
352
 
 
353
  ToFile(HtmlFile(plain["BaseName"] : "chapters.html"))
 
354
    WriteString(
 
355
      HtmlTag(html,
 
356
      HtmlTag(font,HtmlTag(indexbody,
 
357
                HtmlTag(bullets,FramedChapterIndex(chapters)))
 
358
               ) ) );
 
359
 
 
360
  ForEach(chapter,chapters)
 
361
  [
 
362
    Local(pcc,file,index,str,keyword);
 
363
    pcc := plain["Chapters"][chapter];
 
364
    index := pcc["Index"];
 
365
    file := plain["BaseName"] : "chapter" : String(index) : ".html";
 
366
    str := HtmlAnchor() ChapterTag(index);
 
367
    str := str : ChapterHeader(pcc["Commands"]);
 
368
    str := str : pcc["Intro"] : "<p> </p>" : newline;
 
369
    If (pcc["Commands"] != {}, 
 
370
        str := str : ChapterTOC(pcc["Commands"]));
 
371
    str := str : pcc["Body"];
 
372
    str := HtmlTitle(chapter) : newline : HtmlTag(body, HtmlTag(font, str));
 
373
    ToFile(HtmlFile(file)) WriteString(HtmlTag(html, str));
 
374
    GarbageCollect();
 
375
  ];
 
376
];
 
377
 
 
378
10 # ChapterHeader({}) <-- "";
 
379
20 # ChapterHeader(_alist) <--
 
380
[
 
381
  Local(str, keyword);
 
382
  str := Head(alist)[1];
 
383
  ForEach(keyword, Tail(alist))
 
384
    str := str : ", " : keyword[1];
 
385
  str := str : "." : newline;
 
386
];
 
387
 
 
388
ChapterTOC(alist) :=
 
389
[
 
390
  Local(str, flag, keyword);
 
391
  flag := True;
 
392
  ForEach(keyword, alist) 
 
393
     flag := flag And (keyword[2] = "");
 
394
  If (flag, 
 
395
      str := "", /* If there are no descriptions, a TOC has no use */
 
396
      [
 
397
        str := "<CENTER><TABLE>";
 
398
        str := str : newline;   
 
399
        ForEach(keyword, alist)
 
400
          str := str : "<TR BGCOLOR=#E0E0E0>" : newline
 
401
                     : "<TD>" : keyword[1] : "</TD>" : newline
 
402
                     : "<TD>" : keyword[2] : "</TD>" : newline
 
403
                     : "</TR>" : newline;
 
404
        str := str : "</TABLE></CENTER>" : newline;
 
405
      ]);
 
406
];
 
407
 
 
408
BookList():=
 
409
[
 
410
  Local(book,books,bl);
 
411
  bl:="";
 
412
  books:=AssocIndices(site["Books"]);
 
413
  ForEach(book,books)
 
414
  [
 
415
    Local(bookinfo);
 
416
    bookinfo:=site["Books"][book];
 
417
 
 
418
    bl:= bl : 
 
419
     "<TR>" : "<TD bgcolor=e0e0e0><FONT face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\">
 
420
     " : HtmlLink(bookinfo["Title"],book:"manual.html","","_top") :
 
421
/*     " or " : HtmlLink(" (single file) ",bookinfo["BaseName"]:".html","","_top") : */
 
422
     "</TR><TR>" : "<TD bgcolor=ffffff><FONT face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\">
 
423
     " : bookinfo["Blurb"] :"</TR>";
 
424
  ];
 
425
  bl;
 
426
];
 
427
 
 
428
 
 
429
EmitBookIndex():=
 
430
[
 
431
WriteString("Creating book index"); NewLine();
 
432
  ToFile(HtmlFile("books.html"))
 
433
  [
 
434
    WriteString(
 
435
      HtmlTag(html,
 
436
              HtmlTitle("Yacas documentation") :
 
437
              HtmlTag(font,
 
438
              "<center><H1>Yacas documentation</H1></center>":
 
439
              HtmlTag(body,HtmlTable(3,"",
 
440
/*              HtmlCaption("Yacas documentation"): */
 
441
              BookList()))) /*hier*/
 
442
             )
 
443
    );
 
444
  ];
 
445
  True;
 
446
];
 
447
 
 
448
 
 
449
10 # SeeAlso({}) <-- True;
 
450
20 # SeeAlso(_list) <--
 
451
     [
 
452
        Local(item);
 
453
        AddBody(SeeAlso1(Head(list)));
 
454
        ForEach(item, Tail(list)) AddBody(", " : SeeAlso1(item));
 
455
        AddBody(".");
 
456
     ];
 
457
 
 
458
SeeAlso1(_seealso) <-- HtmlLink(seealso, "ref.html", seealso, "Chapters");
 
459
 
 
460
/*
 
461
SeeAlso(_list)<--
 
462
[
 
463
  ForEach(item,list)
 
464
  [
 
465
    AddBody(HtmlLink(item,"ref.html",item,"Chapters"):", ");
 
466
  ];
 
467
];
 
468
*/
 
469
 
 
470
BuiltIn() <-- AddBody("<h5 align=right>Internal function</h5>");
 
471
UnixSpecific() <-- AddBody("<h5 align=right>Unix-specific add-on</h5>");
 
472
MacSpecific() <-- AddBody("<h5 align=right>Macintosh-specific add-on</h5>");
 
473
MSWinSpecific() <-- AddBody("<h5 align=right>MS Windows-specific add-on</h5>");
 
474
StandardLib() <-- AddBody("<h5 align=right>Standard library</h5>");
 
475
 
 
476
/* alias for Load() that can be redefined */
 
477
IncludeFile(x) := [ Load(x); GarbageCollect(); ];
 
478
 
 
479
RuleBase("TeXMath", {x});
 
480
RuleBase("TeXMathD", {x});
 
481
RuleBase("TeXMathD", {x,y});
 
482
 
 
483
/* mathematical expressions */
 
484
TeXMath(x) := "<b>" : EscapeLtGt(ToString() Write(x)) : "</b>";
 
485
TeXMathD(x) := "
 
486
<p><center><b> " : EscapeLtGt(ToString() Write(x)) : " </b></center></p>
 
487
";
 
488
// special form: punctuation at the end of a displayed equation
 
489
TeXMathD(_x, _string) <-- "
 
490
<p><center><b> " : EscapeLtGt(ToString() Write(x)) : string : " </b></center></p>
 
491
";
 
492
 
 
493
HoldArg("TeXMath",x);
 
494
HoldArg("TeXMathD",x);
 
495
 
 
496
/* Replace all < and > characters in a string by &lt; and &gt; */
 
497
EscapeLtGtStrings := { {"<", "&lt;"}, {">", "&gt;"}, {"&", "&amp;"} };
 
498
EscapeLtGt(string) := [
 
499
        Local(i, result);
 
500
        result := "";
 
501
        For(i:=1, i<=Length(string), i++) result := result : If(EscapeLtGtStrings[string[i]] != Empty, EscapeLtGtStrings[string[i]], string[i]);
 
502
        result;
 
503
];
 
504
 
 
505
/* Convert ASCII-7 string to lowercase */
 
506
UCStrings :=
 
507
{
 
508
        {"A","a"},
 
509
        {"B","b"},
 
510
        {"C","c"},
 
511
        {"D","d"},
 
512
        {"E","e"},
 
513
        {"F","f"},
 
514
        {"G","g"},
 
515
        {"H","h"},
 
516
        {"I","i"},
 
517
        {"J","j"},
 
518
        {"K","k"},
 
519
        {"L","l"},
 
520
        {"M","m"},
 
521
        {"N","n"},
 
522
        {"O","o"},
 
523
        {"P","p"},
 
524
        {"Q","q"},
 
525
        {"R","r"},
 
526
        {"S","s"},
 
527
        {"T","t"},
 
528
        {"U","u"},
 
529
        {"V","v"},
 
530
        {"W","w"},
 
531
        {"X","x"},
 
532
        {"Y","y"},
 
533
        {"Z","z"},
 
534
};
 
535
LCStrings :=
 
536
{
 
537
        {"a","A"},
 
538
        {"b","B"},
 
539
        {"c","C"},
 
540
        {"d","D"},
 
541
        {"e","E"},
 
542
        {"f","F"},
 
543
        {"g","G"},
 
544
        {"h","H"},
 
545
        {"i","I"},
 
546
        {"j","J"},
 
547
        {"k","K"},
 
548
        {"l","L"},
 
549
        {"m","M"},
 
550
        {"n","N"},
 
551
        {"o","O"},
 
552
        {"p","P"},
 
553
        {"q","Q"},
 
554
        {"r","R"},
 
555
        {"s","S"},
 
556
        {"t","T"},
 
557
        {"u","U"},
 
558
        {"v","V"},
 
559
        {"w","W"},
 
560
        {"x","X"},
 
561
        {"y","Y"},
 
562
        {"z","Z"},
 
563
};
 
564
ToLowerCase(string) :=
 
565
[
 
566
        Local(i, result);
 
567
        result := "";
 
568
        For(i:=1, i<=Length(string), i++) result := result : If(UCStrings[string[i]] != Empty, UCStrings[string[i]], string[i]);
 
569
        result;
 
570
];