code: def get_docstring_and_rest(filename):
      """Separate `filename` content between docstring and the rest
  
      Strongly inspired from ast.get_docstring.
  
      Returns
      -------
      docstring: str
          docstring of `filename`
      rest: str
          `filename` content without the docstring
      """
      # can't use codecs.open(filename, 'r', 'utf-8') here b/c ast doesn't
      # seem to work with unicode strings in Python2.7
      # "SyntaxError: encoding declaration in Unicode string"
      with open(filename, "rb") as fid:
          content = fid.read()
      # change from Windows format to UNIX for uniformity
      content = content.replace(b"\r\n", b"\n")
  
      try:
          node = ast.parse(content)
      except SyntaxError:
          return SYNTAX_ERROR_DOCSTRING, content.decode("utf-8"), 1
  
      if not isinstance(node, ast.Module):
          raise TypeError(
              "This function only supports modules. "
              "You provided {0}".format(node.__class__.__name__)
          )
      if (
          node.body
          and isinstance(node.body[0], ast.Expr)
          and isinstance(node.body[0].value, ast.Str)
      ):
          docstring_node = node.body[0]
          docstring = docstring_node.value.s
          if hasattr(docstring, "decode"):  # python2.7
              docstring = docstring.decode("utf-8")
          lineno = docstring_node.lineno  # The last line of the string.
          # This get the content of the file after the docstring last line
          # Note: 'maxsplit' argument is not a keyword argument in python2
          rest = content.decode("utf-8").split("\n", lineno)[-1]
          return docstring, rest, lineno + 1
      else:
          raise ValueError(
              (
                  'Could not find docstring in file "{0}". '
                  "A docstring is required by sphinx-gallery"
              ).format(filename)
          )
  
imports: from __future__ import division, absolute_import, print_function
  import ast
  import re
  from textwrap import dedent
label_desc: Use image node_id 1 for calling a global function with example usage: get_docstring_and_rest(filename) and returns: docstring,  rest,  unknown, SYNTAX_ERROR_DOCSTRING,  content,  int