|
39 | 39 |
|
40 | 40 | from docutils.nodes import Element, Node, TextElement, system_message
|
41 | 41 |
|
42 |
| - from sphinx.addnodes import pending_xref |
| 42 | + from sphinx.addnodes import desc_signature, pending_xref |
43 | 43 | from sphinx.application import Sphinx
|
44 | 44 | from sphinx.builders import Builder
|
45 | 45 | from sphinx.domains.c._symbol import LookupKey
|
@@ -309,6 +309,32 @@ def after_content(self) -> None:
|
309 | 309 | self.env.current_document.c_parent_symbol = self.oldParentSymbol
|
310 | 310 | self.env.ref_context['c:parent_key'] = self.oldParentKey
|
311 | 311 |
|
| 312 | + def _object_hierarchy_parts(self, sig_node: desc_signature) -> tuple[str, ...]: |
| 313 | + last_symbol: Symbol = self.env.current_document.c_last_symbol |
| 314 | + return tuple(map(str, last_symbol.get_full_nested_name().names)) |
| 315 | + |
| 316 | + def _toc_entry_name(self, sig_node: desc_signature) -> str: |
| 317 | + if not sig_node.get('_toc_parts'): |
| 318 | + return '' |
| 319 | + |
| 320 | + config = self.config |
| 321 | + objtype = sig_node.parent.get('objtype') |
| 322 | + if config.add_function_parentheses and ( |
| 323 | + objtype in {'function', 'method'} |
| 324 | + or (objtype == 'macro' and '(' in sig_node.rawsource) |
| 325 | + ): |
| 326 | + parens = '()' |
| 327 | + else: |
| 328 | + parens = '' |
| 329 | + *parents, name = sig_node['_toc_parts'] |
| 330 | + if config.toc_object_entries_show_parents == 'domain': |
| 331 | + return '::'.join((name + parens,)) |
| 332 | + if config.toc_object_entries_show_parents == 'hide': |
| 333 | + return name + parens |
| 334 | + if config.toc_object_entries_show_parents == 'all': |
| 335 | + return '::'.join([*parents, name + parens]) |
| 336 | + return '' |
| 337 | + |
312 | 338 |
|
313 | 339 | class CMemberObject(CObject):
|
314 | 340 | object_type = 'member'
|
|
0 commit comments