pytest-sphinx icon indicating copy to clipboard operation
pytest-sphinx copied to clipboard

Support for `.md` / `myst-parser`

Open tony opened this issue 3 years ago • 3 comments

myst-parser (github) supports sphinx roles.

Quick links:

Normal directive syntax:

```{doctest}

>>> print(1 + 2)
3
```

eval-rst directive:

```{eval-rst}

.. doctest::

   >>> print(1 + 2)
   3
```

tony avatar Jul 10 '22 19:07 tony

Sounds like a good idea! Thx for the suggestion! I think it makes sense to use the MyST parser for extracting the doctests. Are you familiar with the MyST python api?

twmr avatar Jul 10 '22 19:07 twmr

@thisch Not enough to champion a PR

The reference page should be a good place to start:

tony avatar Jul 10 '22 19:07 tony

My ambition would be to use it here: https://libvcs.git-pull.com/parse/git.html (.md, .py)

Right now I have doctest everywhere as its amazingly efficient to have meaningful tests that double as documentation, but I'd like to have tutorials, how to, and explanations where the examples are backed by tests.

Workaround: If using automodule directives, write the doctests at the top of the .py file.

tony avatar Jul 11 '22 00:07 tony