From e1db7eae7730f2da5ebfa7e38f07b070b4351980 Mon Sep 17 00:00:00 2001 From: Jakob Lykke Andersen Date: Tue, 30 Mar 2021 11:50:36 +0200 Subject: [PATCH] Decl styling, C++, fix alternate spellings of operators --- sphinx/domains/cpp.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index 057cc203737..1c876081bd7 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -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): @@ -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) @@ -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)