OCAMLDOC(1)
π OCAMLDOC(1) β the OCaml documentation generator π
okay bestie, welcome to ocamldoc(1), from the General Commands Manual, and no cap this thing is the moment. it's the OCaml documentation generator and it's about to make your source files spill all their tea. β¨
πΈ NAME πΈ
ocamldoc β the OCaml documentation generator π«Ά
β¨ SYNOPSIS β¨
ocamldoc [ options ] filename ...
π DESCRIPTION π
so like. ocamldoc(1) is the OCaml documentation generator, and what it does is generate documentation straight out of the special comments you tucked into your source files. the comments it cares about are the ones shaped like (** ... *), and they follow the format described in the The OCaml user's manual. yes that's literally what it's called, i don't make the rules π
the range on this girl? iconic. ocamldoc can produce documentation in a whole bunch of formats:
- HTML
- LaTeX
- TeXinfo
- Unix man pages
- and
dot(1)dependency graphs π¦
and that's not even the best part β users can add their own custom generators. main character energy fr fr π₯
π one lil vocab check, bestie π
in this manpage, when we say element, we mean any of these 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
lowkey memorize that list, because we're gonna be saying "element" a lot and it's giving very much essential. iykyk π
π OPTIONS π
okay bestie, this is the part where you pick your whole vibe. every one of these flags decides what kind of documentation ocamldoc(1) is gonna spit out for you. choose wisely, it's giving β¨destinyβ¨.
π Options for choosing the output format π
-htmlβ generate the docs as HTML, the default format. the pages land in the current directory (or wherever-dpoints). wanna make it cute? edit the generatedstyle.css, or bring your own sheet with-css-style. heads up:style.csswill not be regenerated if it's already there, so your edits are safe. π-latexβ generate the docs as LaTeX, the default format. the document gets saved intoocamldoc.out, or into whatever file-osays. it uses the style fileocamldoc.sty, which gets generated when you use-latexif it doesn't already exist. tweak that file to customize the look. π-texiβ generate the docs in TeXinfo default format. the generated LaTeX document goes toocamldoc.out, or to the file you name with-o.-manβ generate the docs as a set of Unix man pages. they get stored in the current directory, or in the directory from-d.-dotβ generate a dependency graph for the toplevel modules, in a formatdot(1)can display and process.dot(1)lives over athttps://graphviz.org/. the textual version of the graph goes toocamldoc.out, or to the file from-o. rundot ocamldoc.outto actually see it. π₯-gfile β dynamically load file (usually a.cmoor.cma), which defines a custom documentation generator. if it's a simple file and it's not in the current directory,ocamldochunts for it in the custom generators' default directory and in the directories you gave with-i.-customdirβ show the custom generators' default directory. just tells you where the magic lives.-idirectory β add directory to the path where custom generators are searched for.
πΈ General options πΈ
-ddir β write files into dir instead of the current directory.-dumpfile β dump all the collected info into file. you can read that info back later with the-loadoption in a subsequent invocation ofocamldoc(1).-hidemodules β hide these complete module names from the generated docs. modules is a list of complete module names separated by commas (,), no blanks allowed. like this:Stdlib,M2.M3.-inv-merge-ml-mliβ reverse the precedence of implementations and interfaces when merging. every element in implementation files is kept, and the-moption decides which parts of the interface file comments get merged with the implementation file comments. flip the script, basically. π-keep-codeβ always keep the source code for values, methods and instance variables when it's available. source code is always kept when a.mlfile is given, but by default it gets discarded when a.mliis given. this flag says "no, keep it always". π-loadfile β load info from file, which was produced byocamldoc -dump. you can pass several-loadoptions at once.-mflags β set the merge options between interfaces and implementations. flags can be one or several of these characters:dβ merge descriptionaβ merge@authorvβ merge@versionlβ merge@seesβ merge@sinceoβ merge@deprecatedpβ merge@parameβ merge@raiserβ merge@returnAβ merge everything
-no-custom-tagsβ do not allow custom@-tags. sorry, no homemade tags today.-no-stopβ keep elements placed after the(**/**)special comment.-ofile β send the generated documentation to file instead ofocamldoc.out. this only means anything alongside the-latex,-texi, or-dotoptions. periodt.-openmodule β opens module before typing.-ppcommand β pipe sources through preprocessor command.-ppxcommand β pipe the abstract syntax tree through preprocessor command.-show-missed-crossrefβ show missed cross-reference opportunities. the ones that got away π.-sortβ sort the list of top-level modules before generating the docs.-starsβ remove blank characters until the first asterisk ('*') in each line of comments.-ttitle β use title as the title for the generated documentation. main character energy.-textfile β treat file as a.txtfile.-introfile β use the content of file as ocamldoc text for the introduction (HTML, LaTeX and TeXinfo only). for HTML, the file is used to create the whole"index.html"file.-vβ verbose mode. shows you progress info, so you're never left wondering. π-versionβ print the version string and exit.-vnumβ print the short version number and exit.-warn-errorβ treat ocamldoc warnings as errors. spicy. π₯-hide-warningsβ do not print ocamldoc warnings.-helpor--helpβ display a short usage summary and exit.
π§ Type-checking options π§
ocamldoc(1) calls the OCaml type-checker to get type information. these options affect the type-checking phase, and they mean exactly the same thing as they do for ocamlc(1) and ocamlopt(1).
-Idirectory β add directory to the list of directories searched for compiled interface files (.cmifiles).-nolabelsβ ignore non-optional labels in types.-rectypesβ allow arbitrary recursive types. (see the-rectypesoption ofocamlc(1).)
π Options for generating HTML pages π
these apply when you're rolling with the -html option:
-all-paramsβ display the complete list of parameters for functions and methods.-charsets β add info about character encoding being s (default isiso-8859-1).-css-stylefilename β use filename as the Cascading Style Sheet file.-colorize-codeβ colorize the OCaml code enclosed in[ ]and\{[ ]\}, using colors to emphasize keywords and stuff. if the code fragments aren't syntactically correct, no color is added. no glow-up for broken code π.-index-onlyβ generate only index files.-short-functorsβ use a short form to display functors:module M : functor (A:Module) -> functor (B:Module2) -> sig .. endgets displayed asmodule M (A:Module) (B:Module2) : sig .. end. so much cleaner, obsessed. β¨
π¦ Options for generating LaTeX files π¦
these apply when you're rolling with the -latex option:
-latex-value-prefixprefix β give a prefix to use for the labels of the values in the generated LaTeX document. the default prefix is the empty string. you can also use the options-latex-type-prefix,-latex-exception-prefix,-latex-module-prefix,-latex-module-type-prefix,-latex-class-prefix,-latex-class-type-prefix,-latex-attribute-prefix, and-latex-method-prefix.
these options are useful when you have, like, a type and a value with the same name. if you don't specify prefixes, LaTeX will complain about multiply defined labels. it WILL complain, bestie, it always does. π
-latextitlen,style β associate style number n to the given LaTeX sectioning command style, e.g.sectionorsubsection. (LaTeX only.) this is useful when including the generated document in another LaTeX document, at a given sectioning level. the default association is 1 forsection, 2 forsubsection, 3 forsubsubsection, 4 forparagraphand 5 forsubparagraph.-noheaderβ suppress the header in the generated documentation.-notocβ do not generate a table of contents.-notrailerβ suppress the trailer in the generated documentation.-sepfilesβ generate one.texfile per toplevel module, instead of the globalocamldoc.outfile.
π Options for generating TeXinfo files π
these apply when you're rolling with the -texi option:
-esc8β escape accented characters in Info files.-info-entryβ specify the Info directory entry.-info-sectionβ specify the section of the Info directory.-noheaderβ suppress the header in the generated documentation.-noindexβ do not build an index for Info files.-notrailerβ suppress the trailer in the generated documentation.
π Options for generating dot graphs π
these apply when you're rolling with the -dot option:
-dot-colorscolors β specify the colors to use in the generated dot code. when generating module dependencies,ocamldoc(1)uses different colors for modules depending on the directories they live in. when generating type dependencies,ocamldoc(1)uses different colors for types depending on the modules they're defined in. colors is a list of color names separated by commas (,), likeRed,Blue,Green. the available colors are the onesdot(1)supports. aesthetic. π-dot-include-allβ include all modules in thedot(1)output, not just the ones given on the command line or loaded with the-loadoption.-dot-reduceβ perform a transitive reduction of the dependency graph before outputting the dot code. this is useful when there are a lot of transitive dependencies cluttering up the graph. declutter the timeline, fr fr. π§Ή-dot-typesβ output dot code describing the type dependency graph instead of the module dependency graph.
π Options for generating man files π
these apply when you're rolling with the -man option:
-man-miniβ generate man pages only for modules, module types, classes and class types, instead of pages for all elements.-man-suffixsuffix β set the suffix used for generated man filenames. default iso, as inList.o.-man-sectionsection β set the section number used for generated man filenames. default is3.
π SEE ALSO π
ocaml(1),ocamlc(1),ocamlopt(1).- the OCaml user's manual, chapter "The documentation generator".
and that's a wrap on the whole thing, bestie π«Ά go forth and document your OCaml like the icon you are. this isOCAMLDOC(1), signing off β and yes, the page footer really does just sayOCAMLDOC(1)and nothing else, no hidden version number or date hiding down there, so consider this your cute little stand-in for it. slay. π β¨
π¦ where this page comes from
- alpine 3.22: ocaml5-doc 5.3.0-r0 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- alpine 3.23: ocaml5-doc 5.4.0-r0 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- alpine 3.24: ocaml5-doc 5.4.1-r0 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- centos-stream 10: ocaml-docs 5.2.0-5.el10 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- debian trixie: ocaml 5.3.0-3 Β· LGPL-2.1-OCaml
- fedora 43: ocaml-docs 5.3.0-4.fc43 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- fedora 44: ocaml-docs 5.4.0-2.fc44 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- nixos 26.05: ber-metaocaml 153
- nixos 26.05: ocaml 5.4.1
- nixpkgs unstable: ber-metaocaml 153
- nixpkgs unstable: ocaml 5.5.1
- nixpkgs unstable: ocaml-solo5 1.3.5
- ubuntu questing: ocaml 5.3.0-3
- ubuntu resolute: ocaml 5.4.0-3ubuntu1 Β· LGPL-2.1-OCaml
- ubuntu stonking: ocaml 5.4.1-1ubuntu1 Β· LGPL-2.1-OCaml
- Copyright 2004 Institut National de Recherche en Informatique et
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms