-
Notifications
You must be signed in to change notification settings - Fork 6
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
(WIP) Myst parser: .md
+ {eval-rst}
support
#31
base: master
Are you sure you want to change the base?
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to give you more feedback on the weekend.
pytest_sphinx.py
Outdated
@@ -71,6 +71,7 @@ def _is_doctest(config, path, parent): | |||
|
|||
_DIRECTIVE_RE = re.compile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_DIRECTIVE_RE.match
is currently used for every line in a docstring/txt file.
pytest_sphinx.py
Outdated
@@ -71,6 +71,7 @@ def _is_doctest(config, path, parent): | |||
|
|||
_DIRECTIVE_RE = re.compile( | |||
r""" | |||
(?P<myst_directive>`{3}{eval-rst}\n?)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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-rst
directive support..md
testdata/using_the_shapereader.md
using_the_shapereader.md
intest_cartopy
{eval-rst}
and tests_DIRECTIVE_RE
improvements - Use verbose, named expression for readability (cherry-picked and rebased in via Use verbose regular expression #33, Use named group regular expression #34)