You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Griffe claims to specifically support "Deprecated" sections in Google-style docstrings, but actually parses them as general admonitions. (See the "To Reproduce" section below.) The parsing code is there, but it isn't being triggered, because "deprecated" is not recognized as a section name: it is missing from the table of known section names.
Using mkdocstrings-python 1.13.0 (with MkDocs 1.6.1 and mkdocs-material 9.5.49) and griffe 1.5.4, the following Python function
defgriffe_bug() ->None:
"""bla bla bla Deprecated: Since v1.0: Insecure! Do not use! """
renders as
Changing the section heading to DeprecatedABC changes the rendered admonition heading to "DeprecatedABC", confirming that this is indeed parsed as an admonition.
If point (1) is fixed by adding the "deprecated" entry into the recognized section names table, then Griffe will assume the section contents are of the form version: text, and will attempt to partition the contents in this manner. If this fails, then Griffe will issue a warning, and then silently drop the entire section. This is because the parsing code, upon failing to partition the section text, returns None instead of a DocstringSection object (L711).
This is only confirmed via the tests in #353. No published version of Griffe exhibits this behavior yet.
Expected behavior
Griffe should parse these sections as Deprecated sections, not as admonitions. mkdocstrings-python should render them not as default admonitions, but as specific ones (perhaps similar to how griffe-deprecations renders them).
Griffe should not drop docstring sections it cannot properly parse, it should always pass them on.
Environment information
Debian Linux "testing", Python 3.12. See reproduction #1 above for Griffe and mkdocs* versions.
Additional context
(none)
The text was updated successfully, but these errors were encountered:
The code to parse these sections already existed, but the "Deprecated" section header was missing from the table of known section headers. Being an unknown section, Griffe then treated this as an admonition.
Griffe initially required a version indicator in Google-style Deprecated sections. This change now allows it to be missing, in which case the version is the empty string.
Issue-352: #352
PR-353: #353
Description of the bug (1 of 2)
Griffe claims to specifically support "Deprecated" sections in Google-style docstrings, but actually parses them as general admonitions. (See the "To Reproduce" section below.) The parsing code is there, but it isn't being triggered, because "deprecated" is not recognized as a section name: it is missing from the table of known section names.
griffe/src/_griffe/docstrings/google.py
Lines 48 to 72 in a2f320f
I'm preparing a PR to address this.PR fix: Parse Deprecated sections in Google-style docstrings #353 addresses this issue.To Reproduce (1 of 2)
Using
mkdocstrings-python
1.13.0 (with MkDocs 1.6.1 andmkdocs-material
9.5.49) andgriffe
1.5.4, the following Python functionrenders as
Changing the section heading to
DeprecatedABC
changes the rendered admonition heading to "DeprecatedABC", confirming that this is indeed parsed as an admonition.The tests in #353 confirm this suspicion as well.
Description of the bug (2 of 2)
If point (1) is fixed by adding the "deprecated" entry into the recognized section names table, then Griffe will assume the section contents are of the form
version: text
, and will attempt to partition the contents in this manner. If this fails, then Griffe will issue a warning, and then silently drop the entire section. This is because the parsing code, upon failing to partition the section text, returnsNone
instead of aDocstringSection
object (L711).griffe/src/_griffe/docstrings/google.py
Lines 706 to 719 in a2f320f
To Reproduce (2 of 2)
This is only confirmed via the tests in #353. No published version of Griffe exhibits this behavior yet.
Expected behavior
Griffe should parse these sections as Deprecated sections, not as admonitions.
mkdocstrings-python
should render them not as default admonitions, but as specific ones (perhaps similar to how griffe-deprecations renders them).Griffe should not drop docstring sections it cannot properly parse, it should always pass them on.
Environment information
Debian Linux "testing", Python 3.12. See reproduction #1 above for Griffe and
mkdocs*
versions.Additional context
(none)
The text was updated successfully, but these errors were encountered: