From 255e6cc42a9346fd9a7b72a17e1a06a0d3259592 Mon Sep 17 00:00:00 2001 From: Jack McCluskey Date: Thu, 10 Oct 2024 16:19:17 -0400 Subject: [PATCH] fix edge case --- sdks/python/apache_beam/dataframe/frame_base.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sdks/python/apache_beam/dataframe/frame_base.py b/sdks/python/apache_beam/dataframe/frame_base.py index 90f34d45dd98..3b9755232e80 100644 --- a/sdks/python/apache_beam/dataframe/frame_base.py +++ b/sdks/python/apache_beam/dataframe/frame_base.py @@ -606,6 +606,21 @@ def wrap(func): " :skipif: True"), re.sub(r"^", " ", content, flags=re.MULTILINE), ]) + elif "Examples" in content and ">>>" in content: + # some new examples don't have the correct heading + # this catches those examples + split_content = content.split("Examples") + content = '\n\n'.join([ + split_content[0], + "Examples\n", + # Indent the code snippet under a doctest heading, + # add skipif option. This makes sure our doctest + # framework doesn't run these pandas tests. + (".. doctest::\n" + " :skipif: True"), + re.sub(r"^", " ", content, flags=re.MULTILINE), + split_content[1] + ]) else: content = content.replace('DataFrame', 'DeferredDataFrame').replace( 'Series', 'DeferredSeries')