Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Lykke Andersen <Jakob@caput.dk>2021-03-20 18:42:00 +0300
committerJakob Lykke Andersen <Jakob@caput.dk>2021-04-12 20:05:58 +0300
commite012c93f1b69d943fe481982dce6d9dcf317ed51 (patch)
tree97707ac50839e2897cf3e55c955eb86634e7cafe /sphinx/addnodes.py
parentd131ec7acbc2026c0cc05c58fa39f3d845f3e6ba (diff)
Decl styling, move static classes to addnodes from HTML5 writer
Diffstat (limited to 'sphinx/addnodes.py')
-rw-r--r--sphinx/addnodes.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/sphinx/addnodes.py b/sphinx/addnodes.py
index ac41dd951..17f579c0e 100644
--- a/sphinx/addnodes.py
+++ b/sphinx/addnodes.py
@@ -119,6 +119,19 @@ class toctree(nodes.General, nodes.Element, translatable):
# Domain-specific object descriptions (class, function etc.)
#############################################################
+class _desc_classes_injector:
+ """Helper base class for injecting a fixes list of classes.
+
+ Use as the first base class.
+ """
+
+ classes = [] # type: List[str]
+
+ def __init__(self, *args, **kwargs) -> None:
+ super().__init__(*args, **kwargs)
+ self['classes'].extend(self.classes)
+
+
# Top-level nodes
#################
@@ -175,20 +188,26 @@ class desc_content(nodes.General, nodes.Element):
# nodes to use within a desc_signature or desc_signature_line
-class desc_name(nodes.Part, nodes.Inline, nodes.FixedTextElement):
+class desc_name(_desc_classes_injector, nodes.Part, nodes.Inline, nodes.FixedTextElement):
"""Node for the main object name.
For example, in the declaration of a Python class ``MyModule.MyClass``,
the main name is ``MyClass``.
+
+ This node always has the class ``sig-name``.
"""
+ classes = ['sig-name', 'descname'] # 'descname' is for backwards compatibility
-class desc_addname(nodes.Part, nodes.Inline, nodes.FixedTextElement):
+class desc_addname(_desc_classes_injector, nodes.Part, nodes.Inline, nodes.FixedTextElement):
"""Node for additional name parts for an object.
For example, in the declaration of a Python class ``MyModule.MyClass``,
the additional name part is ``MyModule.``.
+
+ This node always has the class ``sig-prename``.
"""
+ classes = ['sig-prename', 'descclassname'] # 'descclassname' is for backwards compatibility
# compatibility alias
@@ -237,7 +256,7 @@ class desc_annotation(nodes.Part, nodes.Inline, nodes.FixedTextElement):
# in SigElementFallbackTransform.
# When adding a new one, add it to SIG_ELEMENTS.
-class desc_sig_element(nodes.inline):
+class desc_sig_element(nodes.inline, _desc_classes_injector):
"""Common parent class of nodes for inline text of a signature."""
classes: List[str] = []