@@ -1033,3 +1033,91 @@ def test_sphinx_output_formatter_no_use_rtype(app: SphinxTestApp, status: String
1033
1033
"str" -- A string
1034
1034
"""
1035
1035
assert text_contents == dedent (expected_contents )
1036
+
1037
+
1038
+ @pytest .mark .sphinx ("text" , testroot = "dummy" )
1039
+ @patch ("sphinx.writers.text.MAXWIDTH" , 2000 )
1040
+ def test_sphinx_output_with_use_signature (app : SphinxTestApp , status : StringIO ) -> None :
1041
+ set_python_path ()
1042
+ app .config .master_doc = "simple" # type: ignore # create flag
1043
+ app .config .typehints_use_signature = True # type: ignore
1044
+ app .build ()
1045
+ assert "build succeeded" in status .getvalue ()
1046
+ text_path = pathlib .Path (app .srcdir ) / "_build" / "text" / "simple.txt"
1047
+ text_contents = text_path .read_text ().replace ("–" , "--" )
1048
+ expected_contents = """\
1049
+ Simple Module
1050
+ *************
1051
+
1052
+ dummy_module_simple.function(x: bool, y: int = 1)
1053
+
1054
+ Function docstring.
1055
+
1056
+ Parameters:
1057
+ * **x** ("bool") -- foo
1058
+
1059
+ * **y** ("int") -- bar
1060
+
1061
+ Return type:
1062
+ "str"
1063
+ """
1064
+ assert text_contents == dedent (expected_contents )
1065
+
1066
+
1067
+ @pytest .mark .sphinx ("text" , testroot = "dummy" )
1068
+ @patch ("sphinx.writers.text.MAXWIDTH" , 2000 )
1069
+ def test_sphinx_output_with_use_signature_return (app : SphinxTestApp , status : StringIO ) -> None :
1070
+ set_python_path ()
1071
+ app .config .master_doc = "simple" # type: ignore # create flag
1072
+ app .config .typehints_use_signature_return = True # type: ignore
1073
+ app .build ()
1074
+ assert "build succeeded" in status .getvalue ()
1075
+ text_path = pathlib .Path (app .srcdir ) / "_build" / "text" / "simple.txt"
1076
+ text_contents = text_path .read_text ().replace ("–" , "--" )
1077
+ expected_contents = """\
1078
+ Simple Module
1079
+ *************
1080
+
1081
+ dummy_module_simple.function(x, y=1) -> str
1082
+
1083
+ Function docstring.
1084
+
1085
+ Parameters:
1086
+ * **x** ("bool") -- foo
1087
+
1088
+ * **y** ("int") -- bar
1089
+
1090
+ Return type:
1091
+ "str"
1092
+ """
1093
+ assert text_contents == dedent (expected_contents )
1094
+
1095
+
1096
+ @pytest .mark .sphinx ("text" , testroot = "dummy" )
1097
+ @patch ("sphinx.writers.text.MAXWIDTH" , 2000 )
1098
+ def test_sphinx_output_with_use_signature_and_return (app : SphinxTestApp , status : StringIO ) -> None :
1099
+ set_python_path ()
1100
+ app .config .master_doc = "simple" # type: ignore # create flag
1101
+ app .config .typehints_use_signature = True # type: ignore
1102
+ app .config .typehints_use_signature_return = True # type: ignore
1103
+ app .build ()
1104
+ assert "build succeeded" in status .getvalue ()
1105
+ text_path = pathlib .Path (app .srcdir ) / "_build" / "text" / "simple.txt"
1106
+ text_contents = text_path .read_text ().replace ("–" , "--" )
1107
+ expected_contents = """\
1108
+ Simple Module
1109
+ *************
1110
+
1111
+ dummy_module_simple.function(x: bool, y: int = 1) -> str
1112
+
1113
+ Function docstring.
1114
+
1115
+ Parameters:
1116
+ * **x** ("bool") -- foo
1117
+
1118
+ * **y** ("int") -- bar
1119
+
1120
+ Return type:
1121
+ "str"
1122
+ """
1123
+ assert text_contents == dedent (expected_contents )
0 commit comments