package mdx

  1. Overview
  2. Docs
Executable code blocks inside markdown files

Install

Dune Dependency

Authors

Maintainers

Sources

mdx-1.11.1.tbz
sha256=603990812efa7184d88a4896d7f9369b43d32e3dbdd26fe9cecb5a5f5f32c1e0
sha512=461bb3f2e25f8a2f869577ec8f95f731e0765a534043088fdc88ee9fabaa52926eb957124529ff889f1d698df594b235219c677521eebe01a5959c7db75131ea

doc/mdx/Mdx/Block/index.html

Module Mdx.BlockSource

Code blocks headers.

Sourcemodule Header : sig ... end

Code blocks.

Sourcetype cram_value = {
  1. language : [ `Bash | `Sh ];
  2. non_det : Label.non_det option;
}
Sourcetype 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;
}
Sourcetype 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;
}
Sourcetype 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.

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

    file_included is the name of the file to synchronize with.

    *)
  2. file_kind : include_file_kind;
}
Sourcetype raw_value = {
  1. header : Header.t option;
}
Sourcetype 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.

Sourcetype section = int * string

The type for sections.

Sourcetype t = {
  1. loc : Location.t;
  2. section : section option;
  3. dir : string option;
  4. source_trees : string list;
  5. required_packages : string list;
  6. labels : Label.t list;
  7. legacy_labels : bool;
  8. contents : string list;
  9. skip : bool;
  10. version_enabled : bool;
    (*

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

    *)
  11. set_variables : (string * string) list;
  12. unset_variables : string list;
  13. value : value;
}

The type for supported code blocks.

Sourceval 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.result
Sourceval mk_include : loc:Location.t -> section:section option -> labels:Label.t list -> (t, [ `Msg of string ]) Result.result

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

Printers

Sourceval dump : t Fmt.t

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

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

pp_header pretty-prints full block headers with the labels.

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

pp_contents pretty-prints block contents.

pp_footer pretty-prints block footer.

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

pp pretty-prints blocks.

Sourceval pp_line_directive : (string * int) Fmt.t

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

Accessors

Sourceval non_det : t -> Label.non_det option

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

Sourceval directory : t -> string option

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

Sourceval source_trees : t -> string list

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

Sourceval file : t -> string option

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

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

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

Sourceval unset_variables : t -> string list

unset_variable t is the list of environment variable to unset

Sourceval explicit_required_packages : t -> string list

explicit_required_packages t returns the list of packages explicitly required by the user through require-package labels in the block t.

Sourceval required_libraries : t -> (Library.Set.t, string) Result.result

required_libraries t returns the set of libaries that are loaded through #require statements in the block t. Always returns an empty set if t isn't a toplevel block.

Sourceval skip : t -> bool

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

Sourceval value : t -> value

value t is t's value.

Sourceval section : t -> section option

section t is t's section.

Sourceval executable_contents : syntax:Syntax.t -> 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).

Sourceval is_active : ?section:string -> t -> bool

Parsers

Sourceval require_from_line : string -> (Library.Set.t, string) Result.result

require_from_line line returns the set of libraries imported by the #require statement on line or an empty set if line is not a require statement.

Sourceval require_from_lines : string list -> (Library.Set.t, string) Result.result

Same as require_from_line but aggregated over several lines

OCaml

Innovation. Community. Security.