code: def extract_summary(obj):
      # type: (List[unicode], Any) -> unicode
      
  
      try:
          doc = inspect.getdoc(obj).split("\n")
      except AttributeError:
          doc = ''
  
      # Skip a blank lines at the top
      while doc and not doc[0].strip():
          doc.pop(0)
  
      # If there's a blank line, then we can assume the first sentence /
      # paragraph has ended, so anything after shouldn't be part of the
      # summary
      for i, piece in enumerate(doc):
          if not piece.strip():
              doc = doc[:i]
              break
  
      # Try to find the "first sentence", which may span multiple lines
      sentences = periods_re.split(" ".join(doc))  # type: ignore
      if len(sentences) == 1:
          summary = sentences[0].strip()
      else:
          summary = ''
          state_machine = RSTStateMachine(state_classes, 'Body')
          while sentences:
              summary += sentences.pop(0) + '.'
              node = new_document('')
              node.reporter = NullReporter('', 999, 4)
              node.settings.pep_references = None
              node.settings.rfc_references = None
              state_machine.run([summary], node)
              if not node.traverse(nodes.system_message):
                  # considered as that splitting by period does not break inline
                  # markups
                  break
  
      return summary
docs: Extract summary from docstring.