-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add support for odoc #17
Comments
I don't know if it's better to add support for I think you will be interested by:
The code block parser is pretty simple (it's actually just a lexer) and I think for An other interesting option is to add a |
I plan to work on this feature very soon, did you start working on this @rizo ? (is there something I could re-use?) |
Hey @gpetiot! Sorry for the late reply. I haven't started working on this feature yet, I'm currently working on more critical odoc features. Feel free to work on this and let me know if you have any questions. P.S. See the linked discussion for some details about odoc integration. |
Update on this: I started working on the code block extraction logic in odoc to allow further integration with mdx. Here's the PR and discussion: ocaml/odoc#303. |
Sadly the PR seems stalled. |
I've written a working version of this. It doesn't support shell, and it doesn't support mdx's notion of "sections". All the other environment/label stuff should work, because all I've done is created a new lexer -- for finding code blocks inside mli docstrings -- and new pretty printers. So suppose you had this in an mli: (** This is a doc comment with a code block in it:
{[ # let x = 1 + 1 ]}
*) The new mdx, when passed the flag (** This is a doc comment with a code block in it:
{[
# let x = 1 + 1
val x : int = 2
]}
*) I will submit a pull request soon, but in the meantime, the high-level approach involves:
Curious to hear feedback on this approach. After some more testing and reviewing, I'll submit a pull request. |
That seems like a good approach to me! I'd be very interested to review your patches. Also curious to hear feedback from @jonludlam who is working on the next version of |
The support for |
Based on the original discussion in ocaml/dune#895 (comment).
It would be great to have support for odoc in mdx. It is a common practice to include examples in API documentation and those can get out of date very quickly. Additionally the new odoc version will include support for documentation pages which would benefit from this feature.
Here are some questions I have regarding the potential integration:
{[ ... ]}
in the documentation or is it better to have a special annotation for this (some examples might not be runnable at all on purpose)?sh
syntax?I would be glad to work on a PR for this feature in the next couple of weeks. Suggestions about how this could be implemented would be very appreciated! :)
Thanks!
The text was updated successfully, but these errors were encountered: