(app)
Load AutoAPI data from the filesystem.
Load AutoAPI data from the filesystem.
Load AutoAPI data from the filesystem .
def run_autoapi(app):  # pylint: disable=too-many-branches
    """
    Load AutoAPI data from the filesystem.
    """
    if app.config.autoapi_type not in LANGUAGE_MAPPERS:
        raise ExtensionError(
            "Invalid autoapi_type setting, "
            "following values is allowed: {}".format(
                ", ".join(
                    '"{}"'.format(api_type) for api_type in sorted(LANGUAGE_MAPPERS)
                )
            )
        )

    if not app.config.autoapi_dirs:
        raise ExtensionError("You must configure an autoapi_dirs setting")

    if app.config.autoapi_include_summaries is not None:
        warnings.warn(
            "autoapi_include_summaries has been replaced by "
            "the show-module-summary AutoAPI option\n",
            RemovedInAutoAPI2Warning,
        )
        if app.config.autoapi_include_summaries:
            app.config.autoapi_options.append("show-module-summary")

    # Make sure the paths are full
    normalised_dirs = _normalise_autoapi_dirs(app.config.autoapi_dirs, app.srcdir)
    for _dir in normalised_dirs:
        if not os.path.exists(_dir):
            raise ExtensionError(
                "AutoAPI Directory `{dir}` not found. "
                "Please check your `autoapi_dirs` setting.".format(dir=_dir)
            )

    normalized_root = os.path.normpath(
        os.path.join(app.srcdir, app.config.autoapi_root)
    )
    url_root = os.path.join("/", app.config.autoapi_root)

    if not all(
        import_name in sys.modules
        for _, import_name in LANGUAGE_REQUIREMENTS[app.config.autoapi_type]
    ):
        raise ExtensionError(
            "AutoAPI of type `{type}` requires following "
            "packages to be installed and included in extensions list: "
            "{packages}".format(
                type=app.config.autoapi_type,
                packages=", ".join(
                    '{import_name} (available as "{pkg_name}" on PyPI)'.format(
                        pkg_name=pkg_name, import_name=import_name
                    )
                    for pkg_name, import_name in LANGUAGE_REQUIREMENTS[
                        app.config.autoapi_type
                    ]
                ),
            )
        )

    sphinx_mapper = LANGUAGE_MAPPERS[app.config.autoapi_type]
    template_dir = app.config.autoapi_template_dir
    if template_dir and not os.path.isabs(template_dir):
        if not os.path.isdir(template_dir):
            template_dir = os.path.join(app.srcdir, app.config.autoapi_template_dir)
        elif app.srcdir != os.getcwd():
            warnings.warn(
                "autoapi_template_dir will be expected to be "
                "relative to the Sphinx source directory instead of "
                "relative to where sphinx-build is run\n",
                RemovedInAutoAPI2Warning,
            )
    sphinx_mapper_obj = sphinx_mapper(app, template_dir=template_dir, url_root=url_root)

    if app.config.autoapi_file_patterns:
        file_patterns = app.config.autoapi_file_patterns
    else:
        file_patterns = DEFAULT_FILE_PATTERNS.get(app.config.autoapi_type, [])

    if app.config.autoapi_ignore:
        ignore_patterns = app.config.autoapi_ignore
    else:
        ignore_patterns = DEFAULT_IGNORE_PATTERNS.get(app.config.autoapi_type, [])

    if ".rst" in app.config.source_suffix:
        out_suffix = ".rst"
    elif ".txt" in app.config.source_suffix:
        out_suffix = ".txt"
    else:
        # Fallback to first suffix listed
        out_suffix = app.config.source_suffix[0]

    if sphinx_mapper_obj.load(
        patterns=file_patterns, dirs=normalised_dirs, ignore=ignore_patterns
    ):
        sphinx_mapper_obj.map(options=app.config.autoapi_options)

        if app.config.autoapi_generate_api_docs:
            sphinx_mapper_obj.output_rst(root=normalized_root, source_suffix=out_suffix)
def run_autoapi ( app ) : # pylint: disable=too-many-branches if app . config . autoapi_type not in LANGUAGE_MAPPERS : raise ExtensionError ( "Invalid autoapi_type setting, " "following values is allowed: {}" . format ( ", " . join ( '"{}"' . format ( api_type ) for api_type in sorted ( LANGUAGE_MAPPERS ) ) ) ) if not app . config . autoapi_dirs : raise ExtensionError ( "You must configure an autoapi_dirs setting" ) if app . config . autoapi_include_summaries is not None : warnings . warn ( "autoapi_include_summaries has been replaced by " "the show-module-summary AutoAPI option\n" , RemovedInAutoAPI2Warning , ) if app . config . autoapi_include_summaries : app . config . autoapi_options . append ( "show-module-summary" ) # Make sure the paths are full normalised_dirs = _normalise_autoapi_dirs ( app . config . autoapi_dirs , app . srcdir ) for _dir in normalised_dirs : if not os . path . exists ( _dir ) : raise ExtensionError ( "AutoAPI Directory `{dir}` not found. " "Please check your `autoapi_dirs` setting." . format ( dir = _dir ) ) normalized_root = os . path . normpath ( os . path . join ( app . srcdir , app . config . autoapi_root ) ) url_root = os . path . join ( "/" , app . config . autoapi_root ) if not all ( import_name in sys . modules for _ , import_name in LANGUAGE_REQUIREMENTS [ app . config . autoapi_type ] ) : raise ExtensionError ( "AutoAPI of type `{type}` requires following " "packages to be installed and included in extensions list: " "{packages}" . format ( type = app . config . autoapi_type , packages = ", " . join ( '{import_name} (available as "{pkg_name}" on PyPI)' . format ( pkg_name = pkg_name , import_name = import_name ) for pkg_name , import_name in LANGUAGE_REQUIREMENTS [ app . config . autoapi_type ] ) , ) ) sphinx_mapper = LANGUAGE_MAPPERS [ app . config . autoapi_type ] template_dir = app . config . autoapi_template_dir if template_dir and not os . path . isabs ( template_dir ) : if not os . path . isdir ( template_dir ) : template_dir = os . path . join ( app . srcdir , app . config . autoapi_template_dir ) elif app . srcdir != os . getcwd ( ) : warnings . warn ( "autoapi_template_dir will be expected to be " "relative to the Sphinx source directory instead of " "relative to where sphinx-build is run\n" , RemovedInAutoAPI2Warning , ) sphinx_mapper_obj = sphinx_mapper ( app , template_dir = template_dir , url_root = url_root ) if app . config . autoapi_file_patterns : file_patterns = app . config . autoapi_file_patterns else : file_patterns = DEFAULT_FILE_PATTERNS . get ( app . config . autoapi_type , [ ] ) if app . config . autoapi_ignore : ignore_patterns = app . config . autoapi_ignore else : ignore_patterns = DEFAULT_IGNORE_PATTERNS . get ( app . config . autoapi_type , [ ] ) if ".rst" in app . config . source_suffix : out_suffix = ".rst" elif ".txt" in app . config . source_suffix : out_suffix = ".txt" else : # Fallback to first suffix listed out_suffix = app . config . source_suffix [ 0 ] if sphinx_mapper_obj . load ( patterns = file_patterns , dirs = normalised_dirs , ignore = ignore_patterns ) : sphinx_mapper_obj . map ( options = app . config . autoapi_options ) if app . config . autoapi_generate_api_docs : sphinx_mapper_obj . output_rst ( root = normalized_root , source_suffix = out_suffix )