summaryrefslogtreecommitdiff
path: root/sphinx/util/cfamily.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-07-05 01:32:54 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-07-05 01:32:54 +0900
commitec3754bd94eaa3aa3c5410ee6ab100bb27bfb798 (patch)
treed0446a967a4f8cbc3208d48d6bf3d9b7c90ca25e /sphinx/util/cfamily.py
parentb268963709dc9256cf711d4cc054a86e70226702 (diff)
parent9fd9edebb47a3a5eda8c6065b12b71cdb0985a73 (diff)
downloadsphinx-git-ec3754bd94eaa3aa3c5410ee6ab100bb27bfb798.tar.gz
Merge branch '3.x'
Diffstat (limited to 'sphinx/util/cfamily.py')
-rw-r--r--sphinx/util/cfamily.py21
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