mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Decl styling, use a post-transform to get the domain name in the desc_signature nodes
This commit is contained in:
parent
86eeee5031
commit
c1da955df2
@ -158,8 +158,9 @@ class desc_signature(_desc_classes_injector, nodes.Part, nodes.Inline, nodes.Tex
|
|||||||
Set ``is_multiline = True`` to describe a multi-line signature.
|
Set ``is_multiline = True`` to describe a multi-line signature.
|
||||||
In that case all child nodes must be :py:class:`desc_signature_line` nodes.
|
In that case all child nodes must be :py:class:`desc_signature_line` nodes.
|
||||||
|
|
||||||
This node always has the classes ``sig`` and ``sig-object``.
|
This node always has the classes ``sig``, ``sig-object``, and the domain it belongs to.
|
||||||
"""
|
"""
|
||||||
|
# Note: the domain name is being added through a post-transform DescSigAddDomainAsClass
|
||||||
classes = ['sig', 'sig-object']
|
classes = ['sig', 'sig-object']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -232,10 +232,20 @@ class SigElementFallbackTransform(SphinxPostTransform):
|
|||||||
node.replace_self(newnode)
|
node.replace_self(newnode)
|
||||||
|
|
||||||
|
|
||||||
|
class DescSigAddDomainAsClass(SphinxPostTransform):
|
||||||
|
"""Add the domain name of the parent node as a class in each desc_signature node."""
|
||||||
|
default_priority = 200
|
||||||
|
|
||||||
|
def run(self, **kwargs: Any) -> None:
|
||||||
|
for node in self.document.traverse(addnodes.desc_signature):
|
||||||
|
node['classes'].append(node.parent['domain'])
|
||||||
|
|
||||||
|
|
||||||
def setup(app: Sphinx) -> Dict[str, Any]:
|
def setup(app: Sphinx) -> Dict[str, Any]:
|
||||||
app.add_post_transform(ReferencesResolver)
|
app.add_post_transform(ReferencesResolver)
|
||||||
app.add_post_transform(OnlyNodeTransform)
|
app.add_post_transform(OnlyNodeTransform)
|
||||||
app.add_post_transform(SigElementFallbackTransform)
|
app.add_post_transform(SigElementFallbackTransform)
|
||||||
|
app.add_post_transform(DescSigAddDomainAsClass)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'version': 'builtin',
|
'version': 'builtin',
|
||||||
|
Loading…
Reference in New Issue
Block a user