Mdx 2.3.0
We're pleased to announce the release of Mdx 2.3.0!
This release comes with support for mld
files and changes the parser used
by the toplevel, which allows Camlp5's parser to be used with MDX.
🌟 Spotlight Feature
Starting in MDX 2.3.0, you can now execute code blocks in your .mld
files! 🎉
As a reminder, .mld
files are text files similar to Markdown, but instead of
using the Markdown markup language, they use the Ocamldoc markdown language - as
is used in .mli
files. .mld
are typically used to write manuals with
odoc.
To run mdx on .mld
files, start by enabling mdx
in your dune-project
:
(using mdx 0.3)
Then list your .mld
files in the mdx
stanza in your dune
:
(mdx
(files index.mld))
Now if you put a code block in index.mld
, it will be executed when running dune test
and if dune will suggest to promote the output. For instance, if you run dune test
with this index.mld
:
Here's an example code block in a [.mld] file:
{[
# List.map (fun x -> x * x) [(1 + 9); 2; 3; 4];;
]}
dune test
will return:
---+++@@@@ Here's an example code block in a [.mld] file:
{[
# List.map (fun x -> x * x) [(1 + 9); 2; 3; 4];;
+ - : int list = [100; 4; 9; 16]
]}
You can run dune promote
to accept the change.
You can see a complete demo of this here.
Now you can keep the code blocks in your manual up-to-date even when your API changes!
See full changelog
Added
- Added support for
mld
files (#423, @jonludlam)
Changed
- Switch to using the parser that toplevel uses (found in a mutable
ref
, instead of always the official OCaml parser). This allows Camlp5's parser to be used with MDX. (#417, @chetmurthy)