是否可以覆盖 Sphinx autodoc 的特定功能?
我正在使用 Sphinx 的 autodoc 插件自动记录一组模块。我有一个接受 *args
的函数,我想重写文档以显示稍微好一点的 funcname(arg1[, arg2[, ...]])
Python stdlib 文档使用的样式。
是否可以覆盖特定函数的自动文档输出?
I'm using Sphinx's autodoc plugin to automatically document a set of modules. I have a function that accepts *args
, and I'd like to override the documentation to show the slightly nicer funcname(arg1[, arg2[, ...]])
style that the Python stdlib docs use.
Is it possible to override the autodoc output for a specific function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以使用
autofunction
覆盖签名:但是,具有覆盖签名的函数不会与使用
automodule
引入的其他函数一起排序。对每个函数使用显式的autofunction
指令可以解决这个问题:添加
您还可以附加到文档字符串:
要覆盖签名和文档字符串,请使用
function
而不是自动函数
。添加 2
还可以通过将签名作为函数文档字符串的第一行来覆盖签名。有关详细信息,请参阅此答案。
It is possible to override a signature by using
autofunction
:However, the function with the overridden signature is not sorted with the other functions pulled in with
automodule
. Using explicitautofunction
directives for every function works around that:Addition
You can also append to the docstring:
To override both signature and docstring, use
function
instead ofautofunction
.Addition 2
The signature can also be overridden by having a signature as the first line of the function docstring. See this answer for details.