Commit 6bf1a1377534304cce466fab907326b95d27fc14
1 parent
2715393d
*** empty log message ***
Showing
1 changed file
with
176 additions
and
2 deletions
Show diff stats
anubis_dev/library/doc_tools/make_doc.anubis
| ... | ... | @@ -123,6 +123,52 @@ public define List(DocItem) |
| 123 | 123 | Stream s |
| 124 | 124 | ). |
| 125 | 125 | |
| 126 | + | |
| 127 | +read tools/maml.anubis | |
| 128 | + | |
| 129 | + | |
| 130 | + *Description* | |
| 131 | + | |
| 132 | + The type 'DocLanguageSet' records several generic linguistic constructs for a given | |
| 133 | + natural language. | |
| 134 | + | |
| 135 | +public type DocLanguageSet: | |
| 136 | + language_set | |
| 137 | + ( | |
| 138 | + String -> String project, | |
| 139 | + String -> String copyright, | |
| 140 | + String -> String author, | |
| 141 | + String -> String revised, | |
| 142 | + One -> String public_header, | |
| 143 | + One -> String description_header | |
| 144 | + ). | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | +public define DocLanguageSet | |
| 149 | + french_language_set | |
| 150 | + = | |
| 151 | + language_set | |
| 152 | + ( | |
| 153 | + (String txt) |-> "Le projet "+txt, | |
| 154 | + (String txt) |-> txt, | |
| 155 | + (String txt) |-> "Auteur: "+txt, | |
| 156 | + (String txt) |-> "Dernière révision: "+txt, | |
| 157 | + (One u) |-> "Définition et Déclarations Publiques", | |
| 158 | + (One u) |-> "Description:" | |
| 159 | + ). | |
| 160 | + | |
| 161 | + | |
| 162 | + *Description* | |
| 163 | + | |
| 164 | + The function 'to_MAML' transforms a list of doc items into a document of type 'MAML'. | |
| 165 | + | |
| 166 | +public define MAML | |
| 167 | + to_MAML | |
| 168 | + ( | |
| 169 | + List(DocItem) l, | |
| 170 | + DocLanguageSet s | |
| 171 | + ). | |
| 126 | 172 | |
| 127 | 173 | |
| 128 | 174 | |
| ... | ... | @@ -130,9 +176,13 @@ public define List(DocItem) |
| 130 | 176 | |
| 131 | 177 | *Private* |
| 132 | 178 | |
| 179 | + | |
| 133 | 180 | |
| 134 | 181 | |
| 135 | 182 | |
| 183 | + *** [1] Reading a source file. | |
| 184 | + | |
| 185 | + | |
| 136 | 186 | type Position: |
| 137 | 187 | leftmost, // we are in leftmost column |
| 138 | 188 | blanks_only(Int32 n), // only 'n' blanks (or tabs) have been read on the current line |
| ... | ... | @@ -472,10 +522,108 @@ define Maybe(DocItem) |
| 472 | 522 | ) = |
| 473 | 523 | success(paragraph(init+read_paragraph_body(s,[],0))). |
| 474 | 524 | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + *** [2] Translation into MAML. | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | +public define String | |
| 535 | + to_MAML | |
| 536 | + ( | |
| 537 | + List(DocItem) l, | |
| 538 | + DocLanguageSet s | |
| 539 | + ) = | |
| 540 | + if l is | |
| 541 | + { | |
| 542 | + [ ] then "", | |
| 543 | + [item1 . items] then | |
| 544 | + if item1 is | |
| 545 | + { | |
| 546 | + tag(name,txt) then | |
| 547 | + with name = to_lower(name), | |
| 548 | + if name = "*project*" then | |
| 549 | + "$center($bold("+project(s)(txt)+"))" else | |
| 550 | + if name = "*title*" then | |
| 551 | + "$center($bold($big($big("+txt+"))))" else | |
| 552 | + if name = "*copyright*" then | |
| 553 | + "$green("+copyright(s)(txt)+")" else | |
| 554 | + if name = "*author*" then | |
| 555 | + "$par"+author(s)(txt) else | |
| 556 | + if name = "*revised*" then | |
| 557 | + "$par"+revised(s)(txt) else | |
| 558 | + if name = "*overview*" then | |
| 559 | + "$par$par"+txt+"$par$par" else | |
| 560 | + if name = "*public*" then | |
| 561 | + "$par$par$center($red($big("+public_header(s)(unique)+")))" else | |
| 562 | + if name = "*description*" then | |
| 563 | + "$par$par$blue($big("+description_header(s)(unique)+"))$par$red("+txt+")" else | |
| 564 | + "", | |
| 565 | + | |
| 566 | + | |
| 567 | + paragraph(txt) then | |
| 568 | + "$code("+txt+")" | |
| 569 | + | |
| 570 | + } + to_MAML(items,s) | |
| 571 | + }. | |
| 572 | + | |
| 573 | + | |
| 574 | + public define MAML | |
| 575 | + to_MAML | |
| 576 | + ( | |
| 577 | + List(DocItem) l, | |
| 578 | + DocLanguageSet s | |
| 579 | + ) = | |
| 580 | + if l is | |
| 581 | + { | |
| 582 | + [ ] then text(t), | |
| 583 | + [item1 . items] then | |
| 584 | + if item1 is | |
| 585 | + { | |
| 586 | + tag(name,txt) then | |
| 587 | + with name = to_lower(name), | |
| 588 | + if name = "*project*" then | |
| 589 | + mark("center",mark("bold",text(t-project(s)(txt)))) else | |
| 590 | + if name = "*title*" then | |
| 591 | + mark("center",mark("bold",mark("big",(text(t-txt))))) else | |
| 592 | + if name = "*copyright*" then | |
| 593 | + text(t-copyright(s)(txt)) else | |
| 594 | + if name = "*author*" then | |
| 595 | + mark("par") + text(t-author(s)(txt)) else | |
| 596 | + if name = "*revised*" then | |
| 597 | + mark("par") + text(t-revised(s)(txt)) else | |
| 598 | + if name = "*overview*" then | |
| 599 | + mark("par") + mark("par") + | |
| 600 | + text(t-txt) else | |
| 601 | + if name = "*public*" then | |
| 602 | + mark("par") + mark("par") + | |
| 603 | + mark("center",mark("red",mark("big",text(t-public_header(s)(unique))))) else | |
| 604 | + if name = "*description*" then | |
| 605 | + mark("par") + mark("par") + | |
| 606 | + mark("blue",mark("big",text(t-description_header(s)(unique)))) + | |
| 607 | + mark("par") + | |
| 608 | + mark("red",text(t-txt)) else | |
| 609 | + | |
| 610 | + text(t), | |
| 611 | + | |
| 612 | + | |
| 613 | + paragraph(txt) then | |
| 614 | + mark("code",text(t-txt)) | |
| 615 | + | |
| 616 | + } + to_MAML(items,s) | |
| 617 | + }. | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 475 | 623 | |
| 476 | 624 | |
| 477 | 625 | |
| 478 | - Testing. | |
| 626 | + *** [3] Testing. | |
| 479 | 627 | |
| 480 | 628 | define One |
| 481 | 629 | |
| ... | ... | @@ -501,12 +649,38 @@ define One |
| 501 | 649 | |
| 502 | 650 | |
| 503 | 651 | |
| 504 | -define One | |
| 652 | + define One | |
| 505 | 653 | make_doc |
| 506 | 654 | ( |
| 507 | 655 | Stream1 s |
| 508 | 656 | ) = |
| 509 | 657 | map_forget(print,read_all_items(s)). |
| 658 | + | |
| 659 | + | |
| 660 | +define String | |
| 661 | + env_HTML | |
| 662 | + ( | |
| 663 | + String txt | |
| 664 | + ) = | |
| 665 | + "<html><head></head><body><table><tr><td width=700>" + | |
| 666 | + "<p style=\"text-align:justify; font-family:helvetica; font-size:10pt\">" + | |
| 667 | + txt + | |
| 668 | + "</p></td></tr></table></body></html>". | |
| 669 | + | |
| 670 | + | |
| 671 | +define One | |
| 672 | + make_doc | |
| 673 | + ( | |
| 674 | + Stream1 s | |
| 675 | + ) = | |
| 676 | + if convert_MAML_to_HTML(to_MAML(read_all_items(s),french_language_set)) is | |
| 677 | + { | |
| 678 | + error(n) then print("Error in MAML translation.\n"), | |
| 679 | + ok(txt) then | |
| 680 | + print(env_HTML(txt)) | |
| 681 | + }. | |
| 682 | + | |
| 683 | + | |
| 510 | 684 | |
| 511 | 685 | define One |
| 512 | 686 | make_doc | ... | ... |