mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-08-17 16:34:48 -05:00
C++: parse pack expansions in function calls.
This commit is contained in:
committed by
Jakob Lykke Andersen
parent
0d96401c43
commit
b839a7cf0e
@@ -26,6 +26,7 @@ Bugs fixed
|
||||
* #4825: C++, properly parse expr roles and give better error messages when
|
||||
(escaped) line breaks are present.
|
||||
* C++, properly use ``desc_addname`` nodes for prefixes of names.
|
||||
* C++, parse pack expansions in function calls.
|
||||
* #4915, #4916: links on search page are broken when using dirhtml builder
|
||||
* #4969: autodoc: constructor method should not have return annotation
|
||||
* latex: deeply nested enumerated list which is beginning with non-1 causes
|
||||
|
||||
+24
-1
@@ -1219,6 +1219,22 @@ class ASTPostfixExpr(ASTBase):
|
||||
p.describe_signature(signode, mode, env, symbol)
|
||||
|
||||
|
||||
class ASTPackExpansionExpr(ASTBase):
|
||||
def __init__(self, expr):
|
||||
self.expr = expr
|
||||
|
||||
def __unicode__(self):
|
||||
return text_type(self.expr) + '...'
|
||||
|
||||
def get_id(self, version):
|
||||
id = self.expr.get_id(version)
|
||||
return 'sp' + id
|
||||
|
||||
def describe_signature(self, signode, mode, env, symbol):
|
||||
self.expr.describe_signature(signode, mode, env, symbol)
|
||||
signode += nodes.Text('...')
|
||||
|
||||
|
||||
class ASTFallbackExpr(ASTBase):
|
||||
def __init__(self, expr):
|
||||
self.expr = expr
|
||||
@@ -4273,6 +4289,9 @@ class DefinitionParser(object):
|
||||
if self.skip_string('*'):
|
||||
# don't steal the dot
|
||||
self.pos -= 2
|
||||
elif self.skip_string('..'):
|
||||
# don't steal the dot
|
||||
self.pos -= 3
|
||||
else:
|
||||
name = self._parse_nested_name()
|
||||
postFixes.append(ASTPostfixMember(name)) # type: ignore
|
||||
@@ -4299,7 +4318,11 @@ class DefinitionParser(object):
|
||||
while True:
|
||||
self.skip_ws()
|
||||
expr = self._parse_expression(inTemplate=False)
|
||||
exprs.append(expr)
|
||||
self.skip_ws()
|
||||
if self.skip_string('...'):
|
||||
exprs.append(ASTPackExpansionExpr(expr))
|
||||
else:
|
||||
exprs.append(expr)
|
||||
self.skip_ws()
|
||||
if self.skip_string(')'):
|
||||
break
|
||||
|
||||
@@ -214,6 +214,9 @@ def test_expressions():
|
||||
exprCheck('operator()()', 'clclE')
|
||||
exprCheck('operator()<int>()', 'clclIiEE')
|
||||
|
||||
# pack expansion
|
||||
exprCheck('a(b(c, 1 + d...)..., e(f..., g))', 'cl1aspcl1b1cspplL1E1dEcl1esp1f1gEE')
|
||||
|
||||
|
||||
def test_type_definitions():
|
||||
check("type", "public bool b", {1: "b", 2: "1b"}, "bool b")
|
||||
|
||||
Reference in New Issue
Block a user