class_docstr: An embedded IPython instance to run inside Sphinx
docstr: content is a list of strings. it is unedited directive content
  
  This runs it line by line in the InteractiveShell, prepends
  prompts as needed capturing stderr and stdout, then returns
  the content as a list as if it were ipython code
docstr_tok: ["content","is","a","list","of","strings",".","it","is","unedited","directive","content","This","runs","it","line","by","line","in","the","InteractiveShell",",","prepends","prompts","as","needed","capturing","stderr","and","stdout",",","then","returns","the","content","as","a","list","as","if","it","were","ipython","code"]
code: def process_pure_python(self, content):
      """
      content is a list of strings. it is unedited directive content
  
      This runs it line by line in the InteractiveShell, prepends
      prompts as needed capturing stderr and stdout, then returns
      the content as a list as if it were ipython code
      """
      output = []
      savefig = False  # keep up with this to clear figure
      multiline = False  # to handle line continuation
      multiline_start = None
      fmtin = self.promptin
  
      ct = 0
  
      for lineno, line in enumerate(content):
          line_stripped = line.strip()
          if not len(line):
              output.append(line)
              continue
  
          # 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
              continue
  
          # handle comments
          if line_stripped.startswith("#"):
              output.extend([line])
              continue
  
          # deal with lines checking for multiline
          continuation = "   %s:" % "".join(["."] * (len(str(ct)) + 2))
          if not multiline:
              modified = "%s %s" % (fmtin % ct, line_stripped)
              output.append(modified)
              ct += 1
              try:
                  ast.parse(line_stripped)
                  output.append("")
              except Exception:  # on a multiline
                  multiline = True
                  multiline_start = lineno
          else:  # still on a multiline
              modified = "%s %s" % (continuation, line)
              output.append(modified)
  
              # if the next line is indented, it should be part of multiline
              if len(content) > lineno + 1:
                  nextline = content[lineno + 1]
                  if len(nextline) - len(nextline.lstrip()) > 3:
                      continue
              try:
                  mod = ast.parse(
                      "\n".join(content[multiline_start : lineno + 1])
                  )
                  if isinstance(mod.body[0], ast.FunctionDef):
                      # check to see if we have the whole function
                      for element in mod.body[0].body:
                          if isinstance(element, ast.Return):
                              multiline = False
                  else:
                      output.append("")
                      multiline = False
              except Exception:
                  pass
  
          if savefig:  # clear figure if plotted
              self.ensure_pyplot()
              self.process_input_line("plt.clf()", store_history=False)
              self.clear_cout()
              savefig = False
  
      return output
  
imports: import atexit
  import errno
  import os
  import pathlib
  import re
  import sys
  import tempfile
  import ast
  import warnings
  import shutil
  from io import StringIO
  from docutils.parsers.rst import directives
  from docutils.parsers.rst import Directive
  from sphinx.util import logging
  from traitlets.config import Config
  from IPython import InteractiveShell
  from IPython.core.profiledir import ProfileDir
label_desc: Use image node_id 13 for calling the EmbeddedSphinxShell obj's underlying member method code with example usage: obj.process_pure_python(content) and returns: output