'Formats the given `docstring` as Markdown and prints it to `f`.'

def _print_formatted_docstring(self, docstring, f):

    lines = self._remove_docstring_indent(docstring)
    i = 0
    def _at_start_of_section():
        'Returns    the    header    if    lines[i]    is    at    start    of    a    docstring    section.'
        l = lines[i]
        match = _section_re.match(l)
        if (match and ((i + 1) < len(lines)) and lines[(i + 1)].startswith('    ')):
            return match.group(1)
        else:
            return None
    while (i < len(lines)):
        l = lines[i]
        section_header = _at_start_of_section()
        if section_header:
            if ((i == 0) or lines[(i - 1)]):
                print('', file=f)
            print((('#####    ' + section_header) + ':'), file=f)
            print('', file=f)
            i += 1
            outputting_list = False
            while (i < len(lines)):
                l = lines[i]
                if _at_start_of_section():
                    break
                match = _arg_re.match(l)
                if match:
                    if (not outputting_list):
                        print('', file=f)
                        outputting_list = True
                    suffix = l[len(match.group()):].lstrip()
                    print(((('*        <b>`' + match.group(1)) + '`</b>:    ') + suffix), file=f)
                else:
                    outputting_list &= l.startswith('            ')
                    print(l, file=f)
                i += 1
        else:
            print(l, file=f)
            i += 1
