File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -235,12 +235,21 @@ def get_class_variables(cls: type) -> OrderedDict:
235
235
if token ['token' ].strip () == '' :
236
236
continue
237
237
238
- # Extract multiline comments
238
+ # Extract multiline comments in triple quote
239
239
if (class_variable is not None
240
240
and token ['token_type' ] == tokenize .STRING
241
241
and token ['token' ][:3 ] in {'"""' , "'''" }):
242
242
sep = ' ' if variable_to_comment [class_variable ]['comment' ] else ''
243
243
variable_to_comment [class_variable ]['comment' ] += sep + token ['token' ][3 :- 3 ].strip ()
244
+ continue
245
+
246
+ # Extract multiline comments in single quote
247
+ if (class_variable is not None
248
+ and token ['token_type' ] == tokenize .STRING
249
+ and token ['token' ][:1 ] in {'"' , "'" }):
250
+ sep = ' ' if variable_to_comment [class_variable ]['comment' ] else ''
251
+ variable_to_comment [class_variable ]['comment' ] += sep + token ['token' ][1 :- 1 ].strip ()
252
+ continue
244
253
245
254
# Match class variable
246
255
class_variable = None
Original file line number Diff line number Diff line change @@ -281,13 +281,30 @@ class TrickyMultiline:
281
281
class_variables ['foo' ] = {'comment' : comment }
282
282
self .assertEqual (get_class_variables (TrickyMultiline ), class_variables )
283
283
284
+ def test_triple_quote_multiline (self ):
285
+ class TripleQuoteMultiline :
286
+ bar : int = 0
287
+ '''biz baz'''
288
+
289
+ hi : str
290
+ """Hello there"""
291
+
292
+ class_variables = OrderedDict ()
293
+ class_variables ['bar' ] = {'comment' : 'biz baz' }
294
+ class_variables ['hi' ] = {'comment' : 'Hello there' }
295
+ self .assertEqual (get_class_variables (TripleQuoteMultiline ), class_variables )
296
+
284
297
def test_single_quote_multiline (self ):
285
298
class SingleQuoteMultiline :
286
299
bar : int = 0
287
- '''biz baz'''
300
+ 'biz baz'
301
+
302
+ hi : str
303
+ "Hello there"
288
304
289
305
class_variables = OrderedDict ()
290
306
class_variables ['bar' ] = {'comment' : 'biz baz' }
307
+ class_variables ['hi' ] = {'comment' : 'Hello there' }
291
308
self .assertEqual (get_class_variables (SingleQuoteMultiline ), class_variables )
292
309
293
310
def test_functions_with_docs_multiline (self ):
You can’t perform that action at this time.
0 commit comments