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

Parsing error when using code-block directive #150

Closed
jrbourbeau opened this issue Sep 23, 2022 · 3 comments · Fixed by #151
Closed

Parsing error when using code-block directive #150

jrbourbeau opened this issue Sep 23, 2022 · 3 comments · Fixed by #151

Comments

@jrbourbeau
Copy link

When using blackdoc (v0.3.7) on this .rst snippet

.. code-block:: python

   >>> import dask.dataframe as dd

I get

❯ python -m blackdoc test.rst
error: cannot format /Users/james/projects/dask/dask/test.rst: Cannot parse: 4:0: >>> import dask.dataframe as dd
Oh no! 💥 💔 💥
1 file fails to reformat.

However, when I update the .rst to

.. ::

   >>> import dask.dataframe as dd

which should be equivalent, blackdoc is happy.

@keewis
Copy link
Owner

keewis commented Sep 28, 2022

thanks for the report, @jrbourbeau. This should be pretty easy to fix (it's a matter of skipping the rst formatter for code blocks with prompt lines; there's similar code for the ipython prompt), but it might take me some time to create a PR.

@keewis
Copy link
Owner

keewis commented Oct 7, 2022

Note that

.. ::

    >>> import dask.dataframe as dd

is equivalent to

>>> import dask.dataframe as dd

(i.e. blackdoc does not care about the block for doctest lines... except the bug reported here, of course)

However, this:

.. ::

    import dask.dataframe as dd

or

description::

    import dask.dataframe as dd

will most likely always be ignored, because the language depends on a sphinx setting / a directive somewhere earlier in the document.

In any case, the bug should be fixed by #151.

@jrbourbeau
Copy link
Author

Thanks for the fix @keewis! Looking forward to taking this for a spin

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