def FormatExtension(extension):
    'Format extension metadata as RST.\n\n  Args:\n    extension: the name of the extension, e.g. com.acme.foo.\n\n  Returns:\n    RST formatted extension description.\n  '
    try:
        extension_metadata = EXTENSION_DB[extension]
        anchor = FormatAnchor(('extension_' + extension))
        status = EXTENSION_STATUS_VALUES.get(extension_metadata['status'], '')
        security_posture = EXTENSION_SECURITY_POSTURES[extension_metadata['security_posture']]
        extension = EXTENSION_TEMPLATE.substitute(anchor=anchor, extension=extension, status=status, security_posture=security_posture)
        categories = FormatExtensionList(extension_metadata['categories'], 'extension_category')
        cat_or_cats = ('categories' if (len(categories) > 1) else 'category')
        category_message = f'This extension extends and can be used with the following extension {cat_or_cats}'
        extension_category = EXTENSION_CATEGORIES_TEMPLATE.substitute(message=category_message, categories=categories)
        return f'''{extension}

{extension_category}'''
    except KeyError as e:
        sys.stderr.write('\n\nDid you forget to add an entry to source/extensions/extensions_build_config.bzl?\n\n')
        exit(1)
Format extension metadata as RST.

Args:
  extension: the name of the extension, e.g. com.acme.foo.

Returns:
  RST formatted extension description.
def FormatExtension(extension):
    'Format extension metadata as RST.\n\n  Args:\n    extension: the name of the extension, e.g. com.acme.foo.\n\n  Returns:\n    RST formatted extension description.\n  '
    try:
        extension_metadata = EXTENSION_DB[extension]
        anchor = FormatAnchor(('extension_' + extension))
        status = EXTENSION_STATUS_VALUES.get(extension_metadata['status'], )
        security_posture = EXTENSION_SECURITY_POSTURES[extension_metadata['security_posture']]
        extension = EXTENSION_TEMPLATE.substitute(anchor=anchor, extension=extension, status=status, security_posture=security_posture)
        categories = FormatExtensionList(extension_metadata['categories'], 'extension_category')
        cat_or_cats = ('categories' if (len(categories) > 1) else 'category')
        category_message = f'This extension extends and can be used with the following extension {cat_or_cats}'
        extension_category = EXTENSION_CATEGORIES_TEMPLATE.substitute(message=category_message, categories=categories)
        return f'{extension}

{extension_category}'
    except KeyError as e:
        sys.stderr.write('\n\nDid you forget to add an entry to source/extensions/extensions_build_config.bzl?\n\n')
        exit(1)