mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #8668 from jakobandersen/c_expr_lookup
C, fix namespace lookup for expr role
This commit is contained in:
commit
4c0a283178
4
CHANGES
4
CHANGES
@ -16,6 +16,10 @@ Features added
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* #8655: autodoc: Failed to generate document if target module contains an
|
||||||
|
object that raises an exception on ``hasattr()``
|
||||||
|
* C, ``expr`` role should start symbol lookup in the current scope.
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -137,8 +137,7 @@ class ASTIdentifier(ASTBaseBase):
|
|||||||
reftype='identifier',
|
reftype='identifier',
|
||||||
reftarget=targetText, modname=None,
|
reftarget=targetText, modname=None,
|
||||||
classname=None)
|
classname=None)
|
||||||
key = symbol.get_lookup_key()
|
pnode['c:parent_key'] = symbol.get_lookup_key()
|
||||||
pnode['c:parent_key'] = key
|
|
||||||
if self.is_anon():
|
if self.is_anon():
|
||||||
pnode += nodes.strong(text="[anonymous]")
|
pnode += nodes.strong(text="[anonymous]")
|
||||||
else:
|
else:
|
||||||
@ -3204,7 +3203,8 @@ class CObject(ObjectDescription):
|
|||||||
def parse_pre_v3_type_definition(self, parser: DefinitionParser) -> ASTDeclaration:
|
def parse_pre_v3_type_definition(self, parser: DefinitionParser) -> ASTDeclaration:
|
||||||
return parser.parse_pre_v3_type_definition()
|
return parser.parse_pre_v3_type_definition()
|
||||||
|
|
||||||
def describe_signature(self, signode: TextElement, ast: Any, options: Dict) -> None:
|
def describe_signature(self, signode: TextElement, ast: ASTDeclaration,
|
||||||
|
options: Dict) -> None:
|
||||||
ast.describe_signature(signode, 'lastIsName', self.env, options)
|
ast.describe_signature(signode, 'lastIsName', self.env, options)
|
||||||
|
|
||||||
def run(self) -> List[Node]:
|
def run(self) -> List[Node]:
|
||||||
@ -3642,7 +3642,7 @@ class CExprRole(SphinxRole):
|
|||||||
location=self.get_source_info())
|
location=self.get_source_info())
|
||||||
# see below
|
# see below
|
||||||
return [self.node_type(text, text, classes=classes)], []
|
return [self.node_type(text, text, classes=classes)], []
|
||||||
parentSymbol = self.env.temp_data.get('cpp:parent_symbol', None)
|
parentSymbol = self.env.temp_data.get('c:parent_symbol', None)
|
||||||
if parentSymbol is None:
|
if parentSymbol is None:
|
||||||
parentSymbol = self.env.domaindata['c']['root_symbol']
|
parentSymbol = self.env.domaindata['c']['root_symbol']
|
||||||
# ...most if not all of these classes should really apply to the individual references,
|
# ...most if not all of these classes should really apply to the individual references,
|
||||||
|
13
tests/roots/test-domain-c/ns_lookup.rst
Normal file
13
tests/roots/test-domain-c/ns_lookup.rst
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
.. c:namespace:: ns_lookup
|
||||||
|
|
||||||
|
.. c:var:: int i
|
||||||
|
|
||||||
|
.. c:function:: void f(int j)
|
||||||
|
|
||||||
|
- :c:var:`i`
|
||||||
|
- :c:var:`j`
|
||||||
|
- :c:expr:`i`
|
||||||
|
- :c:expr:`j`
|
||||||
|
|
||||||
|
- :c:var:`i`
|
||||||
|
- :c:expr:`i`
|
@ -595,6 +595,13 @@ def test_build_function_param_target(app, warning):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
|
||||||
|
def test_build_ns_lookup(app, warning):
|
||||||
|
app.builder.build_all()
|
||||||
|
ws = filter_warnings(warning, "ns_lookup")
|
||||||
|
assert len(ws) == 0
|
||||||
|
|
||||||
|
|
||||||
def _get_obj(app, queryName):
|
def _get_obj(app, queryName):
|
||||||
domain = app.env.get_domain('c')
|
domain = app.env.get_domain('c')
|
||||||
for name, dispname, objectType, docname, anchor, prio in domain.get_objects():
|
for name, dispname, objectType, docname, anchor, prio in domain.get_objects():
|
||||||
|
Loading…
Reference in New Issue
Block a user