diff --git a/docs/source/conf.py b/docs/source/conf.py index e618f8d86..395302d62 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -83,7 +83,7 @@ def doc_redirect_include(file_path): }) # generate openapi -config = Configurator(settings={"weaver.wps": False, "weaver.wps_restapi": True}) +config = Configurator(settings={"weaver.wps": False, "weaver.wps_restapi": True, "weaver.build_docs": True}) config.include("weaver") # need to include package to apply decorators and parse routes api_spec_file = os.path.join(DOC_BLD_ROOT, "api.json") api_spec_json = get_swagger_json(http_host="example", http_scheme="https") diff --git a/weaver/database/__init__.py b/weaver/database/__init__.py index d95755ab6..e9774ece0 100644 --- a/weaver/database/__init__.py +++ b/weaver/database/__init__.py @@ -1,7 +1,9 @@ import logging from typing import TYPE_CHECKING -from weaver.utils import get_registry +from pyramid.settings import asbool + +from weaver.utils import get_registry, get_settings LOGGER = logging.getLogger(__name__) if TYPE_CHECKING: @@ -16,6 +18,11 @@ def get_db(container): def includeme(config): + settings = get_settings(config) + if asbool(settings.get("weaver.build_docs", True)): + LOGGER.info("Skipping database when building docs...") + return + LOGGER.info("Adding database...") from weaver.database.mongodb import MongoDatabase config.registry.db = MongoDatabase(config.registry)