code: def parse_rest_doc(doc):
      
  
      class Section(object):
          def __init__(self, header=None, body=None):
              self.header = header  # str
              self.body = body  # str
  
      doc_sections = OrderedDict([('', Section(header=''))])
      if not doc:
          return doc_sections
  
      doc = cleandoc(doc)
      lines = iter(doc.splitlines())
  
      header = ''
      body = []
      section = Section(header=header)
      line = ''
      while True:
          try:
              prev_line = line
              line = next(lines)
              # section header encountered
              if is_delimiter(line) and 0 < len(prev_line) <= len(line):
                  # prev-prev-line is overline
                  if len(body) >= 2 and len(body[-2]) == len(line) \
                          and body[-2][0] == line[0] and is_delimiter(body[-2]):
                      lim = -2
                  else:
                      lim = -1
  
                  section.body = "\n".join(body[:lim]).rstrip()
                  doc_sections.update([(header.strip(), section)])
                  section = Section(header="\n".join(body[lim:] + [line]))
                  header = prev_line
                  body = []
                  line = ''
              else:
                  body.append(line)
  
          except StopIteration:
              section.body = "\n".join(body).rstrip()
              doc_sections.update([(header.strip(), section)])
              break
      return doc_sections
docs: Extract the headers, delimiters, and text from reST-formatted docstrings.
  
          Parameters
          ----------
          doc: Union[str, None]
  
          Returns
          -------
          Dict[str, Section]