code: def _to_docstring(doc):
      
  
      def format_fn(line, status):
          """ format function """
          # swap &lt; &gt; to < >
          line = re_to_tag.sub(r"<\1>", line)
          if re_to_data.match(line):
              line = re_to_data.sub(r"@\1 ", line)
              status["eat_line"] = True
          line = re_to_defaults.sub(r"\1", line)
          if status["listing"]:
              # parameters
              if re_to_param.match(line):
                  line = re_to_param.sub(r"    \1: ", line)
              # status items
              elif re_to_status.match(line):
                  line = re_to_status.sub(r"    \1 ", line)
              # bullets
              elif re_to_item.match(line):
                  line = re_to_item.sub(r"    -", line)
              # is continuation line
              else:
                  line = " " * 8 + line.lstrip()
          return line
  
      return _reformat_docstring(doc, format_fn)
docs: format from Markdown to docstring