package mdx

  1. Overview
  2. Docs

Code blocks headers.

module Header : sig ... end

Code blocks.

type cram_value = {
  1. language : [ `Bash | `Sh ];
  2. non_det : Label.non_det option;
}
type ocaml_value = {
  1. env : Ocaml_env.t;
    (*

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

    *)
  2. non_det : Label.non_det option;
  3. errors : Output.t list;
    (*

    header defines whether a header was specified for the block.

    *)
  4. header : Header.t option;
}
type toplevel_value = {
  1. env : Ocaml_env.t;
    (*

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

    *)
  2. non_det : Label.non_det option;
}
type include_ocaml_file = {
  1. part_included : string option;
    (*

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

    *)
}
type include_other_file = {
  1. header : Header.t option;
}
type include_file_kind =
  1. | Fk_ocaml of include_ocaml_file
  2. | Fk_other of include_other_file
type include_value = {
  1. file_included : string;
    (*

    file_included is the name of the file to synchronize with.

    *)
  2. file_kind : include_file_kind;
}
type raw_value = {
  1. header : Header.t option;
}
type value =
  1. | Raw of raw_value
  2. | OCaml of ocaml_value
  3. | Cram of cram_value
  4. | Toplevel of toplevel_value
  5. | Include of include_value

The type for block values.

type section = int * string

The type for sections.

module Raw : sig ... end
type t = {
  1. loc : Location.t;
  2. section : section option;
  3. dir : string option;
  4. labels : Label.t list;
  5. legacy_labels : bool;
  6. contents : string list;
  7. skip : bool;
  8. version_enabled : bool;
    (*

    Whether the current OCaml version complies with the block's version.

    *)
  9. set_variables : (string * string) list;
  10. unset_variables : string list;
  11. value : value;
}

The type for supported code blocks.

val mk : loc:Location.t -> section:section option -> labels:Label.t list -> legacy_labels:bool -> header:Header.t option -> contents:string list -> errors:Output.t list -> (t, [ `Msg of string ]) result
val mk_include : loc:Location.t -> section:section option -> labels:Label.t list -> (t, [ `Msg of string ]) result

mk_include builds an include block from a comment <!-- $MDX ... --> that is not followed by a code block ``` ... ```.

val from_raw : Raw.t -> (t, [ `Msg of string ] list) Result.result

Printers

val dump : t Fmt.t

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

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

pp_header pretty-prints full block headers with the labels.

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

pp_contents pretty-prints block contents.

pp_footer pretty-prints block footer.

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

pp pretty-prints blocks.

Accessors

val non_det : t -> Label.non_det option

Whether a block's command or output is non-deterministic.

val directory : t -> string option

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

val file : t -> string option

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

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 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 is_active : ?section:string -> t -> bool

Helpers

val ends_by_semi_semi : string list -> bool
OCaml

Innovation. Community. Security.