diff --git a/src/doc_builder/style_doc.py b/src/doc_builder/style_doc.py index dcea7b39..16db64f2 100644 --- a/src/doc_builder/style_doc.py +++ b/src/doc_builder/style_doc.py @@ -31,8 +31,8 @@ _re_docstyle_ignore = re.compile(r"#\s*docstyle-ignore") # Re pattern that matches , and blocks. _re_tip = re.compile(r"^\s*|\s+warning={true}>)\s*$") -# Re pattern that matches blockquote tip markers: > [!NOTE], > [!TIP], > [!IMPORTANT], > [!WARNING], > [!CAUTION] -_re_blockquote_tip = re.compile(r"^\s*> \[!(?:NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$") +# Re pattern that catches markdown blockquote lines. +_re_blockquote_tip = re.compile(r"^\s*>\s?.*$") DOCTEST_PROMPTS = [">>>", "..."] diff --git a/tests/test_style_doc.py b/tests/test_style_doc.py index fce7cbec..4dd3a213 100644 --- a/tests/test_style_doc.py +++ b/tests/test_style_doc.py @@ -16,6 +16,7 @@ import unittest from doc_builder.style_doc import ( + _re_blockquote_tip, _re_code, _re_docstyle_ignore, _re_list, @@ -53,6 +54,11 @@ def test_re_tip(self): self.assertIsNotNone(_re_tip.search("")) self.assertIsNotNone(_re_tip.search(" ")) + def test_re_blockquote_tip(self): + self.assertIsNotNone(_re_blockquote_tip.search("> quoted line")) + self.assertIsNotNone(_re_blockquote_tip.search("> [!NOTE]")) + self.assertIsNotNone(_re_blockquote_tip.search(" > indented quoted line")) + def test_parse_code_example(self): # One code sample, no output self.assertEqual(parse_code_example(["code line 1", "code line 2"]), (["code line 1\ncode line 2"], [])) @@ -176,3 +182,25 @@ def test_format_docstring_handle_params_without_empty_line_after_description(sel """ self.assertEqual(style_docstring(test_docstring, 119)[0], expected_result) + + def test_format_docstring_keeps_markdown_callout_lines(self): + test_docstring = """Function description + +Params: + x (`int`): This is x. + +> [!NOTE] +> This is a note. +> This is still part of the note. +""" + expected_result = """Function description + +Params: + x (`int`): This is x. + +> [!NOTE] +> This is a note. +> This is still part of the note. +""" + + self.assertEqual(style_docstring(test_docstring, 119)[0], expected_result)