package mdx

  1. Overview
  2. Docs

Code blocks.

type cram_value = {
  1. pad : int;
  2. tests : Cram.t list;
}
type value =
  1. | Raw
  2. | OCaml
  3. | Error of string list
  4. | Cram of cram_value
  5. | Toplevel of Toplevel.t list

The type for block values.

type section = int * string

The type for sections.

type t = {
  1. line : int;
  2. file : string;
  3. section : section option;
  4. labels : (string * ([ `Eq | `Neq | `Le | `Lt | `Ge | `Gt ] * string) option) list;
  5. header : string option;
  6. contents : string list;
  7. value : value;
}

The type for supported code blocks.

val empty : t

empty is the empty block.

Printers

val dump : t Fmt.t

dump is the printer for dumping code blocks. Useful for debugging.

val pp_header : ?syntax:Mdx__.Syntax.t -> t Fmt.t

pp_header pretty-prints block headers.

val pp_contents : ?syntax:Mdx__.Syntax.t -> t Fmt.t

pp_contents pretty-prints block contents.

pp_footer pretty-prints block footer.

val pp : ?syntax:Mdx__.Syntax.t -> t Fmt.t

pp pretty-prints blocks.

val pp_line_directive : (string * int) Fmt.t

pp_line_directive pretty-prints a line directive given as a filename and line number.

Accessors

val mode : t -> [ `Non_det of [ `Command | `Output ] | `Normal ]

mode t is t's mode.

val directory : t -> string option

directory t is the directory where t tests should be run.

val source_trees : t -> string list

source_trees t is the list of extra source-trees to add as dependency of the code-block.

val file : t -> string option

file t is the name of the file to synchronize t with.

val part : t -> string option

part t is the part of the file to synchronize t with. If lines is not specified synchronize the whole file.

val environment : t -> string

environment t is the name given to the environment where t tests are run.

val set_variables : t -> (string * string) list

set_variable t is the list of environment variable to set and their values

val unset_variables : t -> string list

unset_variable t is the list of environment variable to unset

val required_packages : t -> string list

required_packages t is the names of the required packages

val skip : t -> bool

skip t is true iff skip is in the labels of t.

val value : t -> value

value t is t's value.

val section : t -> section option

section t is t's section.

val header : t -> string option

header t is t's header.

val executable_contents : t -> string list

executable_contents t is either t's contents if t is a raw or a cram block, or t's commands if t is a toplevel fragments (e.g. the phrase result is discarded).

val version_enabled : t -> bool

version_supported t if the current OCaml version complies with t's version.

Evaluation

val eval : t -> t

eval t is the same as t but with it's value replaced by either Cram or Toplevel blocks, depending on t's header.

Parsers

val labels_of_string : string -> (string * ([ `Eq | `Neq | `Gt | `Ge | `Lt | `Le ] * string) option) list

labels_of_string s cuts s into a list of labels.

OCaml

Innovation. Community. Security.