docs: def generate_example_rst(app):
      """ Generate the list of examples, as well as the contents of
          examples.
      """
      root_dir = os.path.join(app.builder.srcdir, 'auto_examples')
      example_dir = os.path.abspath(app.builder.srcdir + '/../' + 'examples')
      try:
          plot_gallery = eval(app.builder.config.plot_gallery)
      except TypeError:
          plot_gallery = bool(app.builder.config.plot_gallery)
      if not os.path.exists(example_dir):
          os.makedirs(example_dir)
      if not os.path.exists(root_dir):
          os.makedirs(root_dir)
  
      # we create an index.rst with all examples
      fhindex = file(os.path.join(root_dir, 'index.rst'), 'w')
      #Note: The sidebar button has been removed from the examples page for now
      #      due to how it messes up the layout. Will be fixed at a later point
      fhindex.write("""\
  
  .. raw:: html
  
  
      <style type="text/css">
  
      div#sidebarbutton {
          display: none;
      }
  
      .figure {
          float: left;
          margin: 10px;
          width: auto;
          height: 200px;
          width: 180px;
      }
  
      .figure img {
          display: inline;
          }
  
      .figure .caption {
          width: 170px;
          text-align: center !important;
      }
      </style>
  
  .. _examples-index:
  
  Examples
  ========
  
  """)
      # Here we don't use an os.walk, but we recurse only twice: flat is
      # better than nested.
      generate_dir_rst('.', fhindex, example_dir, root_dir, plot_gallery)
      for dir in sorted(os.listdir(example_dir)):
          if os.path.isdir(os.path.join(example_dir, dir)):
              generate_dir_rst(dir, fhindex, example_dir, root_dir, plot_gallery)
      fhindex.flush()