How to use Caml2html

More information about Caml2html here.

Usage


Caml2html colorizes a set of OCaml source files (.ml, .mli, .mll, .mly, ...).
Type annotations will be shown when the mouse pointer passes over
an expression if the corresponding .annot file is available.
To obtain a .annot file, compile with ocamlc -dtypes or ocamlopt -dtypes.

Usage: caml2html [options] file1 ... fileN
Options:
  -annotfilter {innermost|outermost} : choose whether innermost or outermost type annotations should be used (default: innermost)
  -charset : specify charset to use (default: iso-8859-1)
  -css : use CSS named style.css for styling
  -cssurl url : use the given URL as CSS for styling
  -inhead : use default styling and place it in the <head> section of the document (default when applicable)
  -inline : use inline styling (default fallback if -inhead is not applicable)
  -ln : add line number at the beginning of each line
  -hc : comments are treated as HTML code (no newlines inside of tags)
  -t : add a title to the html page
  -nf : do not add footnotes to the html page
  -ie7 : drop support for type annotations on Internet Explorer 6 and older
  -noannot : do not insert type annotations as read from .annot files
  -notab : do not replace tabs by spaces
  -tab n : replace tab by n spaces (default = 8)
  -d dir : generate files in directory dir, rather than in current directory
  -o file : output file
  -v : show version number
  -make-css file : create CSS file
  -ext <NAME:CMD> : Use the given external command CMD to handle comments that start with (*NAME. NAME must be a lowercase identifier.
  -help  Display this list of options
  --help  Display this list of options

Examples

Process a single file code.ml:

caml2html code.ml

Same thing with a title for the page:

caml2html -t code.ml

Process a file with a title and line numbers:

caml2html -t -ln code.ml

Process a file with a title, line numbers and replace tabs by 4 spaces:

caml2html -t -ln -tab 4 code.ml

Process a file without footnotes (the most simple output):

caml2html -nf code.ml

Process a file and use a css (style.css):

caml2html -css code.ml

Process a file and use a specific css (http://blabla.com/style2.css):

caml2html -css -cssurl http://blabla.com/style2.css code.ml

Read from stdin and output to stdout:

caml2html

Process many files into a single file:

caml2html -o result.html *.mli *.ml

Process many files, and create one HTML page for each file:

caml2html *.ml

Same thing, but write result in the html directory:

caml2html -d html *.ml

Same thing, but write result in the html directory:

caml2html -d html *.ml

You can specify the character encoding with the -charset option:

caml2html -charset euc-jp input.ml -o output.html

You can write the comments in HTML. This lets you add simple formatting such as hyperlinks. Beware that one HTML tag cannot span over several lines, and that the characters <, > and & must be written as &lt;, &gt; and &amp;.

(* This is file1.ml.
   <a href="#file2.ml">This is a link to file2.ml</a>. *)
...

In this case, use the -hc option:

caml2html -hc file1.ml file2.ml -o result.html

This document was not generated by caml2html!