Skip to content

Commit

Permalink
C++, allow arbitrary initializer for variable concepts.
Browse files Browse the repository at this point in the history
  • Loading branch information
other-mickk committed May 31, 2016
1 parent 8a64cfd commit 1955cb3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions sphinx/domains/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2111,9 +2111,10 @@ def describe_signature(self, signode, mode, env, symbol):


class ASTConcept(ASTBase):
def __init__(self, nestedName, isFunction):
def __init__(self, nestedName, isFunction, initializer):
self.nestedName = nestedName
self.isFunction = isFunction # otherwise it's a variable concept
self.initializer = initializer

@property
def name(self):
Expand All @@ -2129,13 +2130,17 @@ def __unicode__(self):
res = text_type(self.nestedName)
if self.isFunction:
res += "()"
if self.initializer:
res += text_type(self.initializer)
return res

def describe_signature(self, signode, mode, env, symbol):
signode += nodes.Text(text_type("bool "))
self.nestedName.describe_signature(signode, mode, env, symbol)
if self.isFunction:
signode += nodes.Text("()")
if self.initializer:
self.initializer.describe_signature(signode, mode)


class ASTBaseClass(ASTBase):
Expand Down Expand Up @@ -3552,7 +3557,12 @@ def _parse_concept(self):
self.skip_ws()
if not self.skip_string(')'):
self.fail("Expected ')' in function concept declaration.")
return ASTConcept(nestedName, isFunction)

initializer = self._parse_initializer('member')
if initializer and isFunction:
self.fail("Function concept with initializer.")

return ASTConcept(nestedName, isFunction, initializer)

def _parse_class(self):
name = self._parse_nested_name()
Expand Down

0 comments on commit 1955cb3

Please sign in to comment.