@@ -112,15 +112,25 @@ def _treat_string(
112
112
quotes_length : Literal [1 , 3 ],
113
113
) -> str :
114
114
"""Return a modified string."""
115
- # TODO(#67): Handle identation at the end of a summary a little better
116
-
117
115
# Split summary and description
118
116
if "\n \n " in tokeninfo .string :
119
117
summary , description = tokeninfo .string .split ("\n \n " , maxsplit = 1 )
118
+
119
+ # Remove final indentation, ending quotes and new line
120
120
description = description [:- quotes_length ]
121
+ if indent_length and description .endswith (indent_length * " " ):
122
+ description = description [:- indent_length ]
123
+ if description .endswith ("\n " ):
124
+ description = description [:- 1 ]
121
125
else :
122
126
summary , description = tokeninfo .string , None
127
+
128
+ # Remove final indentation, ending quotes and new line
123
129
summary = summary [:- quotes_length ]
130
+ if indent_length and summary .endswith (indent_length * " " ):
131
+ summary = summary [:- indent_length ]
132
+ if summary .endswith ("\n " ):
133
+ summary = summary [:- 1 ]
124
134
125
135
# Remove opening quotes
126
136
summary = summary [quotes_length :]
@@ -131,4 +141,8 @@ def _treat_string(
131
141
docstring = f"{ quotes } { new_summary } "
132
142
if description :
133
143
docstring += f"\n \n { description } "
144
+
145
+ # Determine whether ending quotes were initially on same or new line
146
+ if tokeninfo .string .splitlines ()[- 1 ] == indent_length * " " + quotes :
147
+ return f"{ docstring } \n { indent_length * ' ' } { quotes } "
134
148
return f"{ docstring } { quotes } "
0 commit comments