Skip to content

Commit

Permalink
Write mdx files to .mdx dir to avoid running mdx as part of @ALL
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
  • Loading branch information
NathanReb committed Jul 29, 2020
1 parent 44d5194 commit 4825ded
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
next
----

- Write intermediate files in a `.mdx` folder for each `mdx` stanza
to prevent the corresponding actions to be executed as part of the `@all`
alias (#????, @NathanReb)

- Read Coq flags from `env` (#3547 , fixes #3486, @gares)

- Allow bisect_ppx to be enabled/disabled via dune-workspace. (#3404,
Expand Down
11 changes: 7 additions & 4 deletions src/dune/mdx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ module Files = struct
let deps_file build_path =
Path.Build.extend_basename ~suffix:".mdx.deps" build_path

let from_source_file src =
let deps = deps_file src in
let corrected = corrected_file src in
let from_source_file ~mdx_dir src =
let basename = Path.Build.basename src in
let dot_mdx_path = Path.Build.relative mdx_dir basename in
let deps = deps_file dot_mdx_path in
let corrected = corrected_file dot_mdx_path in
{ src; deps; corrected }

let diff_action { src; corrected; deps = _ } =
Expand Down Expand Up @@ -172,7 +174,8 @@ let files_to_mdx t ~sctx ~dir =
[stanza]. *)
let gen_rules_for_single_file stanza ~sctx ~dir ~expander ~mdx_prog src =
let loc = stanza.loc in
let files = Files.from_source_file src in
let mdx_dir = Path.Build.relative dir ".mdx" in
let files = Files.from_source_file ~mdx_dir src in
(* Add the rule for generating the .mdx.deps file with ocaml-mdx deps *)
Super_context.add_rule sctx ~loc ~dir (Deps.rule ~dir ~mdx_prog files);
(* Add the rule for generating the .corrected file using ocaml-mdx test *)
Expand Down
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/mdx-stanza.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ You can use the mdx stanza to check your documentation in markdown and mli files
$ dune runtest --root simple/
Entering directory 'simple'
File "README.md", line 1, characters 0-0:
Error: Files _build/default/README.md and _build/default/README.md.corrected
differ.
Error: Files _build/default/README.md and
_build/default/.mdx/README.md.corrected differ.
[1]
Dune should invoke `ocaml-mdx deps` to figure out the files and directories a markdown
Expand Down

0 comments on commit 4825ded

Please sign in to comment.