sphinx 中的 python 域有 .. py:decorator::
来记录装饰器,但如何交叉引用装饰器?
对于函数(用 .. py:function::
记录)有 :py:func:
。装饰器的等价物是什么?
最佳答案
我在sphinx的文档中找到了答案:
There is no py:deco role to link to a decorator that is marked up with this directive; rather, use the py:func role. http://sphinx-doc.org/domains.html#directive-py:decorator
官方的解决方案是使用:py:func:
。它也有效。不幸的是,sphinx 在装饰器名称后添加了括号。
text py:func:`mydecorator` text
成为输出:
text mydecorator() text
brakets 可以全局禁用,但在引用实际函数时我非常喜欢它们。
关于python - 交叉引用装饰器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30353856/