diff options
author | Jakob Lykke Andersen <Jakob@caput.dk> | 2021-03-04 23:28:18 +0300 |
---|---|---|
committer | Jakob Lykke Andersen <Jakob@caput.dk> | 2021-03-04 23:28:18 +0300 |
commit | 72e231d0e6431f3709e74f0f9355a9798ebb0991 (patch) | |
tree | 3b3115d37cbfd511178b52ac82299e347641aae1 /sphinx/domains | |
parent | cba9ed0bb54a132e48582af58743d34f9c48a02b (diff) |
C and C++, fix nested paramter lists
Diffstat (limited to 'sphinx/domains')
-rw-r--r-- | sphinx/domains/c.py | 25 | ||||
-rw-r--r-- | sphinx/domains/cpp.py | 24 |
2 files changed, 33 insertions, 16 deletions
diff --git a/sphinx/domains/c.py b/sphinx/domains/c.py index 79d4e145c..0fecbad6d 100644 --- a/sphinx/domains/c.py +++ b/sphinx/domains/c.py @@ -669,15 +669,24 @@ class ASTParameters(ASTBase): def describe_signature(self, signode: TextElement, mode: str, env: "BuildEnvironment", symbol: "Symbol") -> None: verify_description_mode(mode) - paramlist = addnodes.desc_parameterlist() - for arg in self.args: - param = addnodes.desc_parameter('', '', noemph=True) - if mode == 'lastIsName': # i.e., outer-function params + # only use the desc_parameterlist for the outer list, not for inner lists + if mode == 'lastIsName': + paramlist = addnodes.desc_parameterlist() + for arg in self.args: + param = addnodes.desc_parameter('', '', noemph=True) arg.describe_signature(param, 'param', env, symbol=symbol) - else: - arg.describe_signature(param, 'markType', env, symbol=symbol) - paramlist += param - signode += paramlist + paramlist += param + signode += paramlist + else: + signode += nodes.Text('(', '(') + first = True + for arg in self.args: + if not first: + signode += nodes.Text(', ', ', ') + first = False + arg.describe_signature(signode, 'markType', env, symbol=symbol) + signode += nodes.Text(')', ')') + for attr in self.attrs: signode += nodes.Text(' ') attr.describe_signature(signode) diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index 04b471b17..3bd764de5 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -1967,15 +1967,23 @@ class ASTParametersQualifiers(ASTBase): def describe_signature(self, signode: TextElement, mode: str, env: "BuildEnvironment", symbol: "Symbol") -> None: verify_description_mode(mode) - paramlist = addnodes.desc_parameterlist() - for arg in self.args: - param = addnodes.desc_parameter('', '', noemph=True) - if mode == 'lastIsName': # i.e., outer-function params + # only use the desc_parameterlist for the outer list, not for inner lists + if mode == 'lastIsName': + paramlist = addnodes.desc_parameterlist() + for arg in self.args: + param = addnodes.desc_parameter('', '', noemph=True) arg.describe_signature(param, 'param', env, symbol=symbol) - else: - arg.describe_signature(param, 'markType', env, symbol=symbol) - paramlist += param - signode += paramlist + paramlist += param + signode += paramlist + else: + signode += nodes.Text('(', '(') + first = True + for arg in self.args: + if not first: + signode += nodes.Text(', ', ', ') + first = False + arg.describe_signature(signode, 'markType', env, symbol=symbol) + signode += nodes.Text(')', ')') def _add_anno(signode: TextElement, text: str) -> None: signode += nodes.Text(' ') |