summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Zverovich <victor.zverovich@gmail.com>2014-05-12 08:12:37 -0700
committerVictor Zverovich <victor.zverovich@gmail.com>2014-05-12 08:12:37 -0700
commit362225b5cf5642e50990d633eae241721ed640b4 (patch)
tree51b8ef10bf29aeeec1bd7969e0afb29f5c1bbe52
parente068ee45f9fac9924858f9e7e10fa88a50f79ab8 (diff)
downloadsphinx-362225b5cf5642e50990d633eae241721ed640b4.tar.gz
Add support for variadic templates in C++ domain
-rw-r--r--sphinx/domains/cpp.py14
-rw-r--r--tests/test_cpp_domain.py2
2 files changed, 13 insertions, 3 deletions
diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py
index df927e64..71cc104a 100644
--- a/sphinx/domains/cpp.py
+++ b/sphinx/domains/cpp.py
@@ -347,11 +347,12 @@ class CastOpDefExpr(PrimaryDefExpr):
class ArgumentDefExpr(DefExpr):
- def __init__(self, type, name, type_suffixes, default=None):
+ def __init__(self, type, name, type_suffixes, default=None, param_pack=False):
self.name = name
self.type = type
self.type_suffixes = type_suffixes
self.default = default
+ self.param_pack = param_pack
def get_name(self):
return self.name.get_name()
@@ -364,7 +365,11 @@ class ArgumentDefExpr(DefExpr):
return u''.join(buf)
def __unicode__(self):
- buf = [(u'%s %s' % (self.type or u'', self.name or u'')).strip()]
+ buf = [(u'%s%s %s' % (
+ self.type or u'',
+ '...' if self.param_pack else u'',
+ self.name or u'')
+ ).strip()]
if self.default is not None:
buf.append('=%s' % self.default)
for suffix in self.type_suffixes:
@@ -838,6 +843,9 @@ class DefinitionParser(object):
argname = default = None
argtype = self._parse_type()
self.skip_ws()
+ param_pack = self.skip_string('...')
+ if param_pack:
+ self.skip_ws()
type_suffixes = self._try_parse_type_suffixes()
if self.skip_string('='):
default = self._parse_default_expr()
@@ -852,7 +860,7 @@ class DefinitionParser(object):
argtype = None
args.append(ArgumentDefExpr(argtype, argname,
- type_suffixes, default))
+ type_suffixes, default, param_pack))
self.skip_ws()
attributes = dict(
signature=args,
diff --git a/tests/test_cpp_domain.py b/tests/test_cpp_domain.py
index 8e1cb22b..ba304529 100644
--- a/tests/test_cpp_domain.py
+++ b/tests/test_cpp_domain.py
@@ -124,6 +124,8 @@ def test_type_definitions():
x = 'int foo(D d=x(a'
raises(DefinitionError, parse, 'function', x)
+ x = 'int foo(const A&... a)'
+ assert unicode(parse('function', x)) == x
def test_bases():
x = 'A'