def handle_signature(self, sig, signode):
cache = _APP_CACHES.get(self.env.app, {})
key = CursorKind.MACRO_DEFINITION, (sig, )
if key in cache:
node, comment, start, end, _ = cache[key]
signode += addnodes.desc_name(node.displayname, node.displayname)
# There is unfortunately no API to get the parameters of a macro,
# so we identify them by looking at the tokens.
tokens = list(node.get_tokens())
if (
tokens[1].kind is TokenKind.PUNCTUATION and
tokens[1].spelling == '('
):
paramlist = addnodes.desc_parameterlist()
for token in tokens[2:]:
if (
token.kind is TokenKind.PUNCTUATION and
token.spelling == ')'
):
break
elif token.kind is TokenKind.IDENTIFIER:
paramlist += addnodes.desc_parameter(token.spelling, token.spelling)
signode += paramlist
self.content = ViewList()
for lineno, line in enumerate(comment.splitlines(), start[0]):
self.content.append(line, '<unknown>', lineno)
return sig
评论列表
文章目录