<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_doc(name, thing, header_level, source_location):
 """ Generate markdown for a class or function Parameters name : str Name of the thing being documented thing : class or function Class or function to document header_level : int Heading level source_location : str URL of repo containing source code """


    if type(thing) is enum.EnumMeta:
        return enum_doc(name, thing, header_level, source_location)
    if inspect.isclass(thing):
        header = f"{'#'*header_level} Class **{name}**\n\n"
    else:
        header = f"{'#'*header_level} {name}\n\n"
    lines = [
        header,
        get_signature(name, thing),
        get_source_link(thing, source_location),
    ]

    try:
        doc = NumpyDocString(inspect.getdoc(thing))._parsed_data
        lines += summary(doc)
        lines += attributes_section(thing, doc, header_level)
        lines += params_section(thing, doc, header_level)
        lines += returns_section(thing, doc, header_level)
        lines += examples_section(doc, header_level)
        lines += notes_section(doc)
        lines += refs_section(doc)
    except Exception as e:
        # print(f"No docstring for {name}, src {source_location}: {e}")
        pass
    return lines