Module Odoc_parser.AstSource

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.

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

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

Sourcetype 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.

Sourcetype 'a cell = 'a with_location list * [ `Header | `Data ]
Sourcetype 'a row = 'a cell list
Sourcetype 'a grid = 'a row list
Sourcetype 'a abstract_table = 'a grid * alignment option list option
Sourcetype code_block_meta = {
  1. language : string with_location;
  2. tags : string with_location option;
}
Sourcetype 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;
}
Sourceand 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).

Sourceand table = nestable_block_element abstract_table * [ `Light | `Heavy ]
Sourcetype 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

Sourcetype 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)

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