diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples.py index 68c7a528a6..381f04b757 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples.py @@ -1195,6 +1195,20 @@ def markdown_over_indented(): pass +# This tests that we can have additional text after the language specifier. +def markdown_additional_info_string(): + """ + Do cool stuff. + + ```python tab="plugin.py" + cool_stuff( 1 ) + ``` + + Done. + """ + pass + + # Tests that an unclosed block gobbles up everything remaining in the # docstring, even if it isn't valid Python. Since it isn't valid Python, # reformatting fails and the entire thing is skipped. diff --git a/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples.py.snap index 7dc1badfe2..ce33622b63 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples.py.snap @@ -1201,6 +1201,20 @@ def markdown_over_indented(): pass +# This tests that we can have additional text after the language specifier. +def markdown_additional_info_string(): + """ + Do cool stuff. + + ```python tab="plugin.py" + cool_stuff( 1 ) + ``` + + Done. + """ + pass + + # Tests that an unclosed block gobbles up everything remaining in the # docstring, even if it isn't valid Python. Since it isn't valid Python, # reformatting fails and the entire thing is skipped. @@ -2556,6 +2570,20 @@ def markdown_over_indented(): pass +# This tests that we can have additional text after the language specifier. +def markdown_additional_info_string(): + """ + Do cool stuff. + + ```python tab="plugin.py" + cool_stuff( 1 ) + ``` + + Done. + """ + pass + + # Tests that an unclosed block gobbles up everything remaining in the # docstring, even if it isn't valid Python. Since it isn't valid Python, # reformatting fails and the entire thing is skipped. @@ -3911,6 +3939,20 @@ def markdown_over_indented(): pass +# This tests that we can have additional text after the language specifier. +def markdown_additional_info_string(): + """ + Do cool stuff. + + ```python tab="plugin.py" + cool_stuff( 1 ) + ``` + + Done. + """ + pass + + # Tests that an unclosed block gobbles up everything remaining in the # docstring, even if it isn't valid Python. Since it isn't valid Python, # reformatting fails and the entire thing is skipped. @@ -5266,6 +5308,20 @@ def markdown_over_indented(): pass +# This tests that we can have additional text after the language specifier. +def markdown_additional_info_string(): + """ + Do cool stuff. + + ```python tab="plugin.py" + cool_stuff( 1 ) + ``` + + Done. + """ + pass + + # Tests that an unclosed block gobbles up everything remaining in the # docstring, even if it isn't valid Python. Since it isn't valid Python, # reformatting fails and the entire thing is skipped. @@ -6621,6 +6677,20 @@ def markdown_over_indented(): pass +# This tests that we can have additional text after the language specifier. +def markdown_additional_info_string(): + """ + Do cool stuff. + + ```python tab="plugin.py" + cool_stuff( 1 ) + ``` + + Done. + """ + pass + + # Tests that an unclosed block gobbles up everything remaining in the # docstring, even if it isn't valid Python. Since it isn't valid Python, # reformatting fails and the entire thing is skipped. @@ -7971,6 +8041,20 @@ def markdown_over_indented(): pass +# This tests that we can have additional text after the language specifier. +def markdown_additional_info_string(): + """ + Do cool stuff. + + ```python tab="plugin.py" + cool_stuff(1) + ``` + + Done. + """ + pass + + # Tests that an unclosed block gobbles up everything remaining in the # docstring, even if it isn't valid Python. Since it isn't valid Python, # reformatting fails and the entire thing is skipped. @@ -9321,6 +9405,20 @@ def markdown_over_indented(): pass +# This tests that we can have additional text after the language specifier. +def markdown_additional_info_string(): + """ + Do cool stuff. + + ```python tab="plugin.py" + cool_stuff(1) + ``` + + Done. + """ + pass + + # Tests that an unclosed block gobbles up everything remaining in the # docstring, even if it isn't valid Python. Since it isn't valid Python, # reformatting fails and the entire thing is skipped. @@ -10671,6 +10769,20 @@ def markdown_over_indented(): pass +# This tests that we can have additional text after the language specifier. +def markdown_additional_info_string(): + """ + Do cool stuff. + + ```python tab="plugin.py" + cool_stuff(1) + ``` + + Done. + """ + pass + + # Tests that an unclosed block gobbles up everything remaining in the # docstring, even if it isn't valid Python. Since it isn't valid Python, # reformatting fails and the entire thing is skipped. @@ -12021,6 +12133,20 @@ def markdown_over_indented(): pass +# This tests that we can have additional text after the language specifier. +def markdown_additional_info_string(): + """ + Do cool stuff. + + ```python tab="plugin.py" + cool_stuff(1) + ``` + + Done. + """ + pass + + # Tests that an unclosed block gobbles up everything remaining in the # docstring, even if it isn't valid Python. Since it isn't valid Python, # reformatting fails and the entire thing is skipped.