-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Documentation: mention tools that can do doctests formatting #3083
Comments
Thank you for opening the discussion again. Personally, after #2150, #3087 and the like, I'm increasingly hesitant to push for more docstring changes. To be fair though, formatting docstrings could be less controversial than us choosing a strict docstring style. Since doctests are code, would this be more appropriate as a dedicated tool wrapping Black? |
This is a good point! |
Question: isn't this already supported by blacken-docs? |
After posting this, I realized that extension only works on documentation files ( |
However, blackdoc works on python files. Depending on where you are placing doctests, you may need both packages. |
Oh awesome! I will give it a stab, that would be certainly worth showcasing in the black docs/website! |
I'd be willing to consider advertising some of these tools in, say, our "integrations"! |
Would like to work on this |
Renamed the issue to reflect the discussion above: we won't do this in Black itself, but we should document third-party tools that can do this. |
def f():
"""docstring here
```pycon
>>> print("hello world")
```
""" or def f():
"""docstring here
.. code-block:: pycon
>>> print("hello world")
""" However, it doesn't support doctests that aren't in Markdown/reStructuredText blocks (issue is old, but I'm pretty sure it hasn't changed).
The issue with using both packages is that they don't fully agree: class _UDF:
...
@util.experimental
@classmethod
def python(cls, fn=None, *, name=None, schema=None, signature=None, **kwargs):
"""
Examples
--------
```pycon
>>> import ibis
>>> @ibis.udf.scalar.pandas
... def add_one(x: int) -> int:
... return x + 1
>>> expr = add_one(2)
>>> con = ibis.connect(os.environ["SNOWFLAKE_URL"]) # doctest: +SKIP
>>> con.execute(expr) # doctest: +SKIP
3
```
""" The above is formatted by edit: Another example... if you have a docstring using single quotes, edit2: On the flip side, |
I would Like you work on this issue . |
Updating the CHNAGES.md for just resolving the issue psf#3083 and showing the full description of what added and what it does in the file.
…ssue-1244203163 Update CHANGES.md
Is your feature request related to a problem? Please describe.
Black currently does not format Doctests in Docstrings. This issues was reported in #745 which was superseeded by #144.
As the latter was closed though, nothing was done about the Doctests.
Describe the solution you'd like
I would be keen for black to format Doctest.
For example, given the following Python Doctests code:
black could produce the following output:
Describe alternatives you've considered
I'm manually formatting the code.
Additional context
N/A
The text was updated successfully, but these errors were encountered: