[myst-parser](https://myst-parser.readthedocs.io/) ([github](https://github.com/executablebooks/MyST-Parser)) [supports sphinx roles](https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html#roles-directives). Quick links: - [`sphinx.ext.doctest`](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html) (source: [sphinx/ext/doctest.py](https://github.com/sphinx-doc/sphinx/blob/5.x/sphinx/ext/doctest.py)) - Related: https://github.com/Erotemic/xdoctest/issues/68 - [Also referenced](https://github.com/executablebooks/MyST-Parser/discussions/601) - as of today at v0.18.0 these are parsed as [`nodes.literal_block`](https://pydoc.dev/docutils/latest/docutils.nodes.literal_block.html) not [`nodes.doctest_block`](https://pydoc.dev/docutils/latest/docutils.nodes.doctest_block.html) ([message](https://github.com/executablebooks/MyST-Parser/issues/444#issuecomment-987296252)) - Potentially useful: https://gist.github.com/tonyfast/cfb55f41f5452ef33ec6fbb4e0bda991 [Normal directive syntax](https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html#directives-a-block-level-extension-point): ```` ```{doctest} >>> print(1 + 2) 3 ``` ```` [`eval-rst`](https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html#roles-directives:~:text=For%20special%20cases%2C%20MySt%20also%20offers%20the%20eval%2Drst%20directive.%20This%20will%20parse%20the%20content%20as%20ReStructuredText%3A) directive: ````markdown ```{eval-rst} .. doctest:: >>> print(1 + 2) 3 ``` ````
myst-parser (github) supports sphinx roles.
Quick links:
sphinx.ext.doctest(source: sphinx/ext/doctest.py)xdoctestwork with the Sphinx doctest extension? Erotemic/xdoctest#68nodes.literal_blocknotnodes.doctest_block(message)Normal directive syntax:
eval-rstdirective: