mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Transplant indices on instantiate domain
This commit is contained in:
parent
a2880dffe6
commit
a7d4fd1a50
@ -169,6 +169,7 @@ class Domain(object):
|
|||||||
# convert class variables to instance one (to enhance through API)
|
# convert class variables to instance one (to enhance through API)
|
||||||
self.directives = dict(self.directives)
|
self.directives = dict(self.directives)
|
||||||
self.roles = dict(self.roles)
|
self.roles = dict(self.roles)
|
||||||
|
self.indices = list(self.indices)
|
||||||
|
|
||||||
if self.name not in env.domaindata:
|
if self.name not in env.domaindata:
|
||||||
assert isinstance(self.initial_data, dict)
|
assert isinstance(self.initial_data, dict)
|
||||||
|
@ -53,6 +53,7 @@ class SphinxComponentRegistry(object):
|
|||||||
self.builders = {} # type: Dict[unicode, Type[Builder]]
|
self.builders = {} # type: Dict[unicode, Type[Builder]]
|
||||||
self.domains = {} # type: Dict[unicode, Type[Domain]]
|
self.domains = {} # type: Dict[unicode, Type[Domain]]
|
||||||
self.domain_directives = {} # type: Dict[unicode, Dict[unicode, Any]]
|
self.domain_directives = {} # type: Dict[unicode, Dict[unicode, Any]]
|
||||||
|
self.domain_indices = {} # type: Dict[unicode, List[Index]]
|
||||||
self.domain_roles = {} # type: Dict[unicode, Dict[unicode, Any]]
|
self.domain_roles = {} # type: Dict[unicode, Dict[unicode, Any]]
|
||||||
self.post_transforms = [] # type: List[Type[Transform]]
|
self.post_transforms = [] # type: List[Type[Transform]]
|
||||||
self.source_parsers = {} # type: Dict[unicode, Parser]
|
self.source_parsers = {} # type: Dict[unicode, Parser]
|
||||||
@ -111,6 +112,7 @@ class SphinxComponentRegistry(object):
|
|||||||
# transplant components added by extensions
|
# transplant components added by extensions
|
||||||
domain.directives.update(self.domain_directives.get(domain.name, {}))
|
domain.directives.update(self.domain_directives.get(domain.name, {}))
|
||||||
domain.roles.update(self.domain_roles.get(domain.name, {}))
|
domain.roles.update(self.domain_roles.get(domain.name, {}))
|
||||||
|
domain.indices.extend(self.domain_indices.get(domain.name, []))
|
||||||
|
|
||||||
yield domain
|
yield domain
|
||||||
|
|
||||||
@ -147,7 +149,8 @@ class SphinxComponentRegistry(object):
|
|||||||
logger.debug('[app] adding index to domain: %r', (domain, index))
|
logger.debug('[app] adding index to domain: %r', (domain, index))
|
||||||
if domain not in self.domains:
|
if domain not in self.domains:
|
||||||
raise ExtensionError(__('domain %s not yet registered') % domain)
|
raise ExtensionError(__('domain %s not yet registered') % domain)
|
||||||
self.domains[domain].indices.append(index)
|
indices = self.domain_indices.setdefault(domain, [])
|
||||||
|
indices.append(index)
|
||||||
|
|
||||||
def add_object_type(self, directivename, rolename, indextemplate='',
|
def add_object_type(self, directivename, rolename, indextemplate='',
|
||||||
parse_node=None, ref_nodeclass=None, objname='',
|
parse_node=None, ref_nodeclass=None, objname='',
|
||||||
|
Loading…
Reference in New Issue
Block a user