99
1010{2 Description}
1111
12+ This label allows you to specify the working directory from which the block
13+ should be evaluated.
14+
1215{2 Syntax}
1316
17+ [dir=<value>]
18+
19+ The dir label expects a single string value which corresponds to the path
20+ to the directory from which the block must be evaluated. It should be a path
21+ relative to the directory containing the current [.mli]/[.mld]/[.md] file.
22+
23+ [.mli] example:
24+ {v
25+ (** We will list the files in subdir:
26+ {@sh dir=subdir[
27+ $ ls
28+ something.ml something_else.ml
29+ ]} *)
30+ v}
31+
32+ [.md] example:
33+ {@markdown[
34+ We will list the files in subdir:
35+ <!-- $MDX dir=subdir -->
36+ ```sh
37+ $ ls
38+ something.ml something_else.ml
39+ ```
40+ ]}
41+
1442{2 Applies to}
1543
44+ - {{!page-types_of_blocks.ocaml_toplevel} OCaml Toplevel Blocks}
45+ - {{!page-types_of_blocks.ocaml} OCaml Blocks}
46+ - {{!page-types_of_blocks.file_include} File Include Blocks}
47+ - {{!page-types_of_blocks.shell} Shell Blocks}
48+
1649{2 Default}
1750
51+ When absent, the block will be evaluated from the directory of
52+ the file being tested by MDX.
53+
1854{1:source_tree Source Tree}
1955
2056{2 Description}
2965
3066{2 Description}
3167
68+ This label allows you
69+
3270{2 Syntax}
3371
72+ [file=<value]
73+
74+ The [file] label expects a single string value which corresponds to the path
75+
3476{2 Applies to}
3577
78+ - {{!page-types_of_blocks.file_include} File Include Blocks}
79+
3680{2 Default}
3781
82+ This label is mandatory for File Include Blocks and therefore has no default
83+ value.
84+
3885{1:part Part}
3986
4087{2 Description}
5097{2 Description}
5198
5299This label allows you to assign an environment to an OCaml block. That means
53- you benefit from whole the code that has been previously evaluated in that
100+ you benefit from all the code that has been previously evaluated in that
54101environment, be it from other code blocks or {{!page-preludes}preludes}.
55102
56103{2 Syntax}
@@ -63,10 +110,10 @@ name of the environment to use.
63110[.mli] example:
64111{v
65112(** Here is how to use this function:
66- {@ocaml env=foo[
67- # f 0;;
68- - : int = 0
69- ]} *)
113+ {@ocaml env=foo[
114+ # f 0;;
115+ - : int = 0
116+ ]} *)
70117v}
71118
72119[.md] example:
@@ -88,3 +135,138 @@ Here is how to use this function:
88135
89136When absent, the block will be evaluated in the default environment, e.g.
90137the environment shared by all blocks without an [env] label.
138+
139+ {1:skip Skip}
140+
141+ {2 Description}
142+
143+ This label allows you to explicitly ask MDX not to interpret a block, no
144+ matter its content.
145+
146+ {2 Syntax}
147+
148+ [skip]
149+
150+ The [skip] label takes no value.
151+
152+ [.mli] example:
153+ {v
154+ (** MDX should not interpret the following block:
155+ {@ocaml skip[
156+ # 1 + 1;;
157+ - : int = 3
158+ ]}
159+ v}
160+
161+ [.md] example:
162+ {@markdown[
163+ MDX should not interpret the following block:
164+ <!-- $MDX skip -->
165+ ```ocaml
166+ # 1 + 1;;
167+ - : int = 3
168+ ```
169+ ]}
170+
171+ {2 Applies to}
172+
173+ - {{!page-types_of_blocks.ocaml_toplevel} OCaml Toplevel Blocks}
174+ - {{!page-types_of_blocks.ocaml} OCaml Blocks}
175+ - {{!page-types_of_blocks.file_include} File Include Blocks}
176+ - {{!page-types_of_blocks.shell} Shell Blocks}
177+
178+ {2 Default}
179+
180+ By default MDX will interpret any block it knows how to deal with and skip
181+ any other block.
182+
183+ {1:non_det Non Deterministic}
184+
185+ {2 Description}
186+
187+ {2 Syntax}
188+
189+ {2 Applies to}
190+
191+ {2 Default}
192+
193+ {1:version Version}
194+
195+ {2 Description}
196+
197+ {2 Syntax}
198+
199+ {2 Applies to}
200+
201+ {2 Default}
202+
203+ {1:set Set}
204+
205+ {2 Description}
206+
207+ {2 Syntax}
208+
209+ {2 Applies to}
210+
211+ {2 Default}
212+
213+ {1:unset Unset}
214+
215+ {2 Description}
216+
217+ {2 Syntax}
218+
219+ {2 Applies to}
220+
221+ {2 Default}
222+
223+ {1:type Type}
224+
225+ {2 Description}
226+
227+ This label allows you to explicitly set the type of the block as described
228+ in {{!page.types_of_blocks}this section}.
229+ Explicitly setting the type of the block instead of relying on MDX to infer
230+ it will provide better error messages and guidance in case of syntax errors or
231+ labels misuse.
232+
233+ {2 Syntax}
234+
235+ [type=<value>]
236+
237+ The [type] label accepts one of the following values:
238+ - [toplevel] for OCaml Toplevel Blocks
239+ - [ocaml] for OCaml Blocks
240+ - [cram] for Shell Blocks
241+ - [include] for File Include Blocks
242+
243+ [.mli] example:
244+ {v
245+ (** The following block is a toplevel block:
246+ {@ocaml type=toplevel[
247+ # 1 + 1;;
248+ - : int = 2
249+ ]} *)
250+ v}
251+
252+ [.md] example:
253+ {@markdown[
254+ The following block is a toplevel block:
255+ <!-- $MDX type=toplevel -->
256+ ```ocaml
257+ # 1 + 1;;
258+ - : int = 2
259+ ```
260+ ]}
261+
262+ {2 Applies to}
263+
264+ - {{!page-types_of_blocks.ocaml_toplevel} OCaml Toplevel Blocks}
265+ - {{!page-types_of_blocks.ocaml} OCaml Blocks}
266+ - {{!page-types_of_blocks.file_include} File Include Blocks}
267+ - {{!page-types_of_blocks.shell} Shell Blocks}
268+
269+ {2 Default}
270+
271+ By default, MDX will infer the type of the block based on its language header,
272+ its content and its labels.
0 commit comments