def handle_signature(self, sig, signode):
ret = super().handle_signature(sig, signode)
# Add the "@" prefix
if ("decorator" in self.options
or self.objtype in ["decorator", "decoratormethod"]):
signode.insert(0, addnodes.desc_addname("@", "@"))
# Now that the "@" has been taken care of, we can add in the regular
# prefix.
prefix = self._get_signature_prefix()
if prefix:
signode.insert(0, addnodes.desc_annotation(prefix, prefix))
# And here's the suffix:
for optname in ["with", "async-with"]:
if self.options.get(optname, "").strip():
# for some reason a regular space here gets stripped, so we
# use U+00A0 NO-BREAK SPACE
s = "\u00A0as {}".format(self.options[optname])
signode += addnodes.desc_annotation(s, s)
return ret
评论列表
文章目录