#!/usr/bin/env python3
"""{{ machine_name }} Sphinx extension."""
from __future__ import annotations

from typing import Any, Dict

from sphinx.application import Sphinx


def setup(app: Sphinx) -> Dict[str, Any]:
    """Register the {{ machine_name }} extension with Sphinx."""
    app.setup_extension('byteb4rb1e.sphinxcontrib.h5p.core')
{% for dep in deps %}
    app.setup_extension('{{ dep.pip_name }}')
{% endfor %}

    # Static asset registration (build-generated)
    try:
        from ._generated import register_assets
        register_assets(app)
    except ImportError:
        pass

    # Content type directives: manual override → generated fallback
    try:
        from . import directives
        directives.register(app)
    except ImportError:
        try:
            from ._generated import directive
            directive.register(app)
        except ImportError:
            pass

    return {
        'parallel_read_safe': True,
        'parallel_write_safe': True,
    }
