mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Make registry use explicit when creating _DomainsContainer
This commit is contained in:
parent
c3968e9be9
commit
c6b4114cde
@ -22,6 +22,7 @@ if TYPE_CHECKING:
|
|||||||
from sphinx.environment import BuildEnvironment
|
from sphinx.environment import BuildEnvironment
|
||||||
from sphinx.ext.duration import DurationDomain
|
from sphinx.ext.duration import DurationDomain
|
||||||
from sphinx.ext.todo import TodoDomain
|
from sphinx.ext.todo import TodoDomain
|
||||||
|
from sphinx.registry import SphinxComponentRegistry
|
||||||
|
|
||||||
|
|
||||||
class _DomainsContainer:
|
class _DomainsContainer:
|
||||||
@ -71,8 +72,10 @@ class _DomainsContainer:
|
|||||||
})
|
})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _from_environment(cls, env: BuildEnvironment, /) -> Self:
|
def _from_environment(
|
||||||
create_domains = env.app.registry.create_domains
|
cls, env: BuildEnvironment, /, *, registry: SphinxComponentRegistry
|
||||||
|
) -> Self:
|
||||||
|
create_domains = registry.create_domains
|
||||||
# Initialise domains
|
# Initialise domains
|
||||||
if domains := {domain.name: domain for domain in create_domains(env)}:
|
if domains := {domain.name: domain for domain in create_domains(env)}:
|
||||||
return cls(**domains) # type: ignore[arg-type]
|
return cls(**domains) # type: ignore[arg-type]
|
||||||
|
@ -220,7 +220,9 @@ class BuildEnvironment:
|
|||||||
self._search_index_objnames: dict[int, tuple[str, str, str]] = {}
|
self._search_index_objnames: dict[int, tuple[str, str, str]] = {}
|
||||||
|
|
||||||
# all the registered domains, set by the application
|
# all the registered domains, set by the application
|
||||||
self.domains: _DomainsContainer = _DomainsContainer._from_environment(self)
|
self.domains: _DomainsContainer = _DomainsContainer._from_environment(
|
||||||
|
self, registry=app.registry
|
||||||
|
)
|
||||||
|
|
||||||
# set up environment
|
# set up environment
|
||||||
self.setup(app)
|
self.setup(app)
|
||||||
@ -259,7 +261,9 @@ class BuildEnvironment:
|
|||||||
# initialise domains
|
# initialise domains
|
||||||
if self.domains is None:
|
if self.domains is None:
|
||||||
# if we are unpickling an environment, we need to recreate the domains
|
# if we are unpickling an environment, we need to recreate the domains
|
||||||
self.domains = _DomainsContainer._from_environment(self)
|
self.domains = _DomainsContainer._from_environment(
|
||||||
|
self, registry=app.registry
|
||||||
|
)
|
||||||
# setup domains (must do after all initialization)
|
# setup domains (must do after all initialization)
|
||||||
self.domains._setup()
|
self.domains._setup()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user