我可以使用sphinx.ext.viewcode显示行号吗?

发布于 2025-01-27 14:42:53 字数 264 浏览 3 评论 0原文

我正在使用 sphinx.ext.viewcode 记录我的API。是否可以在生产的Cod-Block上显示线号,如果是的话?

我试图在文档中找到html_option,但没有找到任何东西。

I'm using the sphinx.ext.viewcode to document my API. Is it possible to display the line numbers on the produced cod-block and if yes how ?

I've tried to find an html_option in the docs but I didn't found anything.

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

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

发布评论

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

评论(1

秉烛思 2025-02-03 14:42:53

由于我问了这个问题,以下 pr 已合并到sphinx从v7.2.0开始。

要在ViewCode输出中添加行编号,只需将以下参数添加到您的conf.py:

viewcode_line_numbers = True

Since I asked this question, the following PR have been merged to Sphinx and is available starting from v7.2.0.

to add the line numbering in a viewcode output, simply add the following parameter to your conf.py:

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