diff --git a/docs/components_page/__init__.py b/docs/components_page/__init__.py index cc2d9f6b4..bca4b1aa6 100644 --- a/docs/components_page/__init__.py +++ b/docs/components_page/__init__.py @@ -1,3 +1,4 @@ +import os from pathlib import Path import dash @@ -9,6 +10,8 @@ from .components.tabs.simple import tab1_content, tab2_content from .markdown_parser import parse +SERVE_LOCALLY = os.getenv("DBC_DOCS_MODE", "production") == "dev" + HERE = Path(__file__).parent COMPONENTS = HERE / "components" TEMPLATES = HERE.parent / "templates" @@ -130,7 +133,7 @@ def register_apps(): external_stylesheets=["/static/loading.css"], requests_pathname_prefix=f"/docs/components/{slug}/", suppress_callback_exceptions=True, - serve_locally=False, + serve_locally=SERVE_LOCALLY, index_string=template.render( sidenav_items=sidenav_items, sidenav_active="components", diff --git a/docs/examples/__init__.py b/docs/examples/__init__.py index 72588c5d9..441a15076 100644 --- a/docs/examples/__init__.py +++ b/docs/examples/__init__.py @@ -9,6 +9,8 @@ from .vendor.graphs_in_tabs import app as git_app from .vendor.iris import app as iris_app +SERVE_LOCALLY = os.getenv("DBC_DOCS_MODE", "production") == "dev" + HREF_PATTERN = re.compile(r'href="') HERE = Path(__file__).parent @@ -73,7 +75,7 @@ def build_app_from_example(app, name, code, code_link, show_warning=False): new_app = dash.Dash( external_stylesheets=["/static/loading.css", dbc.themes.BOOTSTRAP], requests_pathname_prefix=f"/examples/{name}/", - serve_locally=False, + serve_locally=SERVE_LOCALLY, index_string=template.replace("", code), update_title=None, ) diff --git a/docs/run.py b/docs/run.py index dfddce290..1b437fea1 100644 --- a/docs/run.py +++ b/docs/run.py @@ -16,6 +16,9 @@ ) if __name__ == "__main__": + import os + from werkzeug.serving import run_simple + os.environ["DBC_DOCS_MODE"] = "dev" run_simple("localhost", 8888, application, use_reloader=True)