diff --git a/.github/workflows/on-push-tag.yml b/.github/workflows/on-push-tag.yml index 915e59f..5c78f91 100644 --- a/.github/workflows/on-push-tag.yml +++ b/.github/workflows/on-push-tag.yml @@ -56,9 +56,9 @@ jobs: if: ${{ env.build_ok == 1 }} uses: release-drafter/release-drafter@v5 with: - name: $env.tag - tag: $env.tag - version: $env.tag + name: ${{ env.tag }} + tag: ${{ env.tag }} + version: ${{ env.tag }} prerelease: true publish: true env: diff --git a/docs/source/conf.py b/docs/source/conf.py index e8d8bfb..d337b1d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,7 +11,7 @@ project = "docformatter" copyright = "2022-2023, Steven Myint" author = "Steven Myint" -release = "1.7.3" +release = "1.7.4" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/pyproject.toml b/pyproject.toml index 54eab94..06c5af6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "docformatter" -version = "1.7.3" +version = "1.7.4" description = "Formats docstrings to follow PEP 257" authors = ["Steven Myint"] maintainers = [ diff --git a/src/docformatter/__pkginfo__.py b/src/docformatter/__pkginfo__.py index b97e2eb..0758dfe 100644 --- a/src/docformatter/__pkginfo__.py +++ b/src/docformatter/__pkginfo__.py @@ -23,4 +23,4 @@ # SOFTWARE. """Package information for docformatter.""" -__version__ = "1.7.3" +__version__ = "1.7.4" diff --git a/src/docformatter/syntax.py b/src/docformatter/syntax.py index 92f3973..c6af9a6 100644 --- a/src/docformatter/syntax.py +++ b/src/docformatter/syntax.py @@ -59,7 +59,7 @@ REST_REGEX = r"((\.{2}|`{2}) ?[\w.~-]+(:{2}|`{2})?[\w ]*?|`[\w.~]+`)" """Regular expression to use for finding reST directives.""" -SPHINX_REGEX = r":[a-zA-Z0-9_\-(). ]*:" +SPHINX_REGEX = r":(param|raises|return|rtype|type)[a-zA-Z0-9_\-.() ]*:" """Regular expression to use for finding Sphinx-style field lists.""" URL_PATTERNS = ( @@ -276,7 +276,10 @@ def do_find_directives(text: str) -> bool: return bool([(_rest.start(0), _rest.end(0)) for _rest in _rest_iter]) -def do_find_field_lists(text: str, style: str): +def do_find_field_lists( + text: str, + style: str, +): r"""Determine if docstring contains any field lists. Parameters diff --git a/tests/_data/string_files/format_sphinx.toml b/tests/_data/string_files/format_sphinx.toml index 7ffe13e..e2e566e 100644 --- a/tests/_data/string_files/format_sphinx.toml +++ b/tests/_data/string_files/format_sphinx.toml @@ -139,7 +139,7 @@ instring='''"""CC. """''' outstring='''"""CC. - :math:`-` + :math: `-` """''' [issue_230] @@ -190,8 +190,7 @@ outstring='''"""CC. C. - C, - :math:`[0, 1]`. + C, :math:`[0, 1]`. """''' [issue_239] @@ -223,3 +222,17 @@ outstring='''"""Some f. :param a: Some param. :raises my.package.MyReallySrsError: Bad things happened. """''' + +[issue_250] +instring=''' """CC. + + c. + + c c :math:`[0, 1]`. + """''' +outstring='''"""CC. + + c. + + c c :math:`[0, 1]`. + """''' diff --git a/tests/formatter/test_format_sphinx.py b/tests/formatter/test_format_sphinx.py index f6de300..297d682 100644 --- a/tests/formatter/test_format_sphinx.py +++ b/tests/formatter/test_format_sphinx.py @@ -396,3 +396,40 @@ def test_format_docstring_sphinx_style_field_name_has_periods( INDENTATION, instring, ) + + @pytest.mark.unit + @pytest.mark.parametrize( + "args", + [ + [ + "--wrap-descriptions", + "88", + "--wrap-summaries", + "88", + "", + ] + ], + ) + def test_format_docstring_sphinx_style_ignore_directive( + self, + test_args, + args, + ): + """Should not identify inline directives as sphinx field names. + + See issue #250. + """ + uut = Formatter( + test_args, + sys.stderr, + sys.stdin, + sys.stdout, + ) + + instring = self.TEST_STRINGS["issue_250"]["instring"] + outstring = self.TEST_STRINGS["issue_250"]["outstring"] + + assert outstring == uut._do_format_docstring( + INDENTATION, + instring, + )