@@ -89,11 +89,16 @@ def read_parameters_section(
89
89
if signature_param .default is not empty :
90
90
default = signature_param .default
91
91
kind = signature_param .kind
92
+
93
+ description = param .description or ""
94
+ if not description :
95
+ self .error (f"No description for parameter '{ name } '" )
96
+
92
97
parameters .append (
93
98
Parameter (
94
99
name = param .arg_name ,
95
100
annotation = type_name ,
96
- description = param . description ,
101
+ description = description ,
97
102
default = default ,
98
103
kind = kind ,
99
104
)
@@ -124,6 +129,9 @@ def read_attributes_section(
124
129
docstring_attributes = [p for p in docstring_obj .params if p .args [0 ] == "attribute" ]
125
130
126
131
for attr in docstring_attributes :
132
+ description = attr .description or ""
133
+ if not description :
134
+ self .error (f"No description for attribute '{ attr .arg_name } '" )
127
135
attributes .append (
128
136
Attribute (
129
137
name = attr .arg_name ,
@@ -157,7 +165,10 @@ def read_exceptions_section(
157
165
except_obj = docstring_obj .raises
158
166
159
167
for exception in except_obj :
160
- exceptions .append (AnnotatedObject (exception .type_name , exception .description ))
168
+ description = exception .description or ""
169
+ if not description :
170
+ self .error (f"No description for exception '{ exception .type_name } '" )
171
+ exceptions .append (AnnotatedObject (exception .type_name , description ))
161
172
162
173
if exceptions :
163
174
return Section (Section .Type .EXCEPTIONS , exceptions )
@@ -178,26 +189,31 @@ def read_return_section(
178
189
Returns:
179
190
A `Section` object (or `None` if section is empty).
180
191
"""
181
- return_obj = docstring_obj .returns if docstring_obj .returns else []
182
- text = return_obj .description if return_obj else ""
183
-
184
- if self .context ["signature" ]:
185
- annotation = self .context ["signature" ].return_annotation
186
- else :
187
- annotation = self .context ["annotation" ]
188
-
189
- if annotation is empty :
190
- if text :
191
- annotation = return_obj .type_name or empty
192
- text = return_obj .description
193
- elif return_obj and annotation is empty :
192
+ if docstring_obj .returns :
193
+ return_obj = docstring_obj .returns
194
+
195
+ if return_obj .description :
196
+ description = return_obj .description
197
+ else :
198
+ self .error ("Empty return description" )
199
+ description = ""
200
+
201
+ if self .context ["signature" ]:
202
+ annotation = self .context ["signature" ].return_annotation
203
+ else :
204
+ annotation = self .context ["annotation" ]
205
+
206
+ if annotation is empty and return_obj .type_name :
207
+ annotation = return_obj .type_name
208
+
209
+ if not annotation :
194
210
self .error ("No return type annotation" )
211
+ annotation = ""
195
212
196
- if return_obj and not text :
197
- self .error ("Empty return description" )
198
- if not return_obj or annotation is empty or not text :
199
- return None
200
- return Section (Section .Type .RETURN , AnnotatedObject (annotation , text ))
213
+ if annotation or description :
214
+ return Section (Section .Type .RETURN , AnnotatedObject (annotation , description ))
215
+
216
+ return None
201
217
202
218
def read_examples_section (
203
219
self ,
0 commit comments