-
Notifications
You must be signed in to change notification settings - Fork 48
Recognize metadata labels in mli files
#357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recognize metadata labels in mli files
#357
Conversation
|
|
|
OCamlformat |
Julow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests need to be promoted:
diff --git a/test/bin/mdx-test/expect/simple-mli/test-case.mli b/test/bin/mdx-test/expect/simple-mli/test-case.mli
index 254d76d..78c970e 100644
--- a/test/bin/mdx-test/expect/simple-mli/test-case.mli
+++ b/test/bin/mdx-test/expect/simple-mli/test-case.mli
@@ -47,5 +47,5 @@ val foo : string
(** {@ocaml[1 + 1 = 3]} *)
val bar : string
-(** {@ocaml skip [1 + 1 = 3]} *)
+(** {@ocaml skip[1 + 1 = 3]} *)
val baz : string
diff --git a/test/lib/test_mli_parser.ml b/test/lib/test_mli_parser.ml
index 89a6ab5..c226f93 100644
--- a/test/lib/test_mli_parser.ml
+++ b/test/lib/test_mli_parser.ml
@@ -101,7 +101,7 @@ let test_parse_mli =
~expected:
(Ok
{x|[Text "(** This doc comment with a label should get parsed\n\n ";
- Text "{@"; Text "ocaml"; Text " "; Text "skip "; Text "[";
+ Text "{@"; Text "ocaml"; Text " "; Text "skip"; Text "[";
Block {loc: File "_none_", lines 3-6; section: None; labels: [skip];
header: Some ocaml; contents: ["# 1 + 1"; "- : int = 2"];
value: Toplevel};The language tag is used as the header and the other field is for labels. If the metadata is absent, the code block is run as OCaml. This is backward compatible. Until now, Mdx would strip it from the original file by ignoring it at parsing and not outputting it back. This is a rebased version of #339 upon which improvements applied. Resolves #339
|
I'm not happy that all the blocks need to know whether they are I suggest revisiting our Markdown parsering some time down the road to make it more similar to what we get from odoc-parser and try to avoid all this switching logic but for now I think this is ok to be reviewed and actually also fixes the |
Julow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
I've sent a patch to your branch but it can wait until the next refactoring: https://github.com/Leonidas-from-XIV/mdx/pull/1
Co-authored-by: Jules Aguillon <[email protected]>
|
We discussed this with @Julow and concluded that it is worth merging, hence I merged it. |
CHANGES: #### Added - Add support for adding language tags and metadata labels in `mli` files. (realworldocaml/mdx#339, realworldocaml/mdx#357, @Julow, @Leonidas-from-XIV) - Add support for running non-deterministic tests in `dune` MDX 0.2 stanza by setting the `MDX_RUN_NON_DETERMINISTIC` environment variable. (realworldocaml/mdx#365, realworldocaml/mdx#366, @Leonidas-from-XIV)
This is a revival of #339 with a bit of rebasing and a tiny bit more polish.