Skip to content

Commit 830034f

Browse files
authored
Place rtype after directive (#537)
1 parent 8a82cb8 commit 830034f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/sphinx_autodoc_typehints/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,8 @@ def get_insert_index(app: Sphinx, lines: list[str]) -> InsertIndexInfo | None:
906906
continue
907907
line_no = node_line_no(child)
908908
at = max(line_no - 2, 0) if line_no else len(lines)
909+
if lines[at - 1]: # skip if something on this line
910+
break
909911
return InsertIndexInfo(insert_index=at, found_directive=True)
910912

911913
# 5. Otherwise, insert at end

tests/test_integration.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1410,15 +1410,19 @@ def docstring_with_multiline_note_after_params_epilog_replace(param: int) -> Non
14101410
"""
14111411
mod.docstring_with_see_also()
14121412
1413-
Return type:
1414-
"str"
1413+
Test
14151414
14161415
See also: more info at <https://example.com>`_.
14171416
1417+
Return type:
1418+
"str"
1419+
14181420
"""
14191421
)
14201422
def docstring_with_see_also() -> str:
14211423
"""
1424+
Test
1425+
14221426
.. seealso:: more info at <https://example.com>`_.
14231427
"""
14241428
return ""

0 commit comments

Comments
 (0)