Skip to content
Snippets Groups Projects
Commit 6bef7e61 authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

Merge branch 'feature/better_sphinx' into 'develop'

improve sphinx call to _create_app

See merge request !50
parents 7145b226 48fd2f70
Branches
Tags
1 merge request!50improve sphinx call to _create_app
......@@ -32,7 +32,7 @@ environment.setup_logging()
logger = logging.getLogger(__name__)
def _create_app(app_config) -> Flask:
def _create_app() -> Flask:
# used by sphinx to create documentation without config and db migrations
app = Flask(__name__)
CORS(app)
......@@ -46,11 +46,13 @@ def _create_app(app_config) -> Flask:
from compendium_v2.routes import api
app.register_blueprint(api.routes, url_prefix='/api')
if not app_config:
# workaround for sphinx causing app to be created, but not loading a config
return app
return app
def _create_app_with_db(app_config) -> Flask:
# used by the tests and the publishers
app = _create_app()
app.config['CONFIG_PARAMS'] = app_config
app.config['SECRET_KEY'] = app_config['SECRET_KEY']
app.config['SESSION_COOKIE_SECURE'] = True
if 'oidc' not in app_config:
......@@ -59,17 +61,11 @@ def _create_app(app_config) -> Flask:
else:
logger.info('OIDC configuration found, authentication will be enabled')
return app
def _create_app_with_db(app_config) -> Flask:
# used by the tests and the publishers
app = _create_app(app_config)
app.config['SQLALCHEMY_DATABASE_URI'] = app.config['CONFIG_PARAMS']['SQLALCHEMY_DATABASE_URI']
app.config['SQLALCHEMY_DATABASE_URI'] = app_config['SQLALCHEMY_DATABASE_URI']
if 'SQLALCHEMY_BINDS' in app.config['CONFIG_PARAMS']:
if 'SQLALCHEMY_BINDS' in app_config:
# for the publishers
app.config['SQLALCHEMY_BINDS'] = app.config['CONFIG_PARAMS']['SQLALCHEMY_BINDS']
app.config['SQLALCHEMY_BINDS'] = app_config['SQLALCHEMY_BINDS']
db.init_app(app)
return app
......
......@@ -9,8 +9,8 @@ Responses to valid requests are returned as JSON messages.
The server will therefore return an error unless
`application/json` is in the `Accept` request header field.
.. qrefflask:: compendium_v2:_create_app(None)
.. qrefflask:: compendium_v2:_create_app()
:autoquickref:
.. autoflask:: compendium_v2:_create_app(None)
.. autoflask:: compendium_v2:_create_app()
:undoc-static:
......@@ -22,5 +22,5 @@ commands =
coverage report --fail-under 80
flake8
mypy {toxinidir}/compendium_v2/ {toxinidir}/test/
sphinx-build -M html docs/source docs/build
sphinx-build -M html docs/source docs/build -E
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment