docstr: Make a new demo object.  To run the demo, simply call the object.
  
  See the module docstring for full details and an example (you can use
  IPython.Demo? in IPython to see it).
  
  Inputs:
  
    - src is either a file, or file-like object, or a
        string that can be resolved to a filename.
  
  Optional inputs:
  
    - title: a string to use as the demo name.  Of most use when the demo
      you are making comes from an object that has no filename, or if you
      want an alternate denotation distinct from the filename.
  
    - arg_str(''): a string of arguments, internally converted to a list
      just like sys.argv, so the demo script can see a similar
      environment.
  
    - auto_all(None): global flag to run all blocks automatically without
      confirmation.  This attribute overrides the block-level tags and
      applies to the whole demo.  It is an attribute of the object, and
      can be changed at runtime simply by reassigning it to a boolean
      value.
  
    - format_rst(False): a bool to enable comments and doc strings
      formatting with pygments rst lexer
  
    - formatter('terminal'): a string of pygments formatter name to be
      used. Useful values for terminals: terminal, terminal256,
      terminal16m
  
    - style('default'): a string of pygments style name to be used.
docstr_tok: ["Make","a","new","demo","object",".","To","run","the","demo",",","simply","call","the","object",".","See","the","module","docstring","for","full","details","and","an","example","(","you","can","use","IPython.Demo","?","in","IPython","to","see","it",")",".","Inputs",":","-","src","is","either","a","file",",","or","file-like","object",",","or","a","string","that","can","be","resolved","to","a","filename",".","Optional","inputs",":","-","title",":","a","string","to","use","as","the","demo","name",".","Of","most","use","when","the","demo","you","are","making","comes","from","an","object","that","has","no","filename",",","or","if","you","want","an","alternate","denotation","distinct","from","the","filename",".","-","arg_str","(","``",")",":","a","string","of","arguments",",","internally","converted","to","a","list","just","like","sys.argv",",","so","the","demo","script","can","see","a","similar","environment",".","-","auto_all","(","None",")",":","global","flag","to","run","all","blocks","automatically","without","confirmation",".","This","attribute","overrides","the","block-level","tags","and","applies","to","the","whole","demo",".","It","is","an","attribute","of","the","object",",","and","can","be","changed","at","runtime","simply","by","reassigning","it","to","a","boolean","value",".","-","format_rst","(","False",")",":","a","bool","to","enable","comments","and","doc","strings","formatting","with","pygments","rst","lexer","-","formatter","(","'terminal","'",")",":","a","string","of","pygments","formatter","name","to","be","used",".","Useful","values","for","terminals",":","terminal",",","terminal256",",","terminal16m","-","style","(","'default","'",")",":","a","string","of","pygments","style","name","to","be","used","."]
code: def __init__(
      self,
      src,
      title="",
      arg_str="",
      auto_all=None,
      format_rst=False,
      formatter="terminal",
      style="default",
  ):
      """Make a new demo object.  To run the demo, simply call the object.
  
      See the module docstring for full details and an example (you can use
      IPython.Demo? in IPython to see it).
  
      Inputs:
  
        - src is either a file, or file-like object, or a
            string that can be resolved to a filename.
  
      Optional inputs:
  
        - title: a string to use as the demo name.  Of most use when the demo
          you are making comes from an object that has no filename, or if you
          want an alternate denotation distinct from the filename.
  
        - arg_str(''): a string of arguments, internally converted to a list
          just like sys.argv, so the demo script can see a similar
          environment.
  
        - auto_all(None): global flag to run all blocks automatically without
          confirmation.  This attribute overrides the block-level tags and
          applies to the whole demo.  It is an attribute of the object, and
          can be changed at runtime simply by reassigning it to a boolean
          value.
  
        - format_rst(False): a bool to enable comments and doc strings
          formatting with pygments rst lexer
  
        - formatter('terminal'): a string of pygments formatter name to be
          used. Useful values for terminals: terminal, terminal256,
          terminal16m
  
        - style('default'): a string of pygments style name to be used.
      """
      if hasattr(src, "read"):
          # It seems to be a file or a file-like object
          self.fname = "from a file-like object"
          if title == "":
              self.title = "from a file-like object"
          else:
              self.title = title
      else:
          # Assume it's a string or something that can be converted to one
          self.fname = src
          if title == "":
              (filepath, filename) = os.path.split(src)
              self.title = filename
          else:
              self.title = title
      self.sys_argv = [src] + shlex.split(arg_str)
      self.auto_all = auto_all
      self.src = src
  
      try:
          ip = (
              get_ipython()
          )  # this is in builtins whenever IPython is running
          self.inside_ipython = True
      except NameError:
          self.inside_ipython = False
  
      if self.inside_ipython:
          # get a few things from ipython.  While it's a bit ugly design-wise,
          # it ensures that things like color scheme and the like are always in
          # sync with the ipython mode being used.  This class is only meant to
          # be used inside ipython anyways,  so it's OK.
          self.ip_ns = ip.user_ns
          self.ip_colorize = ip.pycolorize
          self.ip_showtb = ip.showtraceback
          self.ip_run_cell = ip.run_cell
          self.shell = ip
  
      self.formatter = pygments.formatters.get_formatter_by_name(
          formatter, style=style
      )
      self.python_lexer = pygments.lexers.get_lexer_by_name("py3")
      self.format_rst = format_rst
      if format_rst:
          self.rst_lexer = pygments.lexers.get_lexer_by_name("rst")
  
      # load user data and initialize data structures
      self.reload()
  
imports: import os
  import re
  import shlex
  import sys
  import pygments
  from pathlib import Path
  from IPython.utils.text import marquee
  from IPython.utils import openpy
  from IPython.utils import py3compat
label_desc: Use image node_id 1 to create a new Demo object from inherited base classes: object with example: obj = Demo(src, title, arg_str, auto_all, format_rst, formatter, style)