Skip to content

Commit cc188f4

Browse files
committed
Place rtype after directive
Closes #535
1 parent 9bc4b14 commit cc188f4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/sphinx_autodoc_typehints/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,8 @@ def get_insert_index(app: Sphinx, lines: list[str]) -> InsertIndexInfo | None:
899899
continue
900900
line_no = node_line_no(child)
901901
at = max(line_no - 2, 0) if line_no else len(lines)
902+
if lines[at - 1]: # skip if something on this line
903+
break
902904
return InsertIndexInfo(insert_index=at, found_directive=True)
903905

904906
# 5. Otherwise, insert at end

tests/test_integration.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,15 +1397,19 @@ def docstring_with_multiline_note_after_params_epilog_replace(param: int) -> Non
13971397
"""
13981398
mod.docstring_with_see_also()
13991399
1400-
Return type:
1401-
"str"
1400+
Test
14021401
14031402
See also: more info at <https://example.com>`_.
14041403
1404+
Return type:
1405+
"str"
1406+
14051407
"""
14061408
)
14071409
def docstring_with_see_also() -> str:
14081410
"""
1411+
Test
1412+
14091413
.. seealso:: more info at <https://example.com>`_.
14101414
"""
14111415
return ""

0 commit comments

Comments
 (0)