class_docstr: Magics that provide central IPython functionality.
  
  These are various magics that don't fit into specific categories but that
  are all part of the base 'IPython experience'.
docstr: Toggle doctest mode on and off.
  
  This mode is intended to make IPython behave as much as possible like a
  plain Python shell, from the perspective of how its prompts, exceptions
  and output look.  This makes it easy to copy and paste parts of a
  session into doctests.  It does so by:
  
  - Changing the prompts to the classic ``>>>`` ones.
  - Changing the exception reporting mode to 'Plain'.
  - Disabling pretty-printing of output.
  
  Note that IPython also supports the pasting of code snippets that have
  leading '>>>' and '...' prompts in them.  This means that you can paste
  doctests from files or docstrings (even if they have leading
  whitespace), and the code will execute correctly.  You can then use
  '%history -t' to see the translated history; this will give you the
  input after removal of all the leading prompts and whitespace, which
  can be pasted back into an editor.
  
  With these features, you can switch into this mode easily whenever you
  need to do testing and changes to doctests, without having to leave
  your existing IPython session.
code: def doctest_mode(self, parameter_s=""):
      """Toggle doctest mode on and off.
  
      This mode is intended to make IPython behave as much as possible like a
      plain Python shell, from the perspective of how its prompts, exceptions
      and output look.  This makes it easy to copy and paste parts of a
      session into doctests.  It does so by:
  
      - Changing the prompts to the classic ``>>>`` ones.
      - Changing the exception reporting mode to 'Plain'.
      - Disabling pretty-printing of output.
  
      Note that IPython also supports the pasting of code snippets that have
      leading '>>>' and '...' prompts in them.  This means that you can paste
      doctests from files or docstrings (even if they have leading
      whitespace), and the code will execute correctly.  You can then use
      '%history -t' to see the translated history; this will give you the
      input after removal of all the leading prompts and whitespace, which
      can be pasted back into an editor.
  
      With these features, you can switch into this mode easily whenever you
      need to do testing and changes to doctests, without having to leave
      your existing IPython session.
      """
  
      # Shorthands
      shell = self.shell
      meta = shell.meta
      disp_formatter = self.shell.display_formatter
      ptformatter = disp_formatter.formatters["text/plain"]
      # dstore is a data store kept in the instance metadata bag to track any
      # changes we make, so we can undo them later.
      dstore = meta.setdefault("doctest_mode", Struct())
      save_dstore = dstore.setdefault
  
      # save a few values we'll need to recover later
      mode = save_dstore("mode", False)
      save_dstore("rc_pprint", ptformatter.pprint)
      save_dstore("xmode", shell.InteractiveTB.mode)
      save_dstore("rc_separate_out", shell.separate_out)
      save_dstore("rc_separate_out2", shell.separate_out2)
      save_dstore("rc_separate_in", shell.separate_in)
      save_dstore("rc_active_types", disp_formatter.active_types)
  
      if not mode:
          # turn on
  
          # Prompt separators like plain python
          shell.separate_in = ""
          shell.separate_out = ""
          shell.separate_out2 = ""
  
          ptformatter.pprint = False
          disp_formatter.active_types = ["text/plain"]
  
          shell.magic("xmode Plain")
      else:
          # turn off
          shell.separate_in = dstore.rc_separate_in
  
          shell.separate_out = dstore.rc_separate_out
          shell.separate_out2 = dstore.rc_separate_out2
  
          ptformatter.pprint = dstore.rc_pprint
          disp_formatter.active_types = dstore.rc_active_types
  
          shell.magic("xmode " + dstore.xmode)
  
      # mode here is the state before we switch; switch_doctest_mode takes
      # the mode we're switching to.
      shell.switch_doctest_mode(not mode)
  
      # Store new mode and inform
      dstore.mode = bool(not mode)
      mode_label = ["OFF", "ON"][dstore.mode]
      print("Doctest mode is:", mode_label)
  
imports: from __future__ import print_function
  from __future__ import absolute_import
  import argparse
  import io
  import sys
  from pprint import pformat
  from IPython.core import magic_arguments, page
  from IPython.core.error import UsageError
  from IPython.core.magic import Magics, magics_class, line_magic, magic_escapes
  from IPython.utils.text import format_screen, dedent, indent
  from IPython.testing.skipdoctest import skip_doctest
  from IPython.utils.ipstruct import Struct
  from IPython.utils.py3compat import unicode_type
  from warnings import warn
  from logging import error
label_desc: Use image node_id 11 for calling the BasicMagics obj's underlying member method code with example usage: obj.doctest_mode(parameter_s) without return types