Skip to content

Commit

Permalink
Decl styling, C++, fix alternate spellings of operators
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobandersen committed Mar 30, 2021
1 parent b16cb6c commit e1db7ea
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions sphinx/domains/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,10 +1246,12 @@ def get_id(self, version: int) -> str:

def describe_signature(self, signode: TextElement, mode: str,
env: "BuildEnvironment", symbol: "Symbol") -> None:
signode += addnodes.desc_sig_operator(self.op, self.op)
if self.op[0] in 'cn':
signode += addnodes.desc_sig_keyword(self.op, self.op)
signode += addnodes.desc_sig_space()
self.expr.describe_signature(signode, mode, env, symbol)
else:
signode += addnodes.desc_sig_operator(self.op, self.op)
self.expr.describe_signature(signode, mode, env, symbol)


class ASTSizeofParamPack(ASTExpression):
Expand Down Expand Up @@ -1484,7 +1486,11 @@ def describe_signature(self, signode: TextElement, mode: str,
self.exprs[0].describe_signature(signode, mode, env, symbol)
for i in range(1, len(self.exprs)):
signode += addnodes.desc_sig_space()
signode += addnodes.desc_sig_operator(self.ops[i - 1], self.ops[i - 1])
op = self.ops[i - 1]
if ord(op[0]) >= ord('a') and ord(op[0]) <= ord('z'):
signode += addnodes.desc_sig_keyword(op, op)
else:
signode += addnodes.desc_sig_operator(op, op)
signode += addnodes.desc_sig_space()
self.exprs[i].describe_signature(signode, mode, env, symbol)

Expand Down Expand Up @@ -1550,7 +1556,11 @@ def describe_signature(self, signode: TextElement, mode: str,
self.exprs[0].describe_signature(signode, mode, env, symbol)
for i in range(1, len(self.exprs)):
signode += addnodes.desc_sig_space()
signode += addnodes.desc_sig_operator(self.ops[i - 1], self.ops[i - 1])
op = self.ops[i - 1]
if ord(op[0]) >= ord('a') and ord(op[0]) <= ord('z'):
signode += addnodes.desc_sig_keyword(op, op)
else:
signode += addnodes.desc_sig_operator(op, op)
signode += addnodes.desc_sig_space()
self.exprs[i].describe_signature(signode, mode, env, symbol)

Expand Down

0 comments on commit e1db7ea

Please sign in to comment.