@@ -525,6 +525,28 @@ def test_parse_yields_section(parse_google: ParserType) -> None:
525525 assert "'x'" in warnings [0 ]
526526
527527
528+ def test_parse_deprecated_section (parse_google : ParserType ) -> None :
529+ """Parse Deprecated section.
530+
531+ See [`mkdocstrings/griffe#352`](https://github.com/mkdocstrings/griffe/issues/352)
532+ for context.
533+
534+ Parameters:
535+ parse_google: Fixture parser.
536+ """
537+ docstring = """
538+ Deprecated:
539+ 1.0: This function is deprecated.
540+ """
541+ sections , warnings = parse_google (docstring )
542+ assert len (sections ) == 1
543+ deprecated = sections [0 ]
544+ assert deprecated .kind is DocstringSectionKind .deprecated
545+ assert deprecated .value .version == "1.0"
546+ assert deprecated .value .description == "This function is deprecated."
547+ assert not warnings
548+
549+
528550def test_invalid_sections (parse_google : ParserType ) -> None :
529551 """Warn on invalid sections.
530552
@@ -1131,6 +1153,60 @@ def test_parse_returns_tuple_in_generator(parse_google: ParserType) -> None:
11311153 assert returns [1 ].annotation .name == "float"
11321154
11331155
1156+ # =============================================================================================
1157+ # Deprecated sections
1158+
1159+
1160+ def test_parse_deprecated_section_missing_version (parse_google : ParserType ) -> None :
1161+ """Parse version numbers in Deprecated sections that aren't numbers.
1162+
1163+ See [`mkdocstrings/griffe#352`](https://github.com/mkdocstrings/griffe/issues/352)
1164+ for context.
1165+
1166+ Parameters:
1167+ parse_google: Fixture parser.
1168+ """
1169+ docstring = """
1170+ Summary.
1171+
1172+ Deprecated:
1173+ Since "Dapper Drake": This function is deprecated.
1174+ """
1175+ sections , warnings = parse_google (docstring )
1176+ assert len (sections ) == 2
1177+ deprecated = sections [1 ]
1178+ assert deprecated .kind is DocstringSectionKind .deprecated
1179+ assert deprecated .value .version == 'Since "Dapper Drake"'
1180+ assert deprecated .value .description == "This function is deprecated."
1181+ assert not warnings
1182+
1183+
1184+ def test_dont_warn_about_missing_deprecated_version (parse_google : ParserType ) -> None :
1185+ """Don't warn about missing version info in Deprecated sections.
1186+
1187+ Also assert that we don't just swallow the section, but actually parse it.
1188+
1189+ See [`mkdocstrings/griffe#352`](https://github.com/mkdocstrings/griffe/issues/352)
1190+ for context.
1191+
1192+ Parameters:
1193+ parse_google: Fixture parser.
1194+ """
1195+ docstring = """
1196+ Summary.
1197+
1198+ Deprecated:
1199+ This function is deprecated since v0.9alpha1.
1200+ """
1201+ sections , warnings = parse_google (docstring )
1202+ assert len (sections ) == 2
1203+ deprecated = sections [1 ]
1204+ assert deprecated .kind is DocstringSectionKind .deprecated
1205+ assert not deprecated .value .version
1206+ assert deprecated .value .description == "This function is deprecated since v0.9alpha1."
1207+ assert not warnings
1208+
1209+
11341210# =============================================================================================
11351211# Parser special features
11361212def test_parse_admonitions (parse_google : ParserType ) -> None :
0 commit comments