realworldocaml / mdx

Execute code blocks inside your documentation
ISC License
269 stars 45 forks source link

Recognize metadata labels in `mli` files #357

Closed Leonidas-from-XIV closed 2 years ago

Leonidas-from-XIV commented 2 years ago

This is a revival of #339 with a bit of rebasing and a tiny bit more polish.

Leonidas-from-XIV commented 2 years ago

odoc-parser.1.0.0 is out, but unfortunately it conflicts with ocamlformat.0.19.0, so it forces a formatter downgrade which then has issues formatting our code.

Julow commented 2 years ago

OCamlformat 0.20.1 has been released today and has compatibility with odoc-parser 1.0.0.

Leonidas-from-XIV commented 2 years ago

I'm not happy that all the blocks need to know whether they are Syntax.Mli or not to print the proper padding because it it incredibly fussy and the cyclomatic complexity is through the roof but it is… not worse than before and at least Cram.t in .mli files should be displayed properly.

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 Cram.t printing bug that @Julow found.

Leonidas-from-XIV commented 2 years ago

We discussed this with @Julow and concluded that it is worth merging, hence I merged it.