From ccd53253d1bdbf0ac1be7ad21be52e7a59a54364 2022-06-16 18:57:09 From: Tom Nicholas <35968931+TomNicholas@users.noreply.github.com> Date: 2022-06-16 18:57:09 Subject: [PATCH] Don't strip decorators before feeding into block_parser (#13612) make sure only pseudo-decorators are stripped before feeding into block_parser --- diff --git a/IPython/sphinxext/ipython_directive.py b/IPython/sphinxext/ipython_directive.py index 18bdfca..b1f3931 100644 --- a/IPython/sphinxext/ipython_directive.py +++ b/IPython/sphinxext/ipython_directive.py @@ -821,8 +821,11 @@ class EmbeddedSphinxShell(object): output.append(line) continue - # handle decorators - if line_stripped.startswith('@'): + # handle pseudo-decorators, whilst ensuring real python decorators are treated as input + if any( + line_stripped.startswith("@" + pseudo_decorator) + for pseudo_decorator in PSEUDO_DECORATORS + ): output.extend([line]) if 'savefig' in line: savefig = True # and need to clear figure diff --git a/docs/source/whatsnew/pr/stripping-decorators-bug.rst b/docs/source/whatsnew/pr/stripping-decorators-bug.rst new file mode 100644 index 0000000..2ea03d7 --- /dev/null +++ b/docs/source/whatsnew/pr/stripping-decorators-bug.rst @@ -0,0 +1,4 @@ +Stripping decorators bug +======================== + +Fixed bug which meant that ipython code blocks in restructured text documents executed with the ipython-sphinx extension skipped any lines of code containing python decorators.