code: def get_documented_in_lines(lines, module=None, filename=None):
      """
      Find out what items are documented in the given lines
  
      Returns
      -------
      documented : dict of list of (filename, title, keyword, toctree)
          Dictionary whose keys are documented names of objects.
          The value is a list of locations where the object was documented.
          Each location is a tuple of filename, the current section title,
          the name of the directive, and the value of the :toctree: argument
          (if present) of the directive.
  
      """
      title_underline_re = re.compile("^[-=*_^#]{3,}\s*$")
      autodoc_re = re.compile(
          ".. auto(function|method|attribute|class|exception|module)::\s*([A-Za-z0-9_.]+)\s*$"
      )
      autosummary_re = re.compile(r"^\.\.\s+autosummary::\s*")
      module_re = re.compile(
          r"^\.\.\s+(current)?module::\s*([a-zA-Z0-9_.]+)\s*$"
      )
      autosummary_item_re = re.compile(
          r"^\s+([_a-zA-Z][a-zA-Z0-9_.]*)\s*.*?"
      )
      toctree_arg_re = re.compile(r"^\s+:toctree:\s*(.*?)\s*$")
  
      documented = {}
  
      current_title = []
      last_line = None
      toctree = None
      current_module = module
      in_autosummary = False
  
      for line in lines:
          try:
              if in_autosummary:
                  m = toctree_arg_re.match(line)
                  if m:
                      toctree = m.group(1)
                      continue
  
                  if line.strip().startswith(":"):
                      continue  # skip options
  
                  m = autosummary_item_re.match(line)
                  if m:
                      name = m.group(1).strip()
                      if current_module and not name.startswith(
                          current_module + "."
                      ):
                          name = f"{current_module}.{name}"
                      documented.setdefault(name, []).append(
                          (
                              filename,
                              current_title,
                              "autosummary",
                              toctree,
                          )
                      )
                      continue
                  if line.strip() == "":
                      continue
                  in_autosummary = False
  
              m = autosummary_re.match(line)
              if m:
                  in_autosummary = True
                  continue
  
              m = autodoc_re.search(line)
              if m:
                  name = m.group(2).strip()
                  if m.group(1) == "module":
                      current_module = name
                      documented.update(
                          get_documented_in_docstring(
                              name, filename=filename
                          )
                      )
                  elif current_module and not name.startswith(
                      current_module + "."
                  ):
                      name = f"{current_module}.{name}"
                  documented.setdefault(name, []).append(
                      (
                          filename,
                          current_title,
                          "auto" + m.group(1),
                          None,
                      )
                  )
                  continue
  
              m = title_underline_re.match(line)
              if m and last_line:
                  current_title = last_line.strip()
                  continue
  
              m = module_re.match(line)
              if m:
                  current_module = m.group(2)
                  continue
          finally:
              last_line = line
  
      return documented
  
file_path: nipy/doc/sphinxext/autosummary_generate.py
imports: import glob
  import inspect
  import optparse
  import os
  import pydoc
  import re
  from autosummary import import_by_name
label_desc: Use image node_id 6 for calling a global function with example usage: get_documented_in_lines(lines, module, filename) and returns: documented