Skip to content

Commit 2e40b00

Browse files
Fix style_docstring for blockquote tips (#645)
1 parent b1ca5ca commit 2e40b00

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/doc_builder/style_doc.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
_re_docstyle_ignore = re.compile(r"#\s*docstyle-ignore")
3232
# Re pattern that matches <Tip>, </Tip> and <Tip warning={true}> blocks.
3333
_re_tip = re.compile(r"^\s*</?Tip(>|\s+warning={true}>)\s*$")
34+
# Re pattern that matches blockquote tip markers: > [!NOTE], > [!TIP], > [!IMPORTANT], > [!WARNING], > [!CAUTION]
35+
_re_blockquote_tip = re.compile(r"^\s*> \[!(?:NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$")
3436

3537
DOCTEST_PROMPTS = [">>>", "..."]
3638

@@ -288,6 +290,7 @@ def style_docstring(docstring, max_len):
288290
code_search = _re_code.search(line)
289291
args_search = _re_args.search(line)
290292
tip_search = _re_tip.search(line)
293+
blockquote_tip_search = _re_blockquote_tip.search(line)
291294

292295
# Are we starting a new paragraph?
293296
# New indentation or new line:
@@ -298,6 +301,8 @@ def style_docstring(docstring, max_len):
298301
new_paragraph = new_paragraph or code_search is not None
299302
# Beginning/end of tip
300303
new_paragraph = new_paragraph or tip_search is not None
304+
# Beginning blockquote tip
305+
new_paragraph = new_paragraph or blockquote_tip_search is not None
301306
# Beginning of Args
302307
new_paragraph = new_paragraph or args_search is not None
303308

@@ -360,6 +365,8 @@ def style_docstring(docstring, max_len):
360365
# Add a new line after if not present
361366
if idx < len(lines) - 1 and not is_empty_line(lines[idx + 1]):
362367
new_lines.append("")
368+
elif blockquote_tip_search:
369+
new_lines.append(line)
363370
elif current_paragraph is None or find_indent(line) != current_indent:
364371
indent = find_indent(line)
365372
# Special behavior for parameters intros.

0 commit comments

Comments
 (0)