code: def generate_markdown_doc(app_name, spec):
      
  
      # Apply standard headers.
      sections = [
          HEADER.format(app_name=app_name),
          SOURCES_HEADER.format(app_name=app_name)
      ]
  
      # Generate the sources section of the documentation
      sorted_labels = sorted(list(spec.sources))
      for label in sorted_labels:
          sections.append(
              _generate_source_section(label, spec.sources[label], app_name)
          )
  
      # Generate the config section.
      sections.append(CONFIG_HEADER.format(app_name=app_name))
      table_rows, item_sections = _generate_item_sections(
          _sorted_dict_values(spec.items),
          app_name
      )
  
      headers = {
          'name': 'Name',
          'type': 'Type',
          'default': 'Default',
          'description': 'Description'
      }
  
      sections.append(
          build_markdown_table(
              headers,
              table_rows,
              ['name', 'type', 'default', 'description'],
          )
      )
      for item_section in item_sections:
          sections.append(item_section)
  
      return '\n'.join([section for section in sections])
docs: 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.