Argot – version 1.0-betaCopyright © 2010-2011 Xavier Clerc – argot@x9c.fr |
Argot is an enhanced html generator for the ocamldoc
comment-extraction tool for the Objective Caml language1.
Its name stems from the following acronym: Argot is a
Raised Generator for the Ocamldoc Tool.
Argot, in its 1.0-beta version is designed to work with
version 3.12.1 of Objective Caml. Argot is released under
the GPL version 3. This licensing scheme should not cause any problem,
as documentation generation will not contamine code.
Bugs and requests for enhancement should be reported at http://bugs.x9c.fr.
Argot can be built from sources using make (in its GNU Make 3.81 flavor), and Objective Caml version 3.12.1. No other dependency is needed. Following the classical Unix convention, the build and installation process consists in these three steps:
During the first step, one can specify elements if they are not correctly inferred by the ./configure script; the following switches are available:
During the third and last step, according to local settings, it may be necessary to acquire privileged accesses, running for example sudo make install.
Once installed, using Argot is as simple as switching from:
to:
where argot-path is ‘ocamlfind query argot‘ when installed through ocamlfind, and to either:
if not installed through ocamlfind.
First, one needs to create a modules.odocl file containing the list of modules to generate documentation for. Then, the following line should be added to the _tags file:
To handle the argot flag, it is necessary to define an ocamlbuild plugin, like the one presented by code sample 1. Finally, it is possible to call ocamlbuild, taking care to specify an ocamldoc version compatible with the generator. The example using ‘‘argot.cmo’’, it is necessary to pass the -ocamldoc /path/to/ocamldoc command-line switch in order to ensure that this is the bytecode version of ocamldoc that will be actually called by ocamlbuild.
open Ocamlbuild_plugin
open Ocamlbuild_pack
let () =
dispatch begin function
| After_rules ->
flag ["argot"] (S[A"-i"; A"+custom"; A"-g"; A"argot.cmo"]);
let myocamldoc tags =
Ocaml_tools.ocamldoc_l_dir (tags -- "extension:html") in
rule "ocamldoc: argot"
~prod:"%.docdir/index.html"
~dep:"%.odocl"
~stamp:"%.docdir/html.stamp"
~insert:`top
(Ocaml_tools.document_ocaml_project ~ocamldoc:myocamldoc
"%.odocl"
"%.docdir/index.html"
"%.docdir")
| _ -> ()
end
In addition to the already available {b ...} (for bold), {i ...} (for italic), and {e ...} (for emphasized), Argot provides the following text formatting modifiers:
In order to define tables, the following elements can be used:
Here is an example of a complete table definition:
{table {caption the caption}
{row {header key} {header value}}
{row {data key1} {data {i data1}}}
{row {data key2} {data {i data2}}}
{row {span 2 summary}}}
Token substitution allows one to use the value of either an environment variable or a command-line switch into an html page. This may for example be useful to insert insert the current date, or to specify the path of an element at documentation generation time:
{token DATE}
file {token FILE_PATH}/file.ext
The value of a token is first searched in -define id value switches passed to the ocamldoc tool, and then searched among the environment variables.
It is possible to include images into the generated pages through
{image path}. The image data will be directly
embedded into the page using base64 format, in such a way that no
external link remains in the generated html. There is thus no need
to package the image along with the html pages.
To avoid to use the full path to the image, it is possible to use the
aforementioned token substitution inside the image formatter:
{image {token IMAGE_PATH}/img.png}
Then, one has to specify the value for IMAGE_PATH on the command-line through the -define switch seen above:
ocamldoc -define IMAGE_PATH /path/to/images ...
When some explanation, albeit useful, is long and/or may appear as a
digression, it is possible to fold it. It means that the texte inside
a {fold digression} will appear as an ellipsis
(i.e. ...) and will be unfolded (that is revealed) when the
ellipsis will be clicked. At the opposite, clicking on the ellipsis while
the foldable text is visible will make it disappear. Any formatting
instruction can be used in the digression.
Argot also defines a bunch of new tags that can be used to enhance
documentation. Some of these tags come with image icons; these have
been designed by Mark James, released under the Creative Commons
Attribution 2.5 License, and are available at
http://www.famfamfam.com/lab/icons/silk/.
The additional tags are:
This document was translated from LATEX by HEVEA.