"""Central documentation hub configuration using sphinx-collections.

This configuration aggregates documentation from all packages into
a single unified documentation site.

Generated by pydevelop-docs for {{ project_name }}.
"""

import os
import sys
from pathlib import Path

# Add source path for imports
sys.path.insert(0, os.path.abspath("{{ source_path | default('..') }}"))

# Import the complete shared configuration
from pydevelop_docs.config import get_central_hub_config

# Get central hub configuration with sphinx-collections support
config = get_central_hub_config()

# Apply all configuration
globals().update(config)

# Project-specific overrides
project = "{{ project_name }}"
html_title = "{{ project_name }} Documentation Hub"

{% if collections_paths %}
# Override collections configuration for this project structure
collections = {
{% for collection_name, collection_config in collections_paths.items() %}
    "{{ collection_name }}": {
        "driver": "{{ collection_config.driver | default('copy_folder') }}",
        "source": "{{ collection_config.source }}",
        "target": "{{ collection_config.target }}",
        "active": {{ collection_config.active | default(True) | tojson }},
    },
{% endfor %}
}
{% endif %}

{% if custom_extensions %}
# Add project-specific extensions
if isinstance(extensions, list):
{% for ext in custom_extensions %}
    if "{{ ext }}" not in extensions:
        extensions.append("{{ ext }}")
{% endfor %}
{% endif %}

# Custom index for the hub
html_additional_pages = {
    "index": "hub_index.html",
}