(WIP) Myst parser: .md + {eval-rst} support#31
Conversation
.md + {eval-rst} support.md + {eval-rst} support
|
@Thisch I will ping you when this is ready to look at Have not hand tested yet. I will build a very robust testsuite for it |
|
Awesome! Thx a lot. |
|
@Thisch feel free to let tests run |
d8c8662 to
938f0a4
Compare
|
@tony thx a lot for all your PRs. I've just enabled the CI pipeline. |
173f4da to
3f98b3f
Compare
|
@Thisch Thank you!
Current PR status: I need to test this by hand, but open to any early feedback |
adf4213 to
6e88ca8
Compare
twmr
left a comment
There was a problem hiding this comment.
I'll try to give you more feedback on the weekend.
| @@ -71,6 +71,7 @@ def _is_doctest(config, path, parent): | |||
|
|
|||
| _DIRECTIVE_RE = re.compile( | |||
There was a problem hiding this comment.
_DIRECTIVE_RE.match is currently used for every line in a docstring/txt file.
|
|
||
| _DIRECTIVE_RE = re.compile( | ||
| r""" | ||
| (?P<myst_directive>`{3}{eval-rst}\n?)? |
There was a problem hiding this comment.
Therefore, this line, doesn't currently add change anything.
If you want that _DIRECTIVE_RE finds (for markdown content) a match for the following input
```{{eval-rst}}
.. docstest::
but not for
```{{xxxxx}}
.. doctest::
we have to extend the code that calls _DIRECTIVE_RE.match
There was a problem hiding this comment.
I've been having some issues when testing this locally in my project, so this may be why.
I will look into this.
(note to self, the above message refers to how the regex checks every line)
There was a problem hiding this comment.
Could you take a stab at getting it to work? (using the existing parser)
I am going try a fork of this branch that uses the myst-parser/docutils/etc API.
Here's what you can do:
I added a test to tests/test_sphinx_doctest.py::TestDirectives::test_doctest. It automatically skips if myst-parser is not found
pip install myst-parser or pip install -e .[myst-parser] (bash) or pip install -e ".[myst-parser]" (zsh)
Then py.test
Re-invoke on file rerun:
pip install pytest-watcher
With this test
py.test tests/test_sphinx_doctest.py::TestDirectives::test_doctest ; ptw . tests/test_sphinx_doctest.py::TestDirectives::test_doctest
Project-wide
py.test -x -s -v; ptw . -x -s -v
There was a problem hiding this comment.
@Thisch I did a lot of research this week, I am going to be digging into the docutils, sphinx, and myst / markdown-it and pytest APIs next weekend. This is priority 0 for me, outside of work
145ca1a to
79de46d
Compare
7857cf0 to
e3f674b
Compare
|
@Thisch I may take a fresh stab at this non-docutils PR now that I am familiarized with doctest 👍 This approach, if pulled it off, would be easier to merge, preserve existing features, and have 0 extra dependencies. |
pip install "rst-to-myst[sphinx]" rst2myst convert using_the_shapereader.rst See also: - https://rst-to-myst.readthedocs.io/en/latest/
Editable: pip install -e .[myst-parser] zsh: pip install -e ".[myst-parser]" pip install pytest-sphinx[myst-parser] zsh: pip install "pytest-sphinx[myst-parser]"
re: #30
Naïve
eval-rstdirective support..mdtestdata/using_the_shapereader.mdusing_the_shapereader.mdintest_cartopy{eval-rst}and tests_DIRECTIVE_REimprovements - Use verbose, named expression for readability (cherry-picked and rebased in via Use verbose regular expression #33, Use named group regular expression #34)