diff options
Diffstat (limited to 'sphinx/util/cfamily.py')
-rw-r--r-- | sphinx/util/cfamily.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sphinx/util/cfamily.py b/sphinx/util/cfamily.py index 8e07ae92a..f8ce4c827 100644 --- a/sphinx/util/cfamily.py +++ b/sphinx/util/cfamily.py @@ -11,7 +11,7 @@ import re from copy import deepcopy from typing import ( - Any, Callable, List, Match, Pattern, Tuple, Union + Any, Callable, List, Match, Optional, Pattern, Tuple, Union ) from docutils import nodes @@ -141,16 +141,14 @@ class ASTCPPAttribute(ASTAttribute): class ASTGnuAttribute(ASTBaseBase): - def __init__(self, name: str, args: Any) -> None: + def __init__(self, name: str, args: Optional["ASTBaseParenExprList"]) -> None: self.name = name self.args = args def _stringify(self, transform: StringifyTransform) -> str: res = [self.name] if self.args: - res.append('(') res.append(transform(self.args)) - res.append(')') return ''.join(res) @@ -204,6 +202,11 @@ class ASTParenAttribute(ASTAttribute): ################################################################################ +class ASTBaseParenExprList(ASTBaseBase): + pass + + +################################################################################ class UnsupportedMultiCharacterCharLiteral(Exception): pass @@ -398,11 +401,8 @@ class BaseParser: while 1: if self.match(identifier_re): name = self.matched_text - self.skip_ws() - if self.skip_string_and_ws('('): - self.fail('Parameterized GNU style attribute not yet supported.') - attrs.append(ASTGnuAttribute(name, None)) - # TODO: parse arguments for the attribute + exprs = self._parse_paren_expression_list() + attrs.append(ASTGnuAttribute(name, exprs)) if self.skip_string_and_ws(','): continue elif self.skip_string_and_ws(')'): @@ -430,3 +430,6 @@ class BaseParser: return ASTParenAttribute(id, arg) return None + + def _parse_paren_expression_list(self) -> ASTBaseParenExprList: + raise NotImplementedError |