1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
|
.\" $Id$
.\"
.\" The tools and formats described by this document are:
.\" COPYRIGHT (c) 2000 Bell Labs, Lucent Technologies.
.\" COPYRIGHT (c) 2003-2004 John Reppy (http://www.cs.uchicago.edu/~jhr)
.\"
.\" The document itself is licensed:
.\" Copyright (C) 2007 Timothy Bourke. All Rights Reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notices, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. No names are removed from the AUTHORS section.
.\"
.\" THIS DOCUMENTATION IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd August 2, 2007
.Os FreeBSD 6.2
.Dt ML-Doc 1
.\" ----------------------------------------
.Sh NAME
.\"
.Nm extract-sig
.Nd generate SML
.br
.Nm extract-info , merge-info
.Nd generate intermediate files
.br
.Nm html-gen , html-index , html-toc
.Nd generate HTML
.br
.Nm latex-gen , proof-latex
.Nd generate LaTeX
.br
.Nm filter-index , mk-mldoc-makefile
.Nd miscellaneous ml-doc tools
.\"
.\" ----------------------------------------
.Sh SYNOPSIS
.Nm extract-sig
.Op Fl config Ar config-file
.Op Fl dir Ar output-dir
.Ar mldoc-files
.\"
.Nm extract-info
.Op Fl config Ar config-file
.Op Fl dir Ar output-dir
.Ar mldoc-files
.\"
.Nm merge-info
.Op Fl config Ar config-file
.Op Fl o Ar output-file
.Ar info-files
.\"
.Nm html-index
.Op Fl config Ar config-file
.Op Fl dir Ar output-dir
.Op Fl o Ar output-file
.Op Fl info Ar path
.Op Fl cols Ar num
.Op Fl all | Fl sig | Fl struct | Fl exn | Fl type | Fl val
.\"
.Nm html-toc
.Op Fl config Ar config-file
.Op Fl dir Ar output-dir
.Op Fl o Ar output-file
.Op Fl info Ar path
.Op Fl depth Ar num
.\"
.Nm html-gen
.Op Fl config Ar config-file
.Op Fl dir Ar output-dir
.Op Fl info Ar path-to-infofile
.Op Fl wid Ar num
.Ar mldoc-file
.\"
.Nm latex-gen
.Op Fl config Ar config-file
.Op Fl dir Ar output-dir
.Op Fl doc
.Op Fl index
.Op Fl info Ar path-to-infofile
.Ar mldoc-file
.\"
.Nm proof-latex
.Op Fl config Ar config-file
.Op Fl dir Ar output-dir
.Op Fl doc
.Op Fl index
.Op Fl info Ar path-to-infofile
.Ar mldoc-file
.\"
.Nm filter-index
.\"
.Nm mk-mldoc-makefile
.Op Fl help
.Op Fl bin Ar dir
.Op Fl html Ar dir
.Op Fl info Ar dir
.Op Fl latex Ar dir
.Op Fl proof Ar dir
.Op Fl root Ar file
.Ar mldoc-files
.Sh DESCRIPTION
ML-Doc
is a system for producing reference manuals for SML libraries. It can
produce high quality documentation with extensive indexing, like the
published SML Basis Library reference manual, and also HTML for online use.
.Pp
ML-Doc
is different to systems like javadoc that extract documentation from source
files.
Rather, the documentation
.Em is
the primary artifact\(emin fact
.Nm extract-sig
can be used to create source files from documentation. The
.Xr mkdoc 1
utility, however, can produce first drafts from source files.
ML-Doc
is most useful for documenting stable library interfaces.
.Pp
ML-Doc
files, marked by the extension
.Pa .mldoc ,
are SGML documents conforming to the
ML-Doc
document type definition.
.Pp
This manual has four major sections besides the present one:
.Bl -tag -compact -width ".Sx WRITING DOCUMENTATION"
.It Sx OPTIONS
describes command line options and configuration files.
.It Sx USING ML-DOC
describes how the toolset is used to produce documentation and includes
subsections on
.Sx HTML Templates
and
.Sx Entities .
.It Sx WRITING DOCUMENTATION
describes the markup used within
.Pa *.mldoc
files.
.It Sx SGML VS HTML/XML
discusses some SGML features absent from HTML and XML.
.El
.\"
.Ss Generating SML
.Nm extract-sig
.Nd Extracts SML signatures from
.Pa *.mldoc
documentation.
.Pp
.\"
.Ss Generating intermediate files
.Nm extract-info
.Nd Produces intermediate files summarising interfaces and
the section hierarchy.
.Pp
.Nm merge-info
.Nd Combines intermediate files into a single master info file.
.Pp
.\"
.Ss Generating HTML
.Nm html-index
.Nd Produces HTML index files from a master info file.
.Pp
.Nm html-toc
.Nd Transform a master info file and HTML template into a table of contents.
.Pp
.Nm html-gen
.Nd Generate HTML output given template, master info, and mldoc input files.
.Pp
.\"
.Ss Generating LaTeX
.Nm latex-gen
.Nd Produce LaTex for printing given master info and mldoc input files.
.Pp
.Nm proof-latex
.Nd Produce LaTeX for proofing given master info and mldoc input files.
.Pp
.\"
.Ss Miscellaneous
.Nm filter-index
.Nd Reads a list of index entries, one per line, from standard input,
removes any duplicates, and writes the sorted entries to standard output.
.Pp
.Nm mk-mldoc-makefile
.Nd Create a Makefile that ties all the other tools together.
.\"
.\"
.\" ----------------------------------------
.Sh OPTIONS
Many command line options can also be specified in a configuration file,
using the names given in brackets.
.Pp
.Bl -tag -width indent
.\" config
.It Fl config Ar config-file
Defaults to
.Pa Config.cfg .
Contains global and per-tool settings.
.\" cols/NumColumns
.It Fl cols Ar num
.Pq Li NumColumns
Number of columns in the index. Defaults to 3.
.\" debug/Debug
.It Fl debug
.Pq Li Debug
Currently unused.
.\" depth/Depth
.It Fl depth Ar num
.Pq Li Depth
Sections nested more deeply than this number will not be listed in the
table of contents.
Defaults to 3.
.\" dir/OutDir
.It Fl dir Ar output-dir
.Pq Li OutDir
Specifies where to write output files.
The default is different for each tool:
.Bl -column -compact -offset indent ".Nm extract-sig" "Hardcopy"
.It Nm extract-sig Ta Pa Sigs
.It Nm extract-info Ta Pa Info
.It Nm html-index Ta Pa HTML
.It Nm html-toc Ta Pa HTML
.It Nm html-gen Ta Pa HTML
.It Nm latex-gen Ta Pa Hardcopy
.It Nm proof-latex Ta Pa Proof
.El
.\" doc/Standalone
.It Fl doc
.Pq Li Standalone
Currently unused.
.\" index
.It Fl index
Currently unused.
.\" info/MasterInfoFile
.It Fl info Ar path
.Pq Li MasterInfoFile
Locates the output of
.Nm merge-info .
Defaults to
.Pa Info/LaTeX.info
for the hardcopy and proof tools, and
.Pa Info/HTML.info
for the HTML tools.
.\" mldoc/MLDocDir
.It Fl mldoc
.Pq Li MLDocDir
Names the subdirectory of the
.Pa *.mldoc
files. Defaults to
.Li ML-Doc .
.\" o/OutFile
.It Fl o Ar output-file
.Pq Li OutFile
Specifies where to write output.
For
.Nm html-index
the default depends on the index generated:
.Bl -column -compact -offset indent "struct" ".Pa index-struct.html"
.It all Ta Pa index-all.html
.It sig Ta Pa index-sig.html
.It struct Ta Pa index-struct.html
.It exn Ta Pa index-exn.html
.It type Ta Pa index-type.html
.It val Ta Pa index-val.html
.El
Otherwise the name depends on the tool:
.Bl -column -compact -offset indent ".Nm merge-info" ".Pa Info/Master.info"
.It Nm merge-info Ta Pa Info/Master.info
.It Nm html-toc Ta Pa toc.html
.El
.\" all, sig, struct, exn, type, val
.It Fl all | Fl sig | Fl struct | Fl exn | Fl type | Fl val
Specify which index to generate, defaulting to
.Fl all :
.Bl -column -compact -offset indent ".Fl struct" "unified identifier index"
.It Fl all Ta unified identifier index
.It Fl sig Ta signatures
.It Fl struct Ta structures
.It Fl exn Ta exceptions
.It Fl type Ta types
.It Fl val Ta values
.El
.\" wid/PreWid
.It Fl wid Ar num
.Pq Li PreWid .
Width of the output device. Currently unused. Defaults to 60.
.El
.Pp
There are some additional options that can only be given in a configuration
file:
.Bl -tag -compact -width ".Sy TopLevelSection"
.\" **
.It Sy BaseURL
Applies to the
.Li HTML
grouping
.Pq described below .
If the RelativeLinks flag is true then intra-document links will be
relative,
otherwise the value of BaseURL, if present, is added as an HTML
.Li BASE
tag.
.\" **
.It Sy Catalog
Global option. Names the catalog file. Defaults to
.Pa CATALOG .
.\" **
.It Sy RelativeLinks
Applies to the
.Li HTML
grouping.
See BaseURL above.
Defaults to false.
.\" **
.It Sy Root
Applies to
.Nm html-gen .
Currently unused.
.\" **
.It Sy SGMLS
Applies to the
.Li Tools
grouping. Path to an SGML validating parser. Defaults to
.Pa %%PREFIX%%/bin/nsgmls .
.\" **
.It Sy Template
Applies to
.Nm html-index , html-toc ,
and
.Nm html-gen .
Names the template file.
.\" **
.It Sy TopLevelSection
Applies to
.Nm latex-gen
and
.Nm proof-latex .
Defaults to
.Li Chapter .
Other permitted values are
.Li Part
and
.Li Section .
Controls the generation of LaTeX sections.
.El
.Pp
A configuration file contains name/value pairs separated within and between
by white space. Single-line comments begin with a
.Ql # .
Groupings are made by giving a name followed by contained options
enclosed in braces,
.Li "{ ... }" .
Values are either names, decimal or hexadecimal literals, the latter
prefixed with
.Ql 0x ,
strings enclosed in double quotes, or logical values
.Po
.Ql TRUE
or
.Ql FALSE
.Pc .
As a brief example:
.Bd -literal -offset indent
# Catalog.cfg
Catalog "CATALOG"
HTML {
BaseURL "CML"
RelativeLinks TRUE
PreWid 70
}
.Ed
.Pp
.Nm mk-mldoc-makefile
does not currently respect the configuration file, instead it uses
command line options, which differ somewhat from the other tools:
.Bl -tag -width indent
.\" **
.It Fl help
Display a summary of options.
.\" **
.It Fl bin Ar dir
Specifies where the ML-Doc tool binaries are installed. Defaults to
.Pa %%PREFIX%%/bin .
.\" **
.It Fl html Ar dir
Output directory for HTML files. Defaults to
.Pa HTML .
.\" **
.It Fl info Ar dir
Output directory for info files. Defaults to
.Pa Info .
.\" **
.It Fl latex Ar dir
Output directory for LaTeX files.
Defaults to
.Pa Hardcopy .
.\" **
.It Fl proof Ar dir
Output directory for proof LaTeX files. Defaults to
.Pa Proof .
.\" **
.It Fl root Ar file
If present, the generated Makefile will run LaTeX against the given
filename, which should not have a
.Li .tex
extension.
.El
.\"
.\" ----------------------------------------
.Sh USING ML-DOC
.\"
.Ss Directory structure
An
ML-Doc
.Em project
comprises a set of files and directories that, at a minimum, will include:
.Bl -tag -width ".Pa index.template"
.\" **
.It Pa CATALOG
Typically links to
.Pa Entities.sgml
in the same directory and the installed
ML-Doc
.Pa CATALOG
file.
See
.Xr FILES .
.\" **
.It Pa Config.cfg
Global and per-tool configuration options.
See
.Xr OPTIONS .
.\" **
.It Pa Entities.sgml
Contains entities local to the project. These entities are used for
abbrevations and referencing external documents and files.
See
.Xr Entities .
.\" **
.It Pa ML-Doc/
The source
.Pa *.mldoc
SGML documentation.
.\" **
.It Pa index.template
Template used by
.Nm html-index .
.\" **
.It Pa page.template
Template used by
.Nm html-gen .
.\" **
.It Pa toc.template
Template used by
.Nm html-toc .
.El
.Pp
Running
.Nm mk-mldoc-makefile
adds:
.Bl -tag -width ".Pa index.template"
.\" **
.It Pa Makefile
Orchestrates the manifold programs to produce documentation.
.El
.Pp
The other tools place their output in additional subdirectories.
Empty subdirectories and any child directories therein
must be created before running the tools.
The default names are:
.Bl -tag -width ".Pa index.template"
.\" **
.It Pa HTML/
Output from the
.Nm html-gen , html-toc ,
and
.Nm html-index
tools.
.\" **
.It Pa Hardcopy/
Output from
.Nm latex-gen .
.\" **
.It Pa Info/
Output from
.Nm extract-info ,
further augmented by
.Nm merge-info ,
to be used by the other tools.
.\" **
.It Pa Proof/
Output from
.Nm proof-latex .
.\" **
.It Pa Sigs/
SML code created by
.Nm extract-sig .
.El
.\"
.Ss HTML Templates
Templates are HTML files containing special entities. The
.Nm html-*
tools replace entities with details from
.Pa *.mldoc
and
.Pa *.info
files.
Each tool works from a distinct template named in the configuration
file.
.Bl -column -offset indent ".Sy Tool name (in configuration file)" \
".Sy Typical Template value"
.It Sy Tool name (in configuration file) Ta Sy Typical Template value
.It HTML-Gen Ta Pa page.template
.It HTML-Index Ta Pa index.template
.It HTML-TOC Ta Pa toc.template
.El
.Pp
The entities are:
.Bl -tag -compact -offset indent -width ".Li &today.monthnum;"
.\" **
.It Li &body;
placeholder for document body
.\" **
.It Li &filename;
document filename without extension
.\" **
.It Li &title;
document title
.\" **
.It Li &version;
document version
.\" **
.It Li &doc.date;
document date in
.Qq month day, year
format
.\" **
.It Li &doc.year;
document year
.Pq 4 digit format
.\" **
.It Li &doc.day;
document day
.\" **
.It Li &doc.month;
document month
.Pq as a string
.\" **
.It Li &doc.monthnum;
document month
.Pq as a number from 1-12
.\" **
.It Li &today.date;
current date in
.Qq month day, year
format
.\" **
.It Li &today.year;
current year
.Pq 4 digit format
.\" **
.It Li &today.day;
current day
.\" **
.It Li &today.month;
current month
.Pq as a string
.\" **
.It Li &today.monthnum;
current month
.Pq as a number from 1-12
.\" **
.It Li &base.url;
URL of the root directory of the document
.\" **
.It Li &parent.url;
URL of the parent document
.\" **
.It Li &root.url;
URL of the document root
.\" **
.It Li &index.url;
URL of the document index
.\" **
.It Li &toc.url;
URL of the table of contents
.El
.\"
.Ss Entities
Entities are used within
ML-Doc
to include mathematical and other
specialised symbols, to abbreviate titles and other text, to reference
files, and to name certain output files.
The latter three purposes are served by including a customised
.Pa Entities.sgml
file within a project.
.Pp
Specialised symbols include various mathematical symbols
.Pq described under Sx Mathematics ,
the HTML 2.0 standard entities, e.g.
.Li , © ,
and these SGML/LaTeX symbols:
.Bl -column -offset indent -compact "&DQUOTE;" "MMMMMMMMM" "&DQUOTE;" "MMM"
.It Li < Ta Li < Ta Li <E; Ta Li <=
.It Li > Ta Li > Ta Li >E; Ta Li >=
.It Li &NEQ; Ta Li != Ta Li & Ta Li &
.It Li &DQUOTE; Ta Li \(dq Ta Li &BAR; Ta Li |
.It Li &DASH; Ta Li -
.El
.Pp
Abbreviations encourage consistency and facilitate certain types of updates.
These definitions, in an
.Pa Entities.sgml
file, are a good example:
.Bd -literal -offset indent -compact
<!ENTITY SMLBASIS SDATA "SML Basis Library">
<!ENTITY SMLNJ SDATA "SML/NJ">
.Ed
References, which will be expanded in the output text, may then be made from
.Pa *.mldoc
files:
.D1 This feature requires the &SMLNJ; libraries.
.Pp
Documentation will sometimes need to reference the
ML-Doc
descriptions of other libraries; such as those of the SML Basis, SML/NJ, or
Concurrent ML.
The reference tags described under
.Sx References
.Po
e.g.
.Li SIGREF , AREF
and
.Li DOCREF
.Pc
provide this facility via a
.Li DOCUMENT
attribute whose value must be an entity listed in
.Pa Entities.sgml ,
a bracketing ampersand and semicolon are not used for such values.
The entity resolves to an identifying string, which is sought within the
configuration file,
.Pa Config.cfg ,
to find an
.Em external document entry .
As an example, consider a constructor reference:
.Dl <CONREF DOCUMENT=SML-BASIS-DOC STRID="Option"/NONE/
The
.Li DOCUMENT
attribute value,
.Li SML-BASIS-DOC ,
is defined in the project entity file,
.Pa Entities.sgml :
.Bd -literal -offset indent -compact
<!ENTITY SML-BASIS-DOC SDATA "SML-Basis-Doc">
.Ed
The entity value,
.Li SML-Basis-Doc,
in turn refers to an entry in the configuration file:
.Bd -literal -offset indent -compact
.Li ...
SML-Basis-Doc {
InfoFile "%%PREFIX%%/smlnj/smlnj-lib/Doc/BasisInfo/HTML.info"
BaseURL "www.standardml.org/Basis"
RootURL "www.standardml.org/Basis/index.html"
}
.Li ...
.Ed
This example refers to a master info file installed with SML/NJ and directs
hyperlinks to the online documentation.
.Pp
Entities are also used within
ML-Doc
to specify values for the
.Li FILE
attribute, which specifies an input file for the
.Pq currently unsupported
.Li FIGURE
tag, and names an output file for the
.Li SIGBODY
tag.
.Nm extract-sig
expands the given entity to name the source code it produces, e.g. given an
entity declaration:
.Bd -literal -compact -offset indent
<!ENTITY CML-SIG SDATA "cml-sig.sml">
.Ed
The specifications in
.D1 <SIGBODY SIGID="CML" FILE=CML-SIG>
would be extracted to a file named
.Pa cml-sig.sml .
.\"
.Ss General Use
A simplified sequence of steps for creating
ML-Doc
documentation:
.Bl -enum
.\" **
.It
Create and populate the basic directory structure, as per
.Sx Directory Structure .
.\" **
.It
Use
.Xr mkdoc 1
to produce skeleton
.Pa *.mldoc
files.
Add explanatory text to each.
.\" **
.It
Add other
.Pa *.mldoc
files to link together into a continuous whole, and to explain the various interfaces.
.\" **
.It
Create a
.Pa Makefile
with
.Nm mk-mldoc-makefile ,
as shown under
.Sx EXAMPLES .
.\" **
.It
Use the make targets to generate documentation.
.Bl -tag -offset indent -width ".Li Hardcopy"
.It Li HTML
Default. Produce HTML pages.
.It Li Hardcopy
Create LaTeX files for generating the final document.
.It Li Proof
Create LaTeX files for generating a review document.
.It Li clean
Run the individual
.Li clean-html , clean-info , clean-latex ,
and
.Li clean-proof
targets to remove generated files.
.El
.\" **
.It
LaTeX documentation requires further processing as described below.
.\" **
.It
Any changes to the library interface should be made against the
.Pa *.mldoc
files,
.Nm extract-sig
is able to extract an updated SML version.
.El
.Pp
LaTeX documents require a
.Em root file
to specify the document class and indexes.
For example, if the first file is called
.Pa intro.mldoc
then
.Pa manual.tex
might resemble:
.Bd -literal -offset indent
\\documentclass{mldoc-book}
\\mldMakeTopicIndex\\mldMakeIdIndex\\mldMakeRaisesIndex
\\newcommand{\\kw}[1]{\\textbf{#1}}
\\begin{document}
\\input{intro}
\\mldPrintTopicIndex\\mldPrintIdIndex\\mldPrintRaisesIndex
\\end{document}
.Ed
The
.Li kw
command formats identifiers.
The mldoc class and style files must be in a path searched by LaTeX.
Updating the
.Ev TEXINPUTS
environment variable is one way of ensuring this. E.g. under bash:
.Dl export TEXINPUTS=".:%%PREFIX%%/share/ml-doc/lib/LaTeX:" .
The
.Sx EXAMPLES
section shows how to run the LaTeX tools.
.\"
.\" ----------------------------------------
.Sh WRITING DOCUMENTATION
.Pp
This section essentially elaborates on the
.Pa ml-doc.dtd
file.
An
ML-Doc
file begins with the declaration:
.Dl <!DOCTYPE ML-DOC SYSTEM>
and contains header elements followed by one or more, potentially nested,
sections.
.Pp
There are four types of header element. Only
.Li TITLE
is mandatory.
They may be given in any order.
.Bl -tag -offset indent -width ".Li COPYRIGHT"
.\" **
.It Li VERSION
The version of the documentation, with attributes:
.Bl -tag -offset indent -width ".Li MONTH" -compact
.It Li VERID
e.g.
.Ql 1.4 .
.It Li YEAR
Year of release.
.It Li MONTH
.Pq optional
Month of release.
.It Li DAY
.Pq optional
Day of release.
.El
E.g.
.Li <VERSION VERID="1.4" YEAR=2007 MONTH=8 DAY=12>
.\" **
.It Li COPYRIGHT
Identify a copyright holder with attributes:
.Bl -tag -offset indent -width ".Li OWNER" -compact
.It Li OWNER
The copyright owner.
.It Li YEAR
Year of assertion.
.El
E.g.
.Li <COPYRIGHT OWNER="Mega Corp" YEAR=2003>
.br
Multiple
.Li COPYRIGHT
elements may be present.
.\" **
.It Li AUTHOR
Identifies the document author, with attributes:
.Bl -tag -offset indent -width ".Li MONTH" -compact
.It Li NAME
Name of author.
.It Li EMAIL
Email address of author.
.It Li YEAR
Year written.
.It Li MONTH
.Pq optional
Month written.
.It Li DAY
.Pq optional
Day written.
.El
E.g.
.Li <AUTHOR NAME="J. Doe" EMAIL="doej@mega.co" YEAR=2006>
.\" **
.It Li TITLE
The document title. E.g.
.Li <TITLE>Superhash Structure</TITLE>
.El
.Pp
Sections begin with a
.Li HEAD
element, followed by zero or more paragraphs
.Pq Li PP No and Li FLOAT No elements ,
and then zero or more nested sections, included files and/or interfaces.
The
.Li SECTION
tag has three optional attributes:
.Bl -tag -offset indent -width ".Li NONUMBER" -compact
.It Li LABEL
A string used for making cross-references
.Pq from Li SECREF .
.It Li NONUMBER
If present, the section will not be numbered in LaTeX output.
.It Li NOTOC
Excludes the section from the table of contents.
Only valid if
.Li NONUMBER
is present.
.El
.Li HEAD
and
.Li PP
elements have no attributes. For
.Li FLOAT
elements see
.Sx GENERAL MARKUP .
E.g.
.Bd -literal -offset indent -compact
<SECTION>
<HEAD>General Markup</HEAD>
<PP>
Various tags provide...
<SECTION>
<HEAD>Formatting</HEAD>
<PP>
Tags available for inline...
</SECTION>
...
</SECTION>
.Ed
.\"
.Pp
Typically a separate
.Pa *.mldoc
file will be used for each major topic, such as introductory or background
text, and interface (signature, structure or functor).
A corresponding
.Pa *.html
file, for HTML output, and/or
.Pa *.tex
file, for LaTeX output, is generated for each
ML-Doc
source file.
A complete document is constructed by including, with
.Li INCLFILE
tags, individual files within a hierarchy of sections.
Inclusions become hyperlinks in HTML output and inserted pages in LaTeX
output. An
.Li INCLFILE
has a single, mandatory
.Li FILE
attribute specifying a relative or absolute file path. The
.Li .mldoc
extension is implied. E.g.
.Dl <INCLFILE FILE="lib/hash-sig">
.\"
.Pp
SGML comments, e.g.
.Li <!-- check source code. --> ,
are ignored.
.\"
.Pp
SML objects are described between
.Li INTERFACE
tags which have optional
.Li LABEL
attributes for making cross-references. An
.Li INTERFACE
element contains, in order:
a
.Li HEAD
element
.Pq as per Li SECTION ,
an optional
.Li SEEALSO
element containing one or more references
.Pq see Sx References ,
optional paragraphs of introductory text,
an
.Em object description ,
and optional paragraphs of concluding text.
.\"
.Ss Object Descriptions
Object description elements may have a
.Li STATUS
attribute, with value
.Li REQUIRED ,
.Li OPTIONAL ,
or
.Li PROPOSED .
There are three types of element for describing objects provided by a
library:
.Bl -tag -offset indent -compact -width ".Li SIGNATURE"
.\" **
.It Li SIGNATURE
With mandatory
.Li SIGID
attribute.
.\" **
.It Li STRUCTURE
With mandatory
.Li STRID
attribute.
.\" **
.It Li FUNCTOR
With mandatory
.Li FCTID
attribute.
.El
.Pp
Example outline of an interface:
.Bd -literal -offset indent -compact
<INTERFACE>
<HEAD>The <CD/Hash/ structure</HEAD>
<SEEALSO>
<STRREF DOCUMENT=SML-BASIS-DOC TOPID/Option/
<STRREF DOCUMENT=SML-BASIS-DOC TOPID/Time/
</SEEALSO>
<PP>
Optional text after synopsis.
<STRUCTURE STRID="CML">
...
</STRUCTURE>
<PP>
Optional final discussion.
</INTERFACE>
.Ed
It is usually easier to generate object descriptions directly from SML
source files using
.Xr mkdoc 1 .
.Pp
The
.Li SIGBODY
element is central to describing objects.
It must be included in
.Li SIGNATURE Ns No s,
may be included in
.Li STRUCTURE Ns No s
and
.Li FUNCTOR Ns No s,
and has two optional attributes:
.Bl -tag -offset indent -width ".Li SIGID" -compact
.\" SIGBODY: SIGID Attribute
.It Li SIGID
Identifies the signature being described. It is used for cross-referencing.
When a
.Li SIGBODY
is given within a
.Li SIGNATURE ,
both may have identical
.Li SIGID
values. Within a
.Li STRUCTURE
the
.Li SIGID
attribute is usually the
.Sq signature version
of the outer
.Li STRID .
It is a succinct way of describing both interface and implementation, e.g.
.Bd -literal -offset indent -compact
<STRUCTURE STRID="ControlSet">
<SIGBODY SIGID="CONTROL_SET" FILE=CONTROL-SET>
...
</SIGBODY>
</STRUCTURE>
.Ed
.\" SIGBODY: FILE Attribute
.It Li FILE
The
.Xr mkdoc 1
utility uses the value of this attribute to name extracted SML files.
.Li SIGID
and
.Li FILE
are typically omitted on
.Li SIGBODY Ns No s
used as functor arguments.
.El
A
.Li SIGBODY
contains one or more
.Li SPEC
and/or
.Li SPECBREAK
elements.
The former is described under
.Sx Specifications .
The latter is used to form sub-groups of related specifications, when
marked with a
.Li NEWLINE
attribute, blank lines are placed in both extracted signatures and
generated output.
.Pp
.\" Object description: SIGNATURE
A
.Li SIGNATURE
contains a
.Li SIGBODY
which may be followed by a series of
.Li SIGINSTANCE
elements that list structures implementing the signature, each containing an
.Li ID ,
zero or more
.Li WHERETYPE
elements, and optionally a
.Li COMMENT .
A
.Li WHERETYPE
element states which signature types are instantiated in an implementation,
it consists of an optional
.Li TYPARAM
binding, the
.Li ID
of the type, and a
.Li TY
type constraint. The
.Li COMMENT , TYPARAM ,
and
.Li TY
elements are described below. The
.Li SIGINSTANCE
tag has two optional attributes:
.Bl -tag -offset indent -width ".Li OPAQUE" -compact
.It Li STATUS
Having a value of
.Li REQUIRED ,
.Li OPTIONAL ,
or
.Li PROPOSED .
.It Li OPAQUE
Indicates an opaque signature binding.
.El
This example from the SML/NJ Library:
.Bd -literal -offset indent -compact
<SIGNATURE SIGID="ORD_MAP">
<SIGBODY SIGID="ORD_MAP" FILE=ORD-MAP>
...
<SIGINSTANCE OPAQUE><ID>IntBinaryMap
<WHERETYPE><ID>Key.ord_key<TY>Int.int
<COMMENT>
...
<SIGINSTANCE OPAQUE><ID>IntListMap
<WHERETYPE><ID>Key.ord_key<TY>Int.int
<COMMENT>
...
</SIGNATURE>
.Ed
would yield a synopsis:
.Bd -unfilled -offset indent -compact
signature ORD_MAP
structure IntBinaryMap :> ORD_MAP
structure IntListMap :> ORD_MAP
.Ed
.Pp
.\" Object description: STRUCTURE
A
.Li STRUCTURE
contains either a full
.Li SIGBODY ,
as described above,
or simply the name of
.Pq Li ID ,
or reference to
.Pq Li SIGREF
a signature described elsewhere.
A name or reference may be followed by
.Li WHERETYPE
type realisations.
An
.Li OPAQUE
element can be placed before the signature body, name or reference, to
signify an opaque binding, e.g.
.Bd -literal -offset indent -compact
<STRUCTURE STRID="Store">
<OPAQUE>
<SIGREF/ORD_SET/
<WHERETYPE><ID>Key.ord_key<TY>String.string
</STRUCTURE>
.Ed
.Pp
The contents of a
.Li FUNCTOR
are identical to those of a
.Li STRUCTURE ,
except that they must begin with an argument element, which takes one of two
forms:
.Bl -tag -offset indent -compact -width "general"
.It short
An argument name
.Pq Li ID
followed by the name of
.Pq Li ID ,
or reference
.Pq Li SIGREF
to a signature.
.It general
A
.Li SIGBODY
element containing specifications, notably of
.Li SUBSTRUCT
and
.Li TYPE
elements.
.El
E.g.
.Li functor ListSetFn (ORD_KEY) : ORD_SET
could be written:
.Bd -literal -compact -offset indent
<FUNCTOR FCTID="ListSetFn">
<ID/K/<ID>ORD_KEY</ID> <!--argument-->
<ID>ORD_SET <!--result-->
</FUNCTOR>
.Ed
The second
.Li ID
could have been written as a
.Li SIGREF ,
the third could have been given in full using
.Li SIGBODY .
.\"
.Ss Specifications
A
.Li SIGBODY
comprises a list of
.Li SPEC
elements, each containing either a single substructure specification, or
multiple specifications of the same kind
.Pq though types and eqtypes may be mixed ,
and optionally followed by a comment.
The specification element types are:
.Bl -tag -width ".Li TYPE No / Li EQTYPE"
.\" **
.It Li INCLUDE
An
.Li ID
or
.Li SIGREF
naming an included signature, optionally followed by
.Li WHERETYPE
realisations.
E.g.
.Bd -literal -compact
<SPEC><INCLUDE><SIGREF DOCUMENT=SML-BASIS-DOC/OS_IO/
.Ed
.\" **
.It Li SUBSTRUCT
The contents are identical to those of
.Li STRUCTURE
except that the first contained element must be an
.Li ID
naming the substructure, e.g.
.Bd -literal -compact
<SPEC><SUBSTRUCT>Key<SIGREF/ORD_KEY/</SUBSTRUCT>
.Ed
.\" **
.It Li SHARING
An
.Li ID
followed by one or more pairings of
.Li EQU
and
.Li ID
elements. The
.Li SHARING
element may include a
.Li TYPE
attribute. E.g.
.Bd -literal -compact
<SPEC>
<SHARING TYPE><ID>A.vector<EQU><ID>V.vector
<SHARING TYPE><ID>A.elem<EQU><ID>V.elem
...
.Ed
.\" **
.It Li EXN
An
.Li ID
and optional
.Li TY ,
e.g.
.Bd -literal -compact
<EXN><ID>Fail<TY>string
.Ed
or taking advantage of SGML short-hand
.Pq the Li ID No tag is optional :
.Bd -literal -compact
<EXN>Fail<TY>string
.Ed
.\" **
.It Li TYPE No / Li EQTYPE
An optional
.Li TYPARAM ,
an
.Li ID ,
and an optional
.Li TY ,
e.g.
.Bd -literal -compact
<TYPE><TYPARAM>'a<ID>queue
.Ed
.\" **
.It Li DATATYPE
An optional
.Li TYPARAM ,
an
.Li ID ,
and a list of
.Li CONS
elements, each containing an
.Li ID
followed by optional
.Li TY
and
.Li COMMENT
elements, e.g.
.Bd -literal -compact
<SPEC>
<DATATYPE><TYPARAM>'a<ID>option
<CONS>NONE
<CONS>SOME<TY>'a
</DATATYPE>
.Ed
A
.Li DATATYPE
element may be marked with a
.Li COMPACT
attribute that directs the output generators to place all of the
constructors on a single line if possible.
.\" **
.It Li DATATYPEDEF
An
.Li ID
followed by another
.Li ID
or a
.Li TYREF .
Adds a datatype replication, e.g.
.Bd -literal -compact
<DATATYPEDEF><ID>access_mode</ID>
<TYREF STRID="OS.FileSys" DOCUMENT=SML-BASIS-DOC>
OS.FileSys.access_mode</TYREF>
</DATATYPEDEF>
.Ed
.\" **
.It Li VAL
An
.Li ID
followed by a
.Li TY
and optionally a
.Li RAISES
element containing one or more
.Li EXNREF Ns No s, e.g.
.Bd -literal -compact
<SPEC>
<VAL>fact<TY>int -> int
<RAISES><EXNREF/Domain/
<EXNREF/Overflow/
.Ed
.El
.Ss Comments
Comments may be included as the last item within a
.Li SIGINSTANCE , SPEC ,
or
.Li CONS
element. A
.Li COMMENT
contains one or more paragraphs
.Pq Li PP ,
each optionally preceded by a
.Li PROTOTY
element that contains one or more
.Li PROTO
elements showing, in SML, how an object might be called or used with
argument names.
To take an example from the SML Basis Library:
.Bd -literal -offset indent -compact
<SPEC>
<VAL>before<TY>('a * unit) -> 'a
<COMMENT>
<PROTOTY>
<PROTO>
<ARG/a/ before <ARG/b/
<PP>
returns <ARG/a/. It provides a notational shorthand for
evaluating <ARG/a/, then <ARG/b/, before returning the
value of <ARG/a/.
.Ed
The specific argument names make it easier to write a description of what
the function does.
.Pp
The final element within a
.Li PROTO
can be
.Li EVALTO ,
which should contain SML showing the result of evaluating the
expression.
.\"
.Ss References
There are several ways to cross-reference:
.Bl -tag -width "External objects"
.\" **
.It SML objects
Signatures, structures, functors, and their contents. Further details
follow this list.
.\" **
.It External objects
An
.Li IDREF
element references an external non-SML identifier.
An optional
.Li KIND
attribute describes what is being referred to, e.g. a C function or a system
call.
If the
.Li NOINDEX
attribute is present the identifier instance is not noted in an index.
E.g.
.Li <IDREF KIND="POSIX" NOINDEX/printf/
.\" **
.It HTML anchors
Cross-linking for HTML output. An
.Li ADEF
with mandatory
.Li TAG
attribute defines an anchor name for a run of text.
.Li AREF
elements, also with
.Li TAG
attributes, link back to the matching name.
Reference is made to anchors in other documents by setting
the
.Li DOCUMENT
attribute to an entity value, see
.Xr Entities .
E.g.
.Bd -literal -compact
<ADEF TAG="FLUSHWARNING">Disaster results if a flush
is attempted after closing the pipe</ADEF>.
...
Heed the <AREF TAG="FLUSHWARNING">earlier</AREF> warning.
.Ed
.\" **
.It URLs
A
.Li URL
tag links to an external resource specified by an
.Li HREF
attribute. This tag is ignored when generating LaTeX output.
.\" **
.It External ML-Doc
Reference is made to other ML-Doc documents with a
.Li DOCREF
element that specifies an entity with the
.Li DOCUMENT
attribute, e.g.
.Bd -literal -compact
...features of the <DOCREF
DOCUMENT=SML-BASIS-DOC/SML Basis Library/...
.Ed
.\" **
.It Sections/floats
Cross-references may be made to
.Li SECTION Ns No s
or
.Li FLOAT Ns No s
that have
.Li LABEL
attributes. The former using
.Li SECREF
and the latter with
.Li FLOATREF .
Both require a
.Li LABEL
attribute of their own.
Neither contain text, which comes instead from the referenced object.
E.g.
.Bd -literal -compact
<SECTION LABEL="Files">
.Li ...
<SECTION LABEL="Storage">
<HEAD>Sockets</HEAD>
<PP>
The <SECREF LABEL="Files"> section describes...
.Ed
.\" **
.It Citations
A
.Li CITE
element refers to a bibliography entry.
It is not supported by the HTML generators.
The value of the
.Li KEY
attribute is passed directly into LaTeX.
.El
.Pp
The remainder of this section discusses references to SML objects.
These references are included in the document index, if not marked with a
.Li NOINDEX
attribute, and become hyperlinks in HTML output, unless marked with a
.Li NOLINK
attribute.
A
.Li DOCUMENT
attribute is used to reference another ML-Doc project.
.Pp
The SML object reference tags are:
.Bl -tag -offset indent -compact -width ".Li FCTARGREF"
.\" **
.It Li SIGREF
Refer to a complete signature, e.g.
.Li <SIGREF/MONO_ARRAY_SORT/
.\" **
.It Li FCTREF
Refer to a functor, e.g.
.Bd -literal -compact
The <FCTREF NOLINK/ArrayQSortFn/ implements...
.Ed
.\" **
.It Li FCTARGREF
Refer to the argument of a functor.
.\" **
.It Li STRREF
Refer to a structure or substructure.
.\" **
.It Li EXNREF
Refer to an exception, e.g.
.Bd -literal -compact
<RAISES>
<EXNREF STRID="General" DOCUMENT=SML-BASIS-DOC/Size/
.Ed
.\" **
.It Li TYREF
Refer to a type, e.g.
.Bd -literal -compact
.Li ...constructor <TYREF SIGID="UREF">uref</TYREF> with...
.Ed
.\" **
.It Li CONREF
Refer to a datatype constructor, e.g.
.Bd -literal -compact
.Li ...then it returns <CONREF STRID="Option"/NONE/
.Ed
.\" **
.It Li VALREF
Refer to a value, e.g
.Li <VALREF>randMin</VALREF> .
.El
.Pp
A context attribute should be given with the latter five tags when they
refer to a specification in another part of the module hierarchy.
There are four, mutually exclusive, possibilities:
.Bl -tag -offset indent -compact -width ".Li FCTID"
.It Li SIGID
For specifications in
.Li SIGNATURE Ns No s.
.It Li STRID
For specifications in
.Li STRUCTURE Ns No s
or
.Li SUBSTRUCT Ns No s.
.It Li FCTID
For specifications in
.Li FUNCTOR Ns No s.
.It Li TOPID
For specifications available at the top-level without qualification. No value is given.
.El
Examples may be seen throughout this document.
The partial path given in the
.Li *ID
attribute and the reference text are merged when there is overlap between
the rightmost components of the former and the leftmost components of the
latter. For example, in cases like:
.Dl <TYREF STRID="OS.FileSys">OS.FileSys.access_mode</TYREF>
An
.Li *ID
attribute is not required when the reference is to another element in the
same
.Li SIGBODY .
.\"
.Ss Formatting
Tags available for inline formatting:
.Bl -column -compact -offset indent "ARG" "function argument"
.It Sy tag Ta Sy effect
.It Li EM Ta emphasis
.It Li IT Ta italics
.It Li BF Ta bold
.It Li TT Ta typewriter
.It Li CD Ta code
.It Li ARG Ta function argument
.It Li KW Ta keyword
.El
Program text may also be displayed, rather than inlined with the tag
.Li CODE .
Both
.Li CD
and
.Li CODE
tags may carry a
.Li LANG
attribute having a value of either
.Qq sml
or
.Qq c .
.\"
.Ss Tables
Tables are as in HTML but initial
.Li COL
tags are mandatory:
.Bd -literal -offset indent -compact
<TABLE>
<COL ALIGN=LEFT PARBOX="5em"><COL ALIGN=CENTER><COL ALIGN=RIGHT>
<TR><TH>Colour<TH>Code<TH>Comment
<TR><TD>Red<TD><CD/#FF0000/<TD>Plain red
<TR><TD>Blue<TD><CD/#0000FF/<TD>Plain blue
</TABLE>
.Ed
Table heading
.Pq Li TH
and cell
.Pq Li TD
elements have optional
.Li ALIGN
and
.Li COLSPAN
attributes. Tables that span multiple pages should be marked
.Li LONG .
.\"
.Ss Floats
Source code and
.Pq non- Ns Li LONG
tables may be floated:
.Bd -literal -offset indent -compact
<FLOAT LABEL="modlist" CAPALIGN=TOP>
<CAPTION>Module List
<TABLE>...</TABLE>
</FLOAT>
.Ed
The
.Li LABEL
attribute is obligatory and may be referenced from a
.Li FLOATREF .
.\"
.Ss Lists
There are three types of lists:
.Bl -bullet -compact
.It
itemized (bulleted items), e.g.
.Bd -literal -compact
<ITEMIZE>
<ITEM>First item
<ITEM>Second item
</ITEMIZE>
.Ed
.It
enumerated (numbered), e.g.
.Bd -literal -compact
<ENUM>
<ITEM>First item
<ITEM>Second item
</ENUM>
.Ed
.It
descriptive, e.g.
.Bd -literal -compact
<DESCRIP>
<DTAG/first/<ITEM>text about first item
<DTAG/second/<ITEM>text about second item
</DESCRIP>
.Ed
.El
.\"
.Ss Miscellaneous Text Blocks
Paragraphs may be grouped based on intent:
.Bl -tag -width ".Li RATIONALEMM"
.It EXAMPLE
For extended examples.
.It QUESTION
Presents a note on, or discussion of, open design issues.
.It IMPLNOTE
Implementation notes, e.g. expected efficiency.
.It RATIONALE
Explain the reasons behind design decisions.
.It SYSNOTE
Comments specific to an architecture
.Pq named with the Li ARCH No attribute
or operating system
.Pq the Li OPSYS No attribute .
.El
As an example:
.Bd -literal -offset indent -compact
<PP>
...
<RATIONALE>
<PP>
These functions...
<PP>
An alternative...
</RATIONALE>
.Ed
.\"
.Ss Regular Expressions
Regular expressions may be included within text
.Pq Li RE
or displayed on their own line
.Pq Li REGEXP .
Literal characters are tagged as
.Li GRAM.LIT
and displayed in typewriter font (other possible atoms are
.Li GRAM.NONTERM
in italics,
.Li GRAM.TERM
in roman, and
.Li GRAM.KW
in bold).
E.g.
.Dl <RE><GRAM.LIT/i/<GRAM.LIT/f/</RE>
gives:
.Li if
.Pp
Characters sets, displayed between square brackets, are built with
.Li GRAM.CSET .
Sets may include character atoms and ranges, e.g.
.Bd -literal -compact -offset indent
<REGEX><GRAM.CSET><GRAM.RANGE><GRAM.LIT/A/<GRAM.LIT/F/<GRAM.RANGE>
<GRAM.RANGE><GRAM.LIT/a/<GRAM.LIT/f/<GRAM.RANGE>
</GRAM.CSET></REGEX>
.Ed
gives:
.Li [A-Fa-f]
.Pp
Closures are expressed by grouping characters and specifying a count, e.g.
.Dl <RE><GRAM.GRP ONE-OR-MORE><GRAM.LIT/a/<GRAM.LIT/b/</GRAM.GRP></RE>
gives:
.Li (ab)+
.Pp
Possible counts are:
.Li ONE
(the default),
.Li ZERO-OR-ONE ,
.Li ZERO-OR-MORE ,
.Li ONE-OR-MORE .
.Pp
Alternation, regular expressions separated by bars, is also possible, e.g.
.Bd -literal -offset indent -compact
<RE><GRAM.ALT>
<GRAM.LIT/A/
<GRAM.GRP ZERO-OR-MORE><GRAM.LIT/B/</GRAM.GRP>
</GRAM.ALT></RE>
.Ed
gives:
.Li A | B*
.\"
.Ss Mathematics
Some support is provided for type-setting mathematics. Formulas may be
placed in running text
.Pq Li MATH ,
displayed (on a separate line,
.Li DISPLAYMATH Ns
) or made into a table of equations, e.g.
.Bd -literal -offset indent -compact
<EQNARRAY>
<EQN>x + y<EQNREL/=/2</EQN>
<EQN>y<EQNREL/>=/0</EQN>
</EQNARRAY>
.Ed
gives:
.Bl -column -compact -offset indent "x + y" ">=" "2"
.It x + y Ta = Ta 2
.It y Ta >= Ta 0
.El
.Pp
Other features:
.Bl -column -compact -offset indent "absolute value" ".Li <MATH><CEILING>x + y</CEILING></MATH>"
.It subscripts Ta Li <MATH>x<SUB/i+1/</MATH>
.It superscripts Ta Li <MATH>x<SUP/2*3/</MATH>
.It modulo Ta Li <MATH>x<MOD/y+z/</MATH>
.It Ta Em displayed as: Li x (mod (y+z))
.It fractions Ta Li <MATH><FRAC>1<OVER>2</FRAC></MATH>
.It absolute value Ta Li <MATH><NORM>x + y</NORM></MATH>
.It ceiling Ta Li <MATH><CEILING>x + y</CEILING></MATH>
.It floor Ta Li <MATH><FLOOR>x + y</FLOOR></MATH>
.It sets Ta Li <MATH><SET>x | x > 2</SET></MATH>
.El
.Pp
Argument variables, e.g.
.Li <ARG/lset/ ,
may be included in formulas, as may
normal (roman) text, e.g.
.Dl <MTEXT/if not empty/
.Pp
The predefined mathematical entities are:
.Bl -column -offset indent -compact \
".Li &MINUSPLUS;" ".Li &GREATEREQ;" ".Li &EXISTS;" ".Li &PLUSMINUS;"
.It Li &CUP; Ta Li &CAP; Ta Li &EXISTS; Ta Li FORALL
.It Li &GREATER; Ta Li &GREATEREQ; Ta Li &IN; Ta Li &LESS;
.It Li &LESSEQ; Ta Li &NOTEQ; Ta Li &NOTIN; Ta Li &OMINUS;
.It Li &OPLUS; Ta Li &OTIMES; Ta Li &PI; Ta Li &PLUSMINUS;
.It Li &MINUSPLUS; Ta Li &INF;
.El
.\"
.Ss Indexing
A hardcopy document contains up to three separate indexes:
.Bl -tag -width "raises" -compact -offset indent
.It topic
General index (by topic)
.It id
SML identifier index
.It raises
Raised exception index
.El
In HTML, separate indexes for signatures, structs, and types are possible.
.Pp
Entries are extracted automatically from interface descriptions. They may
also be inserted into text manually with the
.Li INDEX
tag, e.g.
.Dl This module handles <INDEX KEY="Error Reporting">error reporting.
creating an entry in the General Index, by default, with
appropriate page number:
.Bd -literal -compact -offset indent
Error Reporting, 14
.Ed
.Pp
The index\(emone of
.Qq topic , id
or
.Qq raises Ns
\(emis specified with the
.Li WHICH
attribute. The
.Li SEE
attribute replaces the page number with the given text.
.Pp
The key-view tag specifies alternate text or formatting for an index entry.
Extra sub-index tags can be added, with optional key-views, to provide one
or two extra levels of specificity, e.g.
.Bd -literal -offset indent -compact
This module handles <INDEX KEY="Error Reporting">
<KEY-VIEW><IT/Error Reporting/</KEY-VIEW>
<SUBINDEX KEY="Module">
</INDEX>error reporting.
.Ed
Gives:
.Bd -literal -compact -offset indent
.Em Error Reporting
Module, 14
.Ed
.Pp
Topics that span bodies of text are delimited with
.Li START
and
.Li STOP
attributes, e.g.
.Bd -literal -offset indent -compact
<INDEX KEY="Displays" START> This chapter discusses display
characteristics of...
...which concludes our discussion.<INDEX KEY="Displays" STOP>
.Ed
Could produce:
.Bd -literal -offset indent -compact
Displays, 19\(em25
.Ed
.\" ----------------------------------------
.Sh SGML vs HTML/XML
Although the basics of editing
ML-Doc
will be familiar to most authors of HTML and XML, SGML has some peculiarities
that are designed to make editing
.Sq by hand
easier.
.Pp
Many end-tags are optional, as in HTML, but unlike in XML, e.g.
.Bd -literal -offset indent -compact
<PP>
No explicit end-tag is given for this paragraph...
<PP>
...before moving into the next
.Ed
.Pp
The usual start and end-tags are acceptable:
.Dl <CD>'a</CD>
But
.Em null end-tags
can also be used for the same effect:
.Dl <CD/'a/
.Pp
Attribute names are often optional when an enumerated value is required,
i.e. instead of
.Li <GRAM.GRP COUNT=ONE>
one can also write
.Li <GRAM.GRP ONE> .
some attribute values can be stated without a name, i.e. instead of:
.Dl <SPECBREAK NEWLINE=NEWLINE>
one can write:
.Dl <SPECBREAK NEWLINE>
.Pp
Attribute values need not always be enclosed in double quotes.
.Pp
These details are well described in Chapter 9 of
.Em SGML and HTML Explained
.Pq refer Sx SEE ALSO .
.\"
.\" ----------------------------------------
.Sh FILES
System-wide
ML-Doc
files and directories are stored at:
.Dl %%PREFIX%%/share/ml-doc
Notably:
.Bl -tag -compact -offset indent
.It Pa lib/catalog
Master catalog file.
.It Pa lib/ml-doc.dtd
DTD of
ML-Doc
language.
.It Pa lib/entities.sgml
Entity definitions
.Pq see Xr Entities .
.It Pa lib/LaTeX/
LaTeX class and style files for Hardcopy and Proof output.
.El
.\"
.\" ----------------------------------------
.Sh EXAMPLES
After creating the directory structure
.Pq see Sx Directory Structure ,
and writing up the ML-Doc files
.Pq see Sx WRITING DOCUMENTATION ,
first edit the
.Pa CATALOG
file:
.Bd -literal -offset indent -compact
ENTITY %document-entities "Entities.sgml"
CATALOG "%%PREFIX%%/share/ml-doc/lib/catalog"
.Ed
Then, create a
.Pa Makefile :
.Dl find ML-Doc -name '*.mldoc' -print | mk-mldoc-makefile
.Pp
Then produce HTML documentation:
.Dl make
and/or LaTeX:
.Dl make Hardcopy
.Pp
Creating/updating a signature file:
.Dl extract-sig ML-Doc/sync-var.mldoc
.Pp
Processing LaTeX output:
.Bd -literal -offset indent -compact
latex manual
makeindex -o manual.ind manual.idx # topic index
makeindex -o manual.nnd manual.ndx # identifier index
makeindex -o manual.rnd manual.rdx # exception index
latex manual
.Ed
.\" ----------------------------------------
.Sh BUGS
The utilities do not provide helpful error messages, usually
just uncaught exceptions.
.Pp
The toolset does not seem, in totality, to handle sub-directories under
.Pa ML-Doc
very well. Soft links provide a rudimentary work around.
.Pp
The
.Li FIGURE
tag is not implemented.
.Pp
The
.Li GRAMMAR
and
.Li GRAM.SEP
tags are not supported.
.Pp
Neither
.Li SUM , PROD , UNION ,
nor
.Li INTERSECT
are implemented.
.Pp
.Li SUB
and
.Li SUP
do not work well together, i.e. squaring the ith x will not be typeset
properly:
.Dl <MATH>x<SUB/i/<SUP/2/</MATH>
.Pp
It is not clear what
.Li MGROUP
does. The contents are wrapped in brackets () in
HTML output and invisible parentheses {} in LaTeX output.
.Pp
The target added by the
.Fl root
option of
.Nm mk-mldoc-makefile
does not run
.Xr makeindex 1 .
.Pp
It is not clear how to write mutually recursive
.Li DATATYPE
or
.Li VAL
specifications, nor is it clear what the
.Li REC
attribute signifies .
.Pp
The
.Li DOCREF
tag is not supported. There is no way of referencing
.Li INTERFACE
elements
.Pq i.e. the Li LABEL No attribute is redundant .
.\" ----------------------------------------
.Sh SEE ALSO
.Xr mkdoc 1 ,
.Pa %%PREFIX%%/share/ml-doc/lib/ml-doc.dtd .
.Rs
.%A "John H. Reppy"
.%B "Concurrent Programming in ML"
.%D 1999
.%I Cambridge University Press
.Re
.Rs
.%A "Emden R. Gansner"
.%A "John H. Reppy"
.%B "The Standard ML Basis Library"
.%D 2004
.%I Cambridge University Press
.Re
.Rs
.%A "Martin Bryan"
.%B "SGML and HTML Explained"
.%D 1997
.%I "Addison Wesley Longman"
.%O available online: http://www.is-thought.co.uk/book/home.htm
.Re
.\" ----------------------------------------
.Sh AUTHORS
.An John H. Reppy Aq jhr@cs.uchicago.edu
wrote and maintains ML-Doc.
.An Andrew Appel Aq appel@princeton.edu
wrote the first version of
.Nm latex-gen .
.An Lal George Aq lg@network-speed.com
wrote the
.Nm proof-latex
tool.
.Pp
.An Timothy Bourke Aq timbob@bigpond.com
wrote this man page for the FreeBSD port based on documentation and source
files from the distribution.
|