Skip to content

Commit

Permalink
fix: space after field with no description
Browse files Browse the repository at this point in the history
  • Loading branch information
weibullguy committed May 31, 2023
1 parent 2861ffe commit 29b5282
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
project = "docformatter"
copyright = "2022-2023, Steven Myint"
author = "Steven Myint"
release = "1.7.2-rc2"
release = "1.7.2-rc3"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "docformatter"
version = "1.7.2-rc2"
version = "1.7.2-rc3"
description = "Formats docstrings to follow PEP 257"
authors = ["Steven Myint"]
maintainers = [
Expand Down
2 changes: 1 addition & 1 deletion src/docformatter/__pkginfo__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
# SOFTWARE.
"""Package information for docformatter."""

__version__ = "1.7.2-rc2"
__version__ = "1.7.2-rc3"
17 changes: 9 additions & 8 deletions src/docformatter/syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,14 @@ def do_wrap_field_lists( # noqa: PLR0913
try:
_field_description = text[_field[1] : field_idx[_idx + 1][0]].strip()
except IndexError:
_field_description = text[
_field[1] :
].strip() # .replace(" ", "").replace("\t", "")
_field_description = text[_field[1] :].strip()

if _field_description:
_field_description = f" {_field_description}"

if len(_field_description) <= (wrap_length - len(indentation)):
lines.append(
f"{indentation}{text[_field[0]: _field[1]]} " f"{_field_description}"
f"{indentation}{text[_field[0]: _field[1]]}{_field_description}"
)
else:
if len(indentation) > DEFAULT_INDENT:
Expand All @@ -493,16 +494,16 @@ def do_wrap_field_lists( # noqa: PLR0913

_wrapped_fields = textwrap.wrap(
textwrap.dedent(
f"{text[_field[0]:_field[1]]} " f"{_field_description.strip()}"
f"{text[_field[0]:_field[1]]} {_field_description.strip()}"
),
width=wrap_length,
initial_indent=indentation,
subsequent_indent=_subsequent,
)
for _idx, _wrapped_field in enumerate(_wrapped_fields):
_indent = indentation if _idx == 0 else _subsequent
for _wrapped_idx, _wrapped_field in enumerate(_wrapped_fields):
_indent = indentation if _wrapped_idx == 0 else _subsequent
_wrapped_fields[
_idx
_wrapped_idx
] = f"{_indent}{re.sub(' +', ' ', _wrapped_field.strip())}"

lines.extend(_wrapped_fields)
Expand Down

0 comments on commit 29b5282

Please sign in to comment.