def generate_markdown_doc(app_name, spec):
<EOL>sections = [<EOL>HEADER.format(app_name=app_name),<EOL>SOURCES_HEADER.format(app_name=app_name)<EOL>]<EOL>sorted_labels = sorted(list(spec.sources))<EOL>for label in sorted_labels:<EOL><INDENT>sections.append(<EOL>_generate_source_section(label, spec.sources[label], app_name)<EOL>)<EOL><DEDENT>sections.append(CONFIG_HEADER.format(app_name=app_name))<EOL>table_rows, item_sections = _generate_item_sections(<EOL>_sorted_dict_values(spec.items),<EOL>app_name<EOL>)<EOL>headers = {<EOL>'<STR_LIT:name>': '<STR_LIT:Name>',<EOL>'<STR_LIT:type>': '<STR_LIT>',<EOL>'<STR_LIT:default>': '<STR_LIT>',<EOL>'<STR_LIT:description>': '<STR_LIT>'<EOL>}<EOL>sections.append(<EOL>build_markdown_table(<EOL>headers,<EOL>table_rows,<EOL>['<STR_LIT:name>', '<STR_LIT:type>', '<STR_LIT:default>', '<STR_LIT:description>'],<EOL>)<EOL>)<EOL>for item_section in item_sections:<EOL><INDENT>sections.append(item_section)<EOL><DEDENT>return '<STR_LIT:\n>'.join([section for section in sections])<EOL>
Generate Markdown Documentation for the given spec/app name.

    Args:
        app_name (str): The name of the application.
        spec (YapconfSpec): A yapconf specification with sources loaded.

    Returns (str):
        A valid, markdown string representation of the documentation for
        the given specification.