File tree Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 59
59
REST_REGEX = r"((\.{2}|`{2}) ?[\w.~-]+(:{2}|`{2})?[\w ]*?|`[\w.~]+`)"
60
60
"""Regular expression to use for finding reST directives."""
61
61
62
- SPHINX_REGEX = r":(param|raises|return|rtype|type)[a-zA-Z0-9_\-.() ]*:"
62
+ SPHINX_REGEX = r":(param|raises|return|rtype|type|yield )[a-zA-Z0-9_\-.() ]*:"
63
63
"""Regular expression to use for finding Sphinx-style field lists."""
64
64
65
65
URL_PATTERNS = (
Original file line number Diff line number Diff line change @@ -236,3 +236,17 @@ outstring='''"""CC.
236
236
237
237
c c :math:`[0, 1]`.
238
238
"""'''
239
+
240
+ [issue_253 ]
241
+ instring =''' """
242
+ My test fixture.
243
+
244
+ :param caplog: Pytest caplog fixture.
245
+ :yield: Until test complete, then run cleanup.
246
+ """'''
247
+ outstring =''' """
248
+ My test fixture.
249
+
250
+ :param caplog: Pytest caplog fixture.
251
+ :yield: Until test complete, then run cleanup.
252
+ """'''
Original file line number Diff line number Diff line change @@ -433,3 +433,42 @@ def test_format_docstring_sphinx_style_ignore_directive(
433
433
INDENTATION ,
434
434
instring ,
435
435
)
436
+
437
+ @pytest .mark .unit
438
+ @pytest .mark .parametrize (
439
+ "args" ,
440
+ [
441
+ [
442
+ "--wrap-descriptions" ,
443
+ "120" ,
444
+ "--wrap-summaries" ,
445
+ "120" ,
446
+ "--pre-summary-newline" ,
447
+ "--black" ,
448
+ "" ,
449
+ ]
450
+ ],
451
+ )
452
+ def test_format_docstring_sphinx_style_recognize_yield (
453
+ self ,
454
+ test_args ,
455
+ args ,
456
+ ):
457
+ """Should identify `yield` as sphinx field name.
458
+
459
+ See issue #253.
460
+ """
461
+ uut = Formatter (
462
+ test_args ,
463
+ sys .stderr ,
464
+ sys .stdin ,
465
+ sys .stdout ,
466
+ )
467
+
468
+ instring = self .TEST_STRINGS ["issue_253" ]["instring" ]
469
+ outstring = self .TEST_STRINGS ["issue_253" ]["outstring" ]
470
+
471
+ assert outstring == uut ._do_format_docstring (
472
+ INDENTATION ,
473
+ instring ,
474
+ )
You can’t perform that action at this time.
0 commit comments