Skip to content

Commit d0f5b28

Browse files
committed
Fix inline warnings detection
1 parent f33026a commit d0f5b28

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

docstring_to_markdown/rst.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def __init__(self, pattern: str, replacement: str, name: Union[str, None] = None
2525
replacement=r'*Deprecated since \g<version>*\g<end>'
2626
),
2727
Directive(
28-
pattern=r'\.\. warning::/g',
29-
replacement=r'**Warning**'
28+
pattern=r'\.\. warning::',
29+
replacement=r'**Warning**:'
3030
),
3131
Directive(
3232
pattern=r'\.\. seealso::(?P<short_form>.*)(?P<end>$|\n)',

tests/test_rst.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,23 @@ def func(): pass
377377
"""
378378

379379

380+
LINE_WARNING = """
381+
Create a view into the array with the given shape and strides.
382+
383+
.. warning:: This function has to be used with extreme care, see notes.
384+
385+
Parameters
386+
"""
387+
388+
LINE_WARNING_MARKDOWN = """
389+
Create a view into the array with the given shape and strides.
390+
391+
**Warning**: This function has to be used with extreme care, see notes.
392+
393+
Parameters
394+
"""
395+
396+
380397
INTEGRATION = """
381398
Return a fixed frequency DatetimeIndex.
382399
@@ -458,10 +475,14 @@ def func(): pass
458475
'rst': CODE_BLOCK_BUT_NOT_OUTPUT,
459476
'md': CODE_BLOCK_BUT_NOT_OUTPUT_MD
460477
},
461-
'converts warnings': {
478+
'converts block warnings': {
462479
'rst': WARNING_BLOCK,
463480
'md': WARNING_BLOCK_MARKDOWN
464481
},
482+
'converts single-line warnings': {
483+
'rst': LINE_WARNING,
484+
'md': LINE_WARNING_MARKDOWN
485+
},
465486
'escapes double dunders': {
466487
# this is guaranteed to not be any rst markup as per
467488
# https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules

0 commit comments

Comments
 (0)