在 Python 中记录模块/类/函数体 Sphinx 文档

发布于 2024-08-13 03:08:56 字数 317 浏览 2 评论 0原文

Sphinx 文档是否可以通过 autodoc 功能输出函数或类体(代码本身)?我使用 autodoc 取得了很大的成功。除了将文档字符串拉入文档之外,我还想为每个函数添加一个单击链接,它将向您显示源代码......这可能吗?

这就是我的大部分文档现在的样子:

.. module:`foo.mymodule`

Title
===================


.. automodule:: foo.mymodule

.. autoclass:: MyModulesClass
    :members:
    :undoc-members:

Is there a way with Sphinx documentation to output a function or class body (the code itself) with the autodoc feature? I'm using autodoc to much success. In addition to the docstrings getting pulled in to the documentation I want like a link to click for each function where it will show you the source... is that possible?

This is about what most of my documentation looks like now:

.. module:`foo.mymodule`

Title
===================


.. automodule:: foo.mymodule

.. autoclass:: MyModulesClass
    :members:
    :undoc-members:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

趁年轻赶紧闹 2024-08-20 03:08:56

如果这仍然很重要: viewcode 扩展 可以做到这一点,但需要开发Sphinx 版本 (1.0)

If this still matters: The viewcode extension can do this, but needs the development version (1.0) of Sphinx

卖梦商人 2024-08-20 03:08:56

我不相信是这样。 Autodoc 仅用于从源代码中提取文档。

I don't believe so. Autodoc is only for pulling the documentation out of the source code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文