diff --git a/docs/conf.py b/docs/conf.py index f3faf6f3a1..bf6ae09989 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,8 +4,6 @@ # Add the project root to the path so we can import the package sys.path.insert(0, os.path.abspath("../")) -from docs.generate_mappings import generate_mapping_docs # noqa: E402 - # Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: @@ -51,4 +49,30 @@ "footer_start": ["copyright"], } -generate_mapping_docs() + +def setup(app): + """ + Sphinx setup function that runs after configuration is loaded and dependencies are installed. + This generates mapping docs by importing and calling generate_mapping_docs() lazily. + """ + try: + from docs.generate_mappings import generate_mapping_docs # noqa: E402 + + # Get the directory where conf.py is located (docs/ directory) + docs_dir = os.path.dirname(os.path.abspath(__file__)) + templates_dir = os.path.join(docs_dir, "templates") + output_dir = os.path.join(docs_dir, "profiles") + + # Generate the mapping docs - this will create the profile documentation pages + generate_mapping_docs(templates_dir=templates_dir, output_dir=output_dir) + except (ImportError, ModuleNotFoundError) as e: + # If Airflow is not available, skip generating mapping docs + # This can happen during local development if dependencies aren't installed + import warnings + + warnings.warn( + f"Could not generate mapping docs: {e}. " + "Make sure Airflow is installed (pip install -r docs/requirements.txt). " + "Documentation will be built without profile mapping pages.", + UserWarning, + )