package odoc-parser

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Abstract syntax tree representing ocamldoc comments

This is a syntactic representation of ocamldoc comments. See The manual for a detailed description of the syntax understood. Note that there is no attempt at semantic analysis, and hence these types are capable of representing values that will be rejected by further stages, for example, invalid references or headings that are out of range.

type 'a with_location = 'a Loc.with_location
type style = [
  1. | `Bold
  2. | `Italic
  3. | `Emphasis
  4. | `Superscript
  5. | `Subscript
]
type alignment = [
  1. | `Left
  2. | `Center
  3. | `Right
]
type reference_kind = [
  1. | `Simple
  2. | `With_text
]

References in doc comments can be of two kinds: {!simple} or {{!ref}With text}.

type inline_element = [
  1. | `Space of string
  2. | `Word of string
  3. | `Code_span of string
  4. | `Raw_markup of string option * string
  5. | `Styled of style * inline_element with_location list
  6. | `Reference of reference_kind * string with_location * inline_element with_location list
  7. | `Math_span of string
    (*
    • since 2.0.0
    *)
]

Inline elements are equivalent to what would be found in a span in HTML. Mostly these are straightforward. The `Reference constructor takes a triple whose second element is the reference itself, and the third the replacement text. Similarly the `Link constructor has the link itself as first parameter and the second is the replacement text.

type 'a cell = 'a with_location list * [ `Header | `Data ]
type 'a row = 'a cell list
type 'a grid = 'a row list
type 'a abstract_table = 'a grid * alignment option list option
type code_block_meta = {
  1. language : string with_location;
  2. tags : string with_location option;
}
type code_block = {
  1. meta : code_block_meta option;
  2. delimiter : string option;
  3. content : string with_location;
  4. output : nestable_block_element with_location list option;
}
and nestable_block_element = [
  1. | `Paragraph of inline_element with_location list
  2. | `Code_block of code_block
  3. | `Verbatim of string
  4. | `Modules of string with_location list
  5. | `List of [ `Unordered | `Ordered ] * [ `Light | `Heavy ] * nestable_block_element with_location list list
  6. | `Table of table
  7. | `Math_block of string
    (*
    • since 2.0.0
    *)
]

Some block elements may be nested within lists or tags, but not all. The `List constructor has a parameter of type [`Light | `Heavy]. This corresponds to the syntactic constructor used (see the manual).

and table = nestable_block_element abstract_table * [ `Light | `Heavy ]
type internal_tag = [
  1. | `Canonical of string with_location
  2. | `Inline
  3. | `Open
  4. | `Closed
  5. | `Hidden
]

Internal tags are used to exercise fine control over the output of odoc. They are never rendered in the output

type ocamldoc_tag = [
  1. | `Author of string
  2. | `Deprecated of nestable_block_element with_location list
  3. | `Param of string * nestable_block_element with_location list
  4. | `Raise of string * nestable_block_element with_location list
  5. | `Return of nestable_block_element with_location list
  6. | `See of [ `Url | `File | `Document ] * string * nestable_block_element with_location list
  7. | `Since of string
  8. | `Before of string * nestable_block_element with_location list
  9. | `Version of string
]

ocamldoc tags are those that are specified in the manual)

type tag = [
  1. | ocamldoc_tag
  2. | internal_tag
]
type heading = int * string option * inline_element with_location list
type block_element = [
  1. | nestable_block_element
  2. | `Heading of heading
  3. | `Tag of tag
]
OCaml

Innovation. Community. Security.