File tree Expand file tree Collapse file tree 7 files changed +90
-8
lines changed Expand file tree Collapse file tree 7 files changed +90
-8
lines changed Original file line number Diff line number Diff line change @@ -479,7 +479,6 @@ def _do_format_docstring( # noqa PLR0911
479
479
self .args .rest_section_adorns ,
480
480
self .args .style ,
481
481
)
482
- or _syntax .do_find_directives (summary )
483
482
or _syntax .do_find_links (summary )
484
483
):
485
484
# Something is probably not right with the splitting.
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":[a-zA-Z0-9_\-() ]*:"
62
+ SPHINX_REGEX = r":[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 @@ -302,3 +302,14 @@ from typing import Iterator
302
302
"""Don't remove this comment, it's cool."""
303
303
IMPORTANT_CONSTANT = "potato"
304
304
'''
305
+
306
+ [issue_243 ]
307
+ instring =''' def foo(bar):
308
+ """Return `foo` using `bar`. Description."""
309
+ '''
310
+ outstring =''' def foo(bar):
311
+ """Return `foo` using `bar`.
312
+
313
+ Description.
314
+ """
315
+ '''
Original file line number Diff line number Diff line change @@ -212,3 +212,14 @@ outstring='''"""Summary.
212
212
213
213
:param param: asdf
214
214
"""'''
215
+
216
+ [issue_245 ]
217
+ instring =''' """Some f.
218
+ :param a: Some param.
219
+ :raises my.package.MyReallySrsError: Bad things happened.
220
+ """'''
221
+ outstring =''' """Some f.
222
+
223
+ :param a: Some param.
224
+ :raises my.package.MyReallySrsError: Bad things happened.
225
+ """'''
Original file line number Diff line number Diff line change @@ -227,8 +227,8 @@ instring='''"""Locate and call the ``mpm`` CLI.
227
227
"""'''
228
228
outstring =''' """Locate and call the ``mpm`` CLI.
229
229
230
- The output must supports both `Xbar dialect
231
- <https://github.com/matryer/xbar-plugins/blob/main/CONTRIBUTING.md#plugin-api>`_
230
+ The output must supports both
231
+ `Xbar dialect <https://github.com/matryer/xbar-plugins/blob/main/CONTRIBUTING.md#plugin-api>`_
232
232
and `SwiftBar dialect <https://github.com/swiftbar/SwiftBar#plugin-api>`_.
233
233
"""'''
234
234
@@ -288,8 +288,7 @@ def sub_func_test():
288
288
289
289
[issue_157_8 ]
290
290
instring =''' def mixed_links():
291
- """Implements the minimal code necessary to locate and call the ``mpm`` CLI on the
292
- system.
291
+ """Implements the minimal code necessary to locate and call the ``mpm`` CLI on the system.
293
292
294
293
Once ``mpm`` is located, we can rely on it to produce the main output of the plugin.
295
294
@@ -331,8 +330,8 @@ By default we choose to exclude:
331
330
options set.
332
331
"""'''
333
332
outstring =''' def mixed_links():
334
- """Implements the minimal code necessary to locate and call the ``mpm`` CLI on the
335
- system.
333
+ """Implements the minimal code necessary to locate and call the ``mpm`` CLI
334
+ on the system.
336
335
337
336
Once ``mpm`` is located, we can rely on it to produce the main output of the plugin.
338
337
Original file line number Diff line number Diff line change @@ -420,3 +420,28 @@ def test_format_code_keep_newline_after_import(
420
420
assert outstring == uut ._do_format_code (
421
421
instring ,
422
422
)
423
+
424
+ @pytest .mark .unit
425
+ @pytest .mark .parametrize ("args" , [["" ]])
426
+ def test_format_code_with_backtick_in_summary (
427
+ self ,
428
+ test_args ,
429
+ args ,
430
+ ):
431
+ """Format docstring with summary containing backticks.
432
+
433
+ See issue #243.
434
+ """
435
+ uut = Formatter (
436
+ test_args ,
437
+ sys .stderr ,
438
+ sys .stdin ,
439
+ sys .stdout ,
440
+ )
441
+
442
+ instring = self .TEST_STRINGS ["issue_243" ]["instring" ]
443
+ outstring = self .TEST_STRINGS ["issue_243" ]["outstring" ]
444
+
445
+ assert outstring == uut ._do_format_code (
446
+ instring ,
447
+ )
Original file line number Diff line number Diff line change @@ -359,3 +359,40 @@ def test_format_docstring_sphinx_style_field_body_is_a_link(
359
359
INDENTATION ,
360
360
instring ,
361
361
)
362
+
363
+ @pytest .mark .unit
364
+ @pytest .mark .parametrize (
365
+ "args" ,
366
+ [
367
+ [
368
+ "--wrap-descriptions" ,
369
+ "88" ,
370
+ "--wrap-summaries" ,
371
+ "88" ,
372
+ "" ,
373
+ ]
374
+ ],
375
+ )
376
+ def test_format_docstring_sphinx_style_field_name_has_periods (
377
+ self ,
378
+ test_args ,
379
+ args ,
380
+ ):
381
+ """Should format sphinx field names containing a period.
382
+
383
+ See issue #245.
384
+ """
385
+ uut = Formatter (
386
+ test_args ,
387
+ sys .stderr ,
388
+ sys .stdin ,
389
+ sys .stdout ,
390
+ )
391
+
392
+ instring = self .TEST_STRINGS ["issue_245" ]["instring" ]
393
+ outstring = self .TEST_STRINGS ["issue_245" ]["outstring" ]
394
+
395
+ assert outstring == uut ._do_format_docstring (
396
+ INDENTATION ,
397
+ instring ,
398
+ )
You can’t perform that action at this time.
0 commit comments