PyCQA / docformatter

Formats docstrings to follow PEP 257
https://pypi.python.org/pypi/docformatter
MIT License
530 stars 62 forks source link

Error when URL is the last line #145

Closed mwalsh161 closed 1 year ago

mwalsh161 commented 1 year ago

https://github.com/PyCQA/docformatter/blob/6706e9591c9f605956372eb1ee6228c465e0ac93/src/docformatter/syntax.py#L138 fails if there is no additional line (and possibly URLs .

Traceback (most recent call last):
    ...
  File ".../python3.7/site-packages/docformatter/syntax.py", line 87, in do_preserve_links
    url = url + lines[url_idx + 1].strip()
IndexError: list index out of range

The input docstring was:


"""<Short decription>

.. _linspace API: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html
.. _arange API: https://numpy.org/doc/stable/reference/generated/numpy.arange.html
.. _logspace API: https://numpy.org/doc/stable/reference/generated/numpy.logspace.html
"""
weibullguy commented 1 year ago

@mwalsh161 I got ahead of myself releasing 1.5.0 to PyPi without sufficient testing. Before I cause users anymore headaches, I'm providing release candidates for the brave to use and provide feedback. If you'd like to use the next release candidate that should resolve your issue, you can install it with pip:

pip install git+https://github.com/PyCQA/docformatter.git@v1.6.0.rc1