File: manual029.html

package info (click to toggle)
ocaml-doc 3.09-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 10,428 kB
  • ctags: 4,963
  • sloc: ml: 9,244; makefile: 2,413; ansic: 122; sh: 49; asm: 17
file content (991 lines) | stat: -rw-r--r-- 44,499 bytes parent folder | download
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="manual.css">
<TITLE>
The documentation generator (ocamldoc)
</TITLE>
</HEAD>
<BODY >
<A HREF="manual028.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="manual030.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H1 CLASS="chapter"><A NAME="htoc155">Chapter&nbsp;15</A>&nbsp;&nbsp;The documentation generator (ocamldoc)</H1> <A NAME="c:ocamldoc"></A>

This chapter describes OCamldoc, a tool that generates documentation from
special comments embedded in source files. The comments used by OCamldoc
are of the form <TT>(**</TT>...<TT>*)</TT> and follow the format described
in section <A HREF="#s:ocamldoc-comments">15.2</A>.<BR>
<BR>
OCamldoc can produce documentation in various formats: HTML, L<sup>A</sup>T<sub>E</sub>X,
TeXinfo, Unix man pages, and <TT>dot</TT> dependency graphs. Moreover,
users can add their own custom generators, as explained in
section <A HREF="#s:ocamldoc-custom-generators">15.3</A>.<BR>
<BR>
In this chapter, we use the word <EM>element</EM> to refer to any of the
following parts of an OCaml source file: a type declaration, a value,
a module, an exception, a module type, a type constructor, a record
field, a class, a class type, a class method, a class value or a class
inheritance clause.<BR>
<BR>

<H2 CLASS="section"><A NAME="htoc156">15.1</A>&nbsp;&nbsp;Usage</H2> <A NAME="s:ocamldoc-usage"></A>

<H3 CLASS="subsection"><A NAME="htoc157">15.1.1</A>&nbsp;&nbsp;Invocation</H3>
OCamldoc is invoked via the command <TT>ocamldoc</TT>, as follows:
<PRE>
        ocamldoc <I>options sourcefiles</I>
</PRE>

<H4 CLASS="subsubsection">Options for choosing the output format</H4>
The following options determine the format for the generated
documentation.
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<TT><B>-html</B></TT><DD CLASS="dd-description">
Generate documentation in HTML default format. The generated HTML pages
are stored in the current directory, or in the directory specified
with the <TT><B>-d</B></TT> option. You can customize the style of the
generated pages by editing the generated <TT>style.css</TT> file, or by providing
your own style sheet using option <TT>-css-style</TT>.
The file <TT>style.css</TT> is not generated if it already exists.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-latex</B></TT><DD CLASS="dd-description">
Generate documentation in L<sup>A</sup>T<sub>E</sub>X default format. The generated
L<sup>A</sup>T<sub>E</sub>X document is saved in file <TT>ocamldoc.out</TT>, or in the file
specified with the <TT><B>-o</B></TT> option. The document uses the style file
<TT>ocamldoc.sty</TT>. This file is generated when using the <TT>-latex</TT> option,
if it does not already exist.
You can change this file to customize the style of your L<sup>A</sup>T<sub>E</sub>X documentation.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-texi</B></TT><DD CLASS="dd-description">
Generate documentation in TeXinfo default format. The generated
L<sup>A</sup>T<sub>E</sub>X document is saved in file <TT>ocamldoc.out</TT>, or in the file
specified with the <TT><B>-o</B></TT> option.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-man</B></TT><DD CLASS="dd-description">
Generate documentation as a set of Unix <TT>man</TT> pages. The generated pages
are stored in the current directory, or in the directory specified
with the <TT><B>-d</B></TT> option.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-dot</B></TT><DD CLASS="dd-description">
Generate a dependency graph for the toplevel modules, in a format suitable
for displaying and processing by <TT>dot</TT>. The <TT>dot</TT> tool is available from
<TT><A HREF="http://www.research.att.com/sw/tools/graphviz/">http://www.research.att.com/sw/tools/graphviz/</A></TT>.
The textual representation of the graph is written to the file
<TT>ocamldoc.out</TT>, or to the file specified with the <TT><B>-o</B></TT> option.
Use <TT>dot ocamldoc.out</TT> to display it.<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-g</TT> <I>file.cm[o,a]</I></B><DD CLASS="dd-description">
Dynamically load the given file, which defines a custom documentation
generator. See section <A HREF="#s:ocamldoc-compilation-and-usage">15.4.1</A>. This
option is supported by the <TT>ocamldoc</TT> command, but not by its
native-code version <TT>ocamldoc.opt</TT>.
If the given file is a simple one and does not exist in
the current directory, then ocamldoc looks for it in the custom
generators default directory, and in the directories specified with
optional <TT>-i</TT> options.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-customdir</B></TT><DD CLASS="dd-description">
Display the custom generators default directory.<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-i</TT> <I>directory</I></B><DD CLASS="dd-description">
Add the given directory to the path where to look for custom generators.</DL>

<H4 CLASS="subsubsection">General options</H4>
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description"><B><TT>-d</TT> <I>dir</I></B><DD CLASS="dd-description">
Generate files in directory <I>dir</I>, rather than in the current directory.<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-dump</TT> <I>file</I></B><DD CLASS="dd-description">
Dump collected information into <I>file</I>. This information can be
read with the <TT>-load</TT> option in a subsequent invocation of <TT>ocamldoc</TT>.<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-hide</TT> <I>modules</I></B><DD CLASS="dd-description">
Hide the given complete module names in the generated documentation
<I>modules</I> is a list of complete module names are separated
 by '<TT>,</TT>', without blanks. For instance: <TT>Pervasives,M2.M3</TT>.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-inv-merge-ml-mli</B></TT><DD CLASS="dd-description">
Inverse implementations and interfaces when merging. All elements
in implementation files are kept, and the <TT><B>-m</B></TT> option
indicates which parts of the comments in interface files are merged
with the comments in implementation files.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-keep-code</B></TT><DD CLASS="dd-description">
Always keep the source code for values, methods and instance variables,
when available.
The source code is always kept when a <TT>.ml</TT>
file is given, but is by default discarded when a <TT>.mli</TT> is given.
This option allows to always keep the source code.<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-load</TT> <I>file</I></B><DD CLASS="dd-description">
Load information from <I>file</I>, which has been produced by
<TT>ocamldoc -dump</TT>. Several <TT>-load</TT> options can be given.<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-m</TT> <I>flags</I></B><DD CLASS="dd-description">
Specify merge options between interfaces and implementations.
(see section <A HREF="#s:ocamldoc-merge">15.1.2</A> for details).
<I>flags</I> can be one or several of the following characters:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
 <TT><B>d</B></TT><DD CLASS="dd-description"> merge description
 <DT CLASS="dt-description"><TT><B>a</B></TT><DD CLASS="dd-description"> merge @author
 <DT CLASS="dt-description"><TT><B>v</B></TT><DD CLASS="dd-description"> merge @version
 <DT CLASS="dt-description"><TT><B>l</B></TT><DD CLASS="dd-description"> merge @see
 <DT CLASS="dt-description"><TT><B>s</B></TT><DD CLASS="dd-description"> merge @since
 <DT CLASS="dt-description"><TT><B>o</B></TT><DD CLASS="dd-description"> merge @deprecated
 <DT CLASS="dt-description"><TT><B>p</B></TT><DD CLASS="dd-description"> merge @param
 <DT CLASS="dt-description"><TT><B>e</B></TT><DD CLASS="dd-description"> merge @raise
 <DT CLASS="dt-description"><TT><B>r</B></TT><DD CLASS="dd-description"> merge @return
 <DT CLASS="dt-description"><TT><B>A</B></TT><DD CLASS="dd-description"> merge everything
</DL><BR>
<BR>
<DT CLASS="dt-description"><TT><B>-no-custom-tags</B></TT><DD CLASS="dd-description">
Do not allow custom @-tags (see section <A HREF="#s:ocamldoc-tags">15.2.5</A>).<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-no-stop</B></TT><DD CLASS="dd-description">
Keep elements placed after the <TT>(**/**)</TT> special comment
(see section <A HREF="#s:ocamldoc-comments">15.2</A>).<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-o</TT> <I>file</I></B><DD CLASS="dd-description">
Output the generated documentation to <I>file</I> instead of <TT>ocamldoc.out</TT>.
This option is meaningful only in conjunction with the
<TT><B>-latex</B></TT>, <TT><B>-texi</B></TT>, or <TT><B>-dot</B></TT> options.<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-pp</TT> <I>command</I></B><DD CLASS="dd-description">
Pipe sources through preprocessor <I>command</I>.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-sort</B></TT><DD CLASS="dd-description">
Sort the list of top-level modules before generating the documentation.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-stars</B></TT><DD CLASS="dd-description">
Remove blank characters until the first asterisk ('<TT>*</TT>') in each
line of comments.<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-t</TT> <I>title</I></B><DD CLASS="dd-description">
Use <I>title</I> as the title for the generated documentation.<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-intro</TT> <I>file</I></B><DD CLASS="dd-description">
Use content of <I>file</I> as ocamldoc text to use as introduction (HTML, L<sup>A</sup>T<sub>E</sub>Xand TeXinfo only).
For HTML, the file is used to create the whole <TT>index.html</TT> file.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-v</B></TT><DD CLASS="dd-description">
Verbose mode. Display progress information.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-warn-error</B></TT><DD CLASS="dd-description">
Treat warnings as errors.</DL>

<H4 CLASS="subsubsection">Type-checking options</H4>
OCamldoc calls the Objective Caml type-checker to obtain type
informations. The following options impact the type-checking phase.
They have the same meaning as for the <TT>ocamlc</TT> and <TT>ocamlopt</TT> commands.
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description"><B><TT>-I</TT> <I>directory</I></B><DD CLASS="dd-description">
Add <I>directory</I> to the list of directories search for compiled
interface files (<TT>.cmi</TT> files).<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-nolabels</B></TT><DD CLASS="dd-description">
Ignore non-optional labels in types.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-rectypes</B></TT><DD CLASS="dd-description">
Allow arbitrary recursive types. (See the <TT>-rectypes</TT> option to <TT>ocamlc</TT>.)</DL>

<H4 CLASS="subsubsection">Options for generating HTML pages</H4>
The following options apply in conjunction with the <TT>-html</TT> option:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<TT><B>-all-params</B></TT><DD CLASS="dd-description">
Display the complete list of parameters for functions and methods.<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-css-style</TT> <I>filename</I></B><DD CLASS="dd-description">
Use <I>filename</I> as the Cascading Style Sheet file.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-colorize-code</B></TT><DD CLASS="dd-description">
Colorize the OCaml code enclosed in <TT>[ ]</TT> and <TT>\{[ ]\}</TT>, using colors
to emphasize keywords, etc. If the code fragments are not
syntactically correct, no color is added.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-index-only</B></TT><DD CLASS="dd-description">
Generate only index files.</DL>

<H4 CLASS="subsubsection">Options for generating L<sup>A</sup>T<sub>E</sub>X files</H4>
The following options apply in conjunction with the <TT>-latex</TT> option:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B><TT>-latex-value-prefix</TT> <I>prefix</I></B><DD CLASS="dd-description">
Give a prefix to use for the labels of the values in the generated L<sup>A</sup>T<sub>E</sub>X document.
The default prefix is the empty string. You can also use the options
<TT>-latex-type-prefix</TT>, <TT>-latex-exception-prefix</TT>, <TT>-latex-module-prefix</TT>,
<TT>-latex-module-type-prefix</TT>, <TT>-latex-class-prefix</TT>, <TT>-latex-class-type-prefix</TT>,
<TT>-latex-attribute-prefix</TT> and <TT>-latex-method-prefix</TT>.<BR>
<BR>
These options are useful when you have, for example, a type and a value with
 the same name. If you do not specify prefixes, L<sup>A</sup>T<sub>E</sub>X will complain about
multiply defined labels.<BR>
<BR>
<DT CLASS="dt-description"><B><TT>-latextitle</TT> <I>n,style</I></B><DD CLASS="dd-description">
Associate style number <I>n</I> to the given L<sup>A</sup>T<sub>E</sub>X sectioning command
<I>style</I>, e.g. <TT>section</TT> or <TT>subsection</TT>. (L<sup>A</sup>T<sub>E</sub>X only.) This is
useful when including the generated document in another L<sup>A</sup>T<sub>E</sub>X document,
at a given sectioning level. The default association is 1 for <TT>section</TT>,
2 for <TT>subsection</TT>, 3 for <TT>subsubsection</TT>, 4 for <TT>paragraph</TT> and 5 for
<TT>subparagraph</TT>.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-noheader</B></TT><DD CLASS="dd-description">
Suppress header in generated documentation.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-notoc</B></TT><DD CLASS="dd-description">
Do not generate a table of contents.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-notrailer</B></TT><DD CLASS="dd-description">
Suppress trailer in generated documentation.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-sepfiles</B></TT><DD CLASS="dd-description">
Generate one <TT>.tex</TT> file per toplevel module, instead of the global
<TT>ocamldoc.out</TT> file.
</DL>

<H4 CLASS="subsubsection">Options for generating TeXinfo files</H4>
The following options apply in conjunction with the <TT>-texi</TT> option:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<TT><B>-esc8</B></TT><DD CLASS="dd-description">
Escape accented characters in Info files.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-info-entry</B></TT><DD CLASS="dd-description">
Specify Info directory entry.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-info-section</B></TT><DD CLASS="dd-description">
Specify section of Info directory.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-noheader</B></TT><DD CLASS="dd-description">
Suppress header in generated documentation.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-noindex</B></TT><DD CLASS="dd-description">
Do not build index for Info files.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-notrailer</B></TT><DD CLASS="dd-description">
Suppress trailer in generated documentation.
</DL>

<H4 CLASS="subsubsection">Options for generating <TT>dot</TT> graphs</H4>
The following options apply in conjunction with the <TT>-dot</TT> option:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B><TT>-dot-colors</TT> <I>colors</I></B><DD CLASS="dd-description">
Specify the colors to use in the generated <TT>dot</TT> code.
When generating module dependencies, <TT>ocamldoc</TT> uses different colors
for modules, depending on the directories in which they reside.
When generating types dependencies, <TT>ocamldoc</TT> uses different colors
for types, depending on the modules in which they are defined.
<I>colors</I> is a list of color names separated by '<TT>,</TT>', as
in <TT>Red,Blue,Green</TT>. The available colors are the ones supported by
the <TT>dot</TT> tool.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-dot-include-all</B></TT><DD CLASS="dd-description">
Include all modules in the <TT>dot</TT> output, not only modules given
on the command line or loaded with the <TT><B>-load</B></TT> option.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-dot-reduce</B></TT><DD CLASS="dd-description">
Perform a transitive reduction of the dependency graph before
outputting the <TT>dot</TT> code. This can be useful if there are
a lot of transitive dependencies that clutter the graph.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-dot-types</B></TT><DD CLASS="dd-description">
Output <TT>dot</TT> code describing the type dependency graph instead of
the module dependency graph.
</DL>

<H4 CLASS="subsubsection">Options for generating man files</H4>
The following options apply in conjunction with the <TT>-man</TT> option:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<TT><B>-man-mini</B></TT><DD CLASS="dd-description">
Generate man pages only for modules, module types, clases and class
types, instead of pages for all elements.<BR>
<BR>
<DT CLASS="dt-description"><TT><B>-man-suffix</B></TT><DD CLASS="dd-description">
Set the suffix used for generated man filenames. Default is '<TT>o</TT>',
like in <TT>List.o</TT>.</DL>

<H3 CLASS="subsection"><A NAME="htoc158">15.1.2</A>&nbsp;&nbsp;Merging of module information</H3>
<A NAME="s:ocamldoc-merge"></A>
Information on a module can be extracted either from the <TT>.mli</TT> or <TT>.ml</TT>
file, or both, depending on the files given on the command line.
When both <TT>.mli</TT> and <TT>.ml</TT> files are given for the same module,
information extracted from these files is merged according to the
following rules:
<UL CLASS="itemize"><LI CLASS="li-itemize">
Only elements (values, types, classes, ...) declared in the <TT>.mli</TT>
file are kept. In other terms, definitions from the <TT>.ml</TT> file that are
not exported in the <TT>.mli</TT> file are not documented.
<LI CLASS="li-itemize">Descriptions of elements and descriptions in @-tags are handled
as follows. If a description for the same element or in the same
@-tag of the same element is present in both files, then the
description of the <TT>.ml</TT> file is concatenated to the one in the <TT>.mli</TT> file,
if the corresponding <TT>-m</TT> flag is given on the command line.
If a description is present in the <TT>.ml</TT> file and not in the
<TT>.mli</TT> file, the <TT>.ml</TT> description is kept.
In either case, all the information given in the <TT>.mli</TT> file is kept.
</UL>

<H3 CLASS="subsection"><A NAME="htoc159">15.1.3</A>&nbsp;&nbsp;Coding rules</H3>
<A NAME="s:ocamldoc-rules"></A>
The following rules must be respected in order to avoid name clashes
resulting in cross-reference errors:
<UL CLASS="itemize"><LI CLASS="li-itemize">
In a module, there must not be two modules, two module types or
 a module and a module type with the same name.
<div style="background-color:yellow; color:red; border-style:none; border-width:0.5pt">
 In the default HTML generator, modules <TT>ab</TT> and <TT>AB</TT> will be printed
 to the same file on case insensitive file systems.
</div>
<LI CLASS="li-itemize">In a module, there must not be two classes, two class types or
 a class and a class type with the same name.
<LI CLASS="li-itemize">In a module, there must not be two values, two types, or two
 exceptions with the same name.
<LI CLASS="li-itemize">Values defined in tuple, as in <TT>let (x,y,z) = (1,2,3)</TT>
are not kept by OCamldoc.
<LI CLASS="li-itemize">Avoid the following construction:
<PRE CLASS="verbatim">
open Foo (* which has a module Bar with a value x *)
module Foo =
  struct
    module Bar =
      struct
        let x = 1
      end
  end
  let dummy = Bar.x
</PRE>In this case, OCamldoc will associate <TT>Bar.x</TT> to the <TT>x</TT> of module
<TT>Foo</TT> defined just above, instead of to the <TT>Bar.x</TT> defined in the
opened module <TT>Foo</TT>.
</UL>

<H2 CLASS="section"><A NAME="htoc160">15.2</A>&nbsp;&nbsp;Syntax of documentation comments</H2>
<A NAME="s:ocamldoc-comments"></A>
Comments containing documentation material are called <EM>special
comments</EM> and are written between <TT>(**</TT> and <TT>*)</TT>. Special comments
must start exactly with <TT>(**</TT>. Comments beginning with <TT>(</TT> and more
than two <TT>*</TT> are ignored.<BR>
<BR>

<H3 CLASS="subsection"><A NAME="htoc161">15.2.1</A>&nbsp;&nbsp;Placement of documentation comments</H3>
OCamldoc can associate comments to some elements of the language
encountered in the source files. The association is made according to
the locations of comments with respect to the language elements. The
locations of comments in <TT>.mli</TT> and <TT>.ml</TT> files are different.<BR>
<BR>

<H4 CLASS="subsubsection">Comments in <TT>.mli</TT> files</H4>
A special comment is associated to an element if it is placed before or
after the element.<BR>
A special comment before an element is associated to this element if&nbsp;:
<UL CLASS="itemize"><LI CLASS="li-itemize">
There is no blank line or another special comment between the special
comment and the element. However, a regular comment can occur between
the special comment and the element.
<LI CLASS="li-itemize">The special comment is not already associated to the previous element.
<LI CLASS="li-itemize">The special comment is not the first one of a toplevel module.
</UL>
A special comment after an element is associated to this element if
there is no blank line or comment between the special comment and the
element.<BR>
<BR>
There are two exceptions: for type constructors and record fields in
type definitions, the associated comment can only be placed after the
constructor or field definition, without blank lines or other comments
between them.
<div style="background-color:yellow; color:red; border-style:none; border-width:0.5pt">
The special comment for a type constructor
with another type constructor following must be placed before the '|'
character separating the two constructors.<BR>
</div>
<BR>
The following sample interface file <TT>foo.mli</TT> illustrates the
placement rules for comments in <TT>.mli</TT> files.
<PRE CLASS="verbatim">
(** The first special comment of the file is the comment associated
    with the whole module.*)


(** Special comments can be placed between elements and are kept
    by the OCamldoc tool, but are not associated to any element.
    @-tags in these comments are ignored.*)

(*******************************************************************)
(** Comments like the one above, with more than two asterisks,
    are ignored. *)

(** The comment for function f. *)
val f : int -&gt; int -&gt; int
(** The continuation of the comment for function f. *)

(** Comment for exception My_exception, even with a simple comment
    between the special comment and the exception.*)
(* Hello, I'm a simple comment :-) *)
exception My_exception of (int -&gt; int) * int

(** Comment for type weather  *)
type weather =
| Rain of int (** The comment for construtor Rain *)
| Sun (** The comment for constructor Sun *)

(** Comment for type weather2  *)
type weather2 =
| Rain of int (** The comment for construtor Rain *)
| Sun (** The comment for constructor Sun *)
(** I can continue the comment for type weather2 here
  because there is already a comment associated to the last constructor.*)

(** The comment for type my_record *)
type my_record = {
    val foo : int ;    (** Comment for field foo *)
    val bar : string ; (** Comment for field bar *)
  }
  (** Continuation of comment for type my_record *)

(** Comment for foo *)
val foo : string
(** This comment is associated to foo and not to bar. *)
val bar : string
(** This comment is assciated to bar. *)

(** The comment for class my_class *)
class my_class :
  object
    (** A comment to describe inheritance from cl *)
    inherit cl

    (** The comment for attribute tutu *)
    val mutable tutu : string

    (** The comment for attribute toto. *)
    val toto : int

    (** This comment is not attached to titi since
        there is a blank line before titi, but is kept
        as a comment in the class. *)

    val titi : string

    (** Comment for method toto *)
    method toto : string

    (** Comment for method m *)
    method m : float -&gt; int
  end

(** The comment for the class type my_class_type *)
class type my_class_type =
  object
    (** The comment for variable x. *)
    val mutable x : int

    (** The commend for method m. *)
    method m : int -&gt; int
end

(** The comment for module Foo *)
module Foo =
  struct
    (** The comment for x *)
    val x : int

    (** A special comment that is kept but not associated to any element *)
  end

(** The comment for module type my_module_type. *)
module type my_module_type =
  sig
    (** The comment for value x. *)
    val x : int

    (** The comment for module M. *)
    module M =
      struct
        (** The comment for value y. *)
        val y : int

        (* ... *)
      end

  end

</PRE>

<H4 CLASS="subsubsection">Comments in <TT>.ml</TT> files</H4>
A special comment is associated to an element if it is placed before
the element and there is no blank line between the comment and the
element. Meanwhile, there can be a simple comment between the special
comment and the element. There are two exceptions, for type
constructors and record fields in type definitions, whose associated
comment must be placed after the constructor or field definition,
without blank line between them.
<div style="background-color:yellow; color:red; border-style:none; border-width:0.5pt">
The special comment for a type constructor
with another type constructor following must be placed before the '|'
character separating the two constructors.<BR>
</div>
<BR>
The following example of file <TT>toto.ml</TT> shows where to place comments
in a <TT>.ml</TT> file.
<PRE CLASS="verbatim">
(** The first special comment of the file is the comment associated
    to the whole module.*)

(** The comment for function f *)
let f x y = x + y

(** This comment is not attached to any element since there is another
    special comment just before the next element. *)

(** Comment for exception My_exception, even with a simple comment
    between the special comment and the exception.*)
(* A simple comment. *)
exception My_exception of (int -&gt; int) * int

(** Comment for type weather  *)
type weather =
| Rain of int (** The comment for constructor Rain *)
| Sun (** The comment for constructor Sun *)

(** The comment for type my_record *)
type my_record = {
    val foo : int ;    (** Comment for field foo *)
    val bar : string ; (** Comment for field bar *)
  }

(** The comment for class my_class *)
class my_class =
    object
      (** A comment to describe inheritance from cl *)
      inherit cl

      (** The comment for the instance variable tutu *)
      val mutable tutu = "tutu"
      (** The comment for toto *)
      val toto = 1
      val titi = "titi"
      (** Comment for method toto *)
      method toto = tutu ^ "!"
      (** Comment for method m *)
      method m (f : float) = 1
    end

(** The comment for class type my_class_type *)
class type my_class_type =
  object
    (** The comment for the instance variable x. *)
    val mutable x : int
    (** The commend for method m. *)
    method m : int -&gt; int
  end

(** The comment for module Foo *)
module Foo =
  struct
    (** The comment for x *)
    val x : int
    (** A special comment in the class, but not associated to any element. *)
  end

(** The comment for module type my_module_type. *)
module type my_module_type =
  sig
    (* Comment for value x. *)
    val x : int
    (* ... *)
  end
</PRE>

<H3 CLASS="subsection"><A NAME="htoc162">15.2.2</A>&nbsp;&nbsp;The Stop special comment</H3>
The special comment <TT>(**/**)</TT> tells OCamldoc to discard
elements placed after this comment, up to the end of the current
class, class type, module or module type. For instance:
<PRE CLASS="verbatim">
class type foo =
  object
    (** comment for method m *)
    method m : string

    (**/**)

    (** This method won't appear in the documentation *)
    method bar : int
  end

(** This value appears in the documentation, since the Stop special comment
    in the class does not affect the parent module of the class.*)
val foo : string

(**/**)
(** The value bar does not appear in the documentation.*)
val bar : string

(** The type t does not appear either. *)
type t = string
</PRE>
The <TT><B>-no-stop</B></TT> option to <TT>ocamldoc</TT> causes the Stop special
comments to be ignored.<BR>
<BR>

<H3 CLASS="subsection"><A NAME="htoc163">15.2.3</A>&nbsp;&nbsp;Syntax of documentation comments</H3>
The inside of documentation comments <TT>(**</TT>...<TT>*)</TT> consists of
free-form text with optional formatting annotations, followed by
optional <EM>tags</EM> giving more specific information about parameters,
version, authors, ... The tags are distinguished by a leading @
character. Thus, a documentation comment has the following shape:
<PRE CLASS="verbatim">
(** The comment begins with a description, which is text formatted
   according to the rules described in the next section.
   The description continues until the first non-escaped '@' character.
   @author Mr Smith
   @param x description for parameter x
*)
</PRE>Some elements support only a subset of all @-tags. Tags that are not
relevant to the documented element are simply ignored. For instance,
all tags are ignored when documenting type constructors, record
fields, and class inheritance clauses. Similarly, a <TT>@param</TT> tag on a
class instance variable is ignored.<BR>
<BR>
At last, <TT>(**)</TT> is the empty documentation comment.<BR>
<BR>

<H3 CLASS="subsection"><A NAME="htoc164">15.2.4</A>&nbsp;&nbsp;Text formatting</H3>
Here is the BNF grammar for the simple markup language used to format
text descriptions.<BR>
<BR>
<I>text</I> ::= (<I>text_element</I>)<TT>+</TT><BR>
<I>text_element</I> ::= <BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {[0-9]+ <I>text</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>format <I>text</I> as a section header;
 the integer following <TT>{</TT> indicates the sectioning level.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {[0-9]+:<I>label text</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>same, but also associate the name <I>label</I> to the current point.
 This point can be referenced by its fully-qualified label in a
 <TT>{!</TT> command, just like any other element.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {b <I>text</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>set <I>text</I> in bold.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {i <I>text</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>set <I>text</I> in italic.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {e <I>text</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>emphasize <I>text</I>.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {C <I>text</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>center <I>text</I>.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {L <I>text</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>left align <I>text</I>.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {R <I>text</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>right align <I>text</I>.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {ul <I>list</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>build a list.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {ol <I>list</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>build an enumerated list.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {{:<I>string</I>}<I>text</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>put a link to the given address
(given as a string) on the given text.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| [<I>string</I>]</TT></TD>
<TD VALIGN=top ALIGN=left>set the given <I>string</I> in source code style.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {[<I>string</I>]}</TT></TD>
<TD VALIGN=top ALIGN=left>set the given <I>string</I> in preformatted
				source code style.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {v <I>string</I> v}</TT></TD>
<TD VALIGN=top ALIGN=left>set the given <I>string</I> in verbatim style.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {% <I>string</I> %}</TT></TD>
<TD VALIGN=top ALIGN=left>take the given <I>string</I>
as raw L<sup>A</sup>T<sub>E</sub>X code.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {!<I>string</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>insert a reference to the element named
<I>string</I>. <I>string</I> must be a fully qualified element name,
for example <TT>Foo.Bar.t</TT>. The kind of the referenced element can be forced
(useful when various elements have the same qualified name) with the following
syntax: <TT>{!<I>kind</I>: Foo.Bar.t}</TT> where <I><TT>kind</TT></I> can be
<TT>module</TT>, <TT>modtype</TT>, <TT>class</TT>, <TT>classtype</TT>, <TT>val</TT>,
<TT>type</TT>, <TT>exception</TT>, <TT>attribute</TT>, <TT>method</TT> or <TT>section</TT>.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {!modules: <I>string string</I> ...}</TT></TD>
<TD VALIGN=top ALIGN=left>insert an index table
for the given module names. Used in HTML only.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {!indexlist}</TT></TD>
<TD VALIGN=top ALIGN=left>insert a table of links to the various indexes
(types, values, modules, ...). Used in HTML only.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {^ <I>text</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>set text in superscript.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| {_ <I>text</I>}</TT></TD>
<TD VALIGN=top ALIGN=left>set text in subscript.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| <I>escaped_string</I></TT></TD>
<TD VALIGN=top ALIGN=left>typeset the given string as is;
special characters ('<TT>{</TT>', '<TT>}</TT>', '<TT>[</TT>', '<TT>]</TT>' and '<TT>@</TT>')
must be	escaped by a '<TT>\</TT>'</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>| <I>blank_line</I> </TT></TD>
<TD VALIGN=top ALIGN=left>force a new line.</TD>
</TR></TABLE> <BR>
<I>list</I> ::= <BR>
&nbsp;&nbsp;<TT>| ({- <I>text</I>})+</TT><BR>
&nbsp;&nbsp;<TT>| ({li <I>text</I>})+</TT><BR>
A shortcut syntax exists for lists and enumerated lists:
<PRE CLASS="verbatim">
(** Here is a {b list}
- item 1
- item 2
- item 3

The list is ended by the blank line.*)
</PRE>is equivalent to:
<PRE CLASS="verbatim">
(** Here is a {b list}
{ul {- item 1}
{- item 2}
{- item 3}}
The list is ended by the blank line.*)
</PRE>
The same shortcut is available for enumerated lists, using '<TT>+</TT>'
instead of '<TT>-</TT>'.
Note that only one list can be defined by this shortcut in nested lists.<BR>
<BR>
In the description of a value, type, exception, module, module type, class
or class type, the <EM>first sentence</EM> is sometimes used in indexes, or
when just a part of the description is needed. The first sentence
is composed of the first characters of the description, until
<UL CLASS="itemize"><LI CLASS="li-itemize">
the first dot followed by a blank, or
<LI CLASS="li-itemize">the first blank line
</UL>
outside of the following text formatting :
<TT>{ul <EM>list</EM>}</TT>,
<TT>{ol <EM>list</EM>}</TT>,
<TT>[<EM>string</EM>]</TT>,
<TT>{[<EM>string</EM>]}</TT>,
<TT>{v <EM>string</EM> v}</TT>,
<TT>{% <EM>string</EM>%}</TT>,
<TT>{!<EM>string</EM>}</TT>,
<TT>{^ <EM>text</EM>}</TT>,
<TT>{_ <EM>text</EM>}</TT>.<BR>
<BR>

<H3 CLASS="subsection"><A NAME="htoc165">15.2.5</A>&nbsp;&nbsp;Documentation tags (@-tags)</H3>
<A NAME="s:ocamldoc-tags"></A>

<H4 CLASS="subsubsection">Predefined tags</H4>
The folowing table gives the list of predefined @-tags, with their
syntax and meaning.<BR>
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1>
<TR><TD VALIGN=top ALIGN=left><TT>@author </TT><EM>string</EM></TD>
<TD VALIGN=top ALIGN=left>The author of the element. One author by <TT>@author</TT> tag.
There may be several <TT>@author</TT> tags for the same element.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>@deprecated </TT><EM>text</EM></TD>
<TD VALIGN=top ALIGN=left>The <EM>text</EM> should describe when the element was
deprecated, what to use as a replacement, and possibly the reason
for deprecation.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>@param </TT><EM>id text</EM></TD>
<TD VALIGN=top ALIGN=left>Associate the given description (<EM>text</EM>) to the
given parameter name <EM>id</EM>. This tag is used for functions,
methods, classes and functors.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>@raise Exc </TT><EM>text</EM></TD>
<TD VALIGN=top ALIGN=left>Explain that the element may raise
 the exception <TT>Exc</TT>.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>@return </TT><EM>text</EM></TD>
<TD VALIGN=top ALIGN=left>Describe the return value and
 its possible values. This tag is used for functions
 and methods.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>@see &lt;url&gt; </TT><EM>text</EM></TD>
<TD VALIGN=top ALIGN=left>Add a reference to the URL between '<TT>&lt;</TT>' and '<TT>&gt;</TT>'
with the given text as comment.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>@see 'filename' </TT><EM>text</EM></TD>
<TD VALIGN=top ALIGN=left>Add a reference to the given file name
(written between single quotes), with the given text as comment.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>@see "document name" </TT><EM>text</EM></TD>
<TD VALIGN=top ALIGN=left>Add a reference to the given
document name (written between double quotes), with the given text
as comment.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>@since </TT><EM>string</EM></TD>
<TD VALIGN=top ALIGN=left>Indicates when the element was introduced.</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>@version </TT><EM>string</EM></TD>
<TD VALIGN=top ALIGN=left>The version number for the element.</TD>
</TR></TABLE><BR>

<H4 CLASS="subsubsection">Custom tags</H4>
<A NAME="s:ocamldoc-custom-tags"></A>
You can use custom tags in the documentation comments, but they will
have no effect if the generator used does not handle them. To use a
custom tag, for example <TT>foo</TT>, just put <TT>@foo</TT> with some text in your
comment, as in:
<PRE CLASS="verbatim">
(** My comment to show you a custom tag.
@foo this is the text argument to the [foo] custom tag.
*)
</PRE>
To handle custom tags, you need to define a custom generator,
as explained in section <A HREF="#s:ocamldoc-handling-custom-tags">15.3.2</A>.<BR>
<BR>

<H2 CLASS="section"><A NAME="htoc166">15.3</A>&nbsp;&nbsp;Custom generators</H2>
<A NAME="s:ocamldoc-custom-generators"></A>
OCamldoc operates in two steps:
<OL CLASS="enumerate" type=1><LI CLASS="li-enumerate">
analysis of the source files;
<LI CLASS="li-enumerate">generation of documentation, through a documentation generator,
	which is an object of class <TT>Odoc_args.class_generator</TT>.
</OL>
Users can provide their own documentation generator to be used during
step 2 instead of the default generators.
All the information retrieved during the analysis step is available through
the <TT>Odoc_info</TT> module, which gives access to all the types and functions
 representing the elements found in the given modules, with their associated
description.<BR>
<BR>
The files you can used to define custom generators are installed in the
<TT>ocamldoc</TT> sub-directory of the OCaml standard library.<BR>
<BR>

<H3 CLASS="subsection"><A NAME="htoc167">15.3.1</A>&nbsp;&nbsp;The generator class</H3>
A generator class is a class of type <TT>Odoc_args.doc_generator</TT>.
It has only one method<BR>
<TT>generator : Odoc_info.Module.t_module list -&gt; unit</TT><BR>
This method will be called with the list of analysed and possibly
merged <TT>Odoc_info.t_module</TT> structures.
Of course the class can have other methods, but the object of this
 class must be coerced to <TT>Odoc_args.doc_generator</TT> before being
 passed to the function<BR>
<TT>Odoc_args.set_doc_generator : Odoc_args.doc_generator -&gt; unit</TT><BR>
which installs the new documentation generator.<BR>
<BR>
The following example shows how to define and install a new documentation generator.
See the <TT>odoc_fhtml</TT> generator (in the Ocamldoc Hump) for a complete example.
<PRE CLASS="verbatim">
class my_doc_gen =
  object
    (* ... *)

    method generate module_list =
      (* ... *)
      ()

    (* ... *)
  end

let my_generator = new my_doc_gen
let _ = Odoc_args.set_doc_generator (my_generator :&gt; Odoc_args.doc_generator)
</PRE>
Note: The new class can inherit from <TT>Odoc_html.html</TT>, <TT>Odoc_latex.latex</TT>,
<TT>Odoc_man.man</TT>, <TT>Odoc_texi.texi</TT> or <TT>Odoc_dot.dot</TT>, and
redefine only some methods to benefit from the existing methods.<BR>
<BR>

<H3 CLASS="subsection"><A NAME="htoc168">15.3.2</A>&nbsp;&nbsp;Handling custom tags</H3>
<A NAME="s:ocamldoc-handling-custom-tags"></A>
Making a custom generator handle custom tags (see
<A HREF="#s:ocamldoc-custom-tags">15.2.5</A>) is very simple.<BR>
<BR>

<H4 CLASS="subsubsection">For HTML</H4>
Here is how to develop a HTML generator handling your custom tags.<BR>
<BR>
The class <TT>Odoc_html.html</TT> inherits
from the class <TT>Odoc_html.info</TT>, containing a field <TT>tag_functions</TT> which is a
list pairs composed of a custom tag (e.g. 'foo') and a function taking a <TT>text</TT>
and returning HTML code (of type <TT>string</TT>).
To handle a new tag <TT>bar</TT>, create a HTML generator class from the existing one
 and complete the <TT>tag_functions</TT> field:
<PRE CLASS="verbatim">
class my_gen =
  object(self)
    inherit Odoc_html.html

    (** Return HTML code for the given text of a bar tag. *)
    method html_of_bar t = (* your code here *)

    initializer
      tag_functions &lt;- ("bar", self#html_of_bar) :: tag_functions
  end
</PRE>
Another method of the class <TT>Odoc_html.info</TT> will look for the
function associated to a custom tag and apply it to the text given to
the tag. If no function is associated to a custom tag, then the method
prints a warning message on <TT>stderr</TT>.<BR>
<BR>

<H4 CLASS="subsubsection">For other generators</H4>
As for the HTML custom generator, you can define a new L<sup>A</sup>T<sub>E</sub>X(resp. <TT>man</TT>) generator by inheriting from the class
<TT>Odoc_latex.latex</TT> (resp. <TT>Odoc_man.man</TT>) and
adding your own tag handler to the field <TT>tag_functions</TT>.<BR>
<BR>

<H2 CLASS="section"><A NAME="htoc169">15.4</A>&nbsp;&nbsp;Adding command line options</H2>
The command line analysis is performed after loading the module containing the
documentation generator, thus allowing command line options to be added to the
 list of existing ones. Adding an option can be done with the function<BR>
<TT>Odoc_args.add_option : string * Arg.spec * string -&gt; unit</TT><BR>
Note: Existing command line options can be redefined using this function.<BR>
<BR>

<H3 CLASS="subsection"><A NAME="htoc170">15.4.1</A>&nbsp;&nbsp;Compilation and usage</H3>
<A NAME="s:ocamldoc-compilation-and-usage"></A>

<H4 CLASS="subsubsection">Defining a custom generator class in one file</H4>
Let <TT>custom.ml</TT> be the file defining a new generator class.
Compilation of <TT>custom.ml</TT> can be performed by the following command&nbsp;:<BR>
<TT>ocamlc -I +ocamldoc -c custom.ml</TT><BR>
The file <TT>custom.cmo</TT> is created and can be used this way&nbsp;:<BR>
<TT>ocamldoc -g custom.cmo <EM>other-options source-files</EM></TT><BR>
It is important not to give the <TT><B>-html</B></TT> or any other option selecting a
built in generator to <TT>ocamldoc</TT>,
which would result in using this generator instead of the one you just loaded.<BR>
<BR>

<H4 CLASS="subsubsection">Defining a custom generator class in several files</H4>
It is possible to define a generator class in several modules, which
are defined in several files <TT>file1.ml[i]</TT>, <TT>file2.ml[i]</TT>, ...,
<TT>fileN.ml[i]</TT>. A <TT>.cma</TT> library file must
be created, including all these files.<BR>
The following commands create the <TT>custom.cma</TT> file from files <TT>file1.ml[i]</TT>, ...,
<TT>fileN.ml[i]</TT>&nbsp;:<BR>
<TT>ocamlc -I +ocamldoc -c file1.ml[i]<BR>
ocamlc -I +ocamldoc -c file2.ml[i]<BR>
...<BR>
ocamlc -I +ocamldoc -c fileN.ml[i]<BR>
ocamlc -o custom.cma -a file1.cmo file2.cmo ... fileN.cmo</TT><BR>
Then, the following command uses <TT>custom.cma</TT> as custom generator:<BR>
<TT>ocamldoc -g custom.cma <EM>other-options source-files</EM></TT><BR>
Again, it is important not to give the <TT><B>-html</B></TT> or any other option selecting a
built in generator to <TT>ocamldoc</TT>,
which would result in using this generator instead of the one you just loaded.

<BR>
<BR>
<HR>
<A HREF="manual028.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="manual030.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>