Skip to content
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

Create myst-example directive and change documentation to use it #250

Closed
jbms opened this issue Apr 28, 2023 · 2 comments · Fixed by #254
Closed

Create myst-example directive and change documentation to use it #250

jbms opened this issue Apr 28, 2023 · 2 comments · Fixed by #254

Comments

@jbms
Copy link
Owner

jbms commented Apr 28, 2023

I think the myst-example directive is more of a long-term and worthwhile goal. The solution [in #247] is only meant to satisfy #162 per user's request/feedback.

Originally posted by @2bndy5 in #247 (comment)

@2bndy5
Copy link
Collaborator

2bndy5 commented May 2, 2023

I took a swing at this and it was really easy to re-use the same directive class from our rst-example directive for a myst-example directive. So, that is a first step. There are some MyST examples that can't be used with this though (eg. section headings and markup representing <hr> elements).

My original vision was to feed a single directive multiple code-blocks with the language set, then render them in a set of tabs whose labels correspond to the code-block's language. I was imagining something like

.. doc-example::

    .. code-block:: rst

        Some ``syntax``.

    .. code-block:: md

        Some `syntax`.

Alternatively, it would be more ideal to have rST content converted to MyST syntax and render both syntaxes as a set of tabs (whose labels correspond to the syntax name "rST" and "MyST") sharing a single rendered result. I think this would be better as a derivative of the rst-example directive. I'm not sure if it should be done the other way around though (take MyST content and convert it to rST).

This will take me some time as the parser used by the state machine seems to be automatically determined based on the source file's suffix.

@2bndy5
Copy link
Collaborator

2bndy5 commented May 2, 2023

Damn. It looks like the rst2myst tool (still in beta) doesn't support the latest docutils.

I'll just submit a patch for what I have and put my original vision (a bit zealous even for me) on the back burner (again) till we have a feasible tool/lib to convert rST to MyST.

@2bndy5 2bndy5 mentioned this issue May 2, 2023
2bndy5 added a commit that referenced this issue May 2, 2023
* add myst-example directive
* use myst-example directive in the MyST example topology doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants