Skip to content

Commit

Permalink
fix: wrapping literal blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
weibullguy committed May 3, 2023
1 parent 766dbd1 commit 139247b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 4 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.0-rc2'
release = '1.7.0-rc3'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/source/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ the requirement falls in, the type of requirement, and whether
' PEP_257_9.4',' Should be documented whether keyword arguments are part of the interface.',' Methodology',' Should',' No'
' docformatter_10', '**docstring Syntax**'
' docformatter_10.1', ' Should wrap docstrings at n characters.', ' Style', ' Should', ' Yes'
' docformatter_10.1.1', ' Shall not wrap lists or syntax directive statements', ' Derived', ' Shall', ' Yes'
' docformatter_10.1.1', ' Shall not wrap lists, syntax directive statements, or literal blocks', ' Derived', ' Shall', ' Yes'
' docformatter_10.1.1.1', ' Should allow wrapping of lists and syntax directive statements.', ' Stakeholder', ' Should', ' Yes [*PR #5*, *PR #93*]'
' docformatter_10.1.2', ' Should allow/disallow wrapping of one-line docstrings.', ' Derived', ' Should', ' No'
' docformatter_10.1.3', ' Shall not wrap links that exceed the wrap length.', ' Derived', ' Shall', ' Yes [*PR #114*]'
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.0-rc2"
version = "1.7.0-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.0-rc2"
__version__ = "1.7.0-rc3"
3 changes: 3 additions & 0 deletions src/docformatter/syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ def is_some_sort_of_list(text: str, strict: bool) -> bool:
or
# "parameter -- description"
re.match(r"\s*\S+\s+--\s+", line)
or
# "parameter::" <-- Literal block
re.match(r"\s*[\S ]*:{2}", line)
)
for line in split_lines
)
Expand Down
22 changes: 22 additions & 0 deletions tests/test_utility_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,28 @@ def test_is_some_sort_of_list_non_strict_wrap(self):
False,
)

@pytest.mark.unit
def test_is_some_sort_of_list_literal_block(self):
"""Identify literal blocks.
See issue #199 and requirement docformatter_10.1.1.1.
"""
assert docformatter.is_some_sort_of_list(
"""\
This is a description.
Example code::
config(par=value)
Example code2::
with config(par=value) as f:
pass
""",
False,
)


class TestIsSomeSortOfCode:
"""Class for testing the is_some_sort_of_code() function."""
Expand Down

0 comments on commit 139247b

Please sign in to comment.