diff --git a/CHANGES b/CHANGES index 155ff81ba..9c9bad2b1 100644 --- a/CHANGES +++ b/CHANGES @@ -73,6 +73,7 @@ Features added in the documentation. * #1027: Support backslash line continuation in :rst:dir:`productionlist`. * #7108: config: Allow to show an error message from conf.py via ``ConfigError`` +* #7144: Add CSS class indicating its domain for each desc node Bugs fixed ---------- diff --git a/sphinx/directives/__init__.py b/sphinx/directives/__init__.py index 6b9e5b828..ceabd2b25 100644 --- a/sphinx/directives/__init__.py +++ b/sphinx/directives/__init__.py @@ -160,6 +160,8 @@ class ObjectDescription(SphinxDirective): # 'desctype' is a backwards compatible attribute node['objtype'] = node['desctype'] = self.objtype node['noindex'] = noindex = ('noindex' in self.options) + if self.domain: + node['classes'].append(self.domain) self.names = [] # type: List[Any] signatures = self.get_signatures() diff --git a/tests/test_build_html.py b/tests/test_build_html.py index ac44ca7e4..221bb74b7 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -176,8 +176,8 @@ def test_html4_output(app, status, warning): r'-| |-'), ], 'autodoc.html': [ - (".//dt[@id='autodoc_target.Class']", ''), - (".//dt[@id='autodoc_target.function']/em", r'\*\*kwds'), + (".//dl[@class='py class']/dt[@id='autodoc_target.Class']", ''), + (".//dl[@class='py function']/dt[@id='autodoc_target.function']/em", r'\*\*kwds'), (".//dd/p", r'Return spam\.'), ], 'extapi.html': [ @@ -279,7 +279,7 @@ def test_html4_output(app, status, warning): (".//dt/code", r'long\(parameter,\s* list\)'), (".//dt/code", 'another one'), (".//a[@href='#mod.Cls'][@class='reference internal']", ''), - (".//dl[@class='userdesc']", ''), + (".//dl[@class='std userdesc']", ''), (".//dt[@id='userdesc-myobj']", ''), (".//a[@href='#userdesc-myobj'][@class='reference internal']", ''), # docfields