python-sphinx - 狮身人面像,literalinclude,linenos : How to display the actual line numbers from the source code file on the doc's code snippet?

标签 python-sphinx

我正在使用Sphinx在网页上记录部分Javascript代码。

我用

.. literalinclude:: ../examples/mapviz-step1-simple.html
   :language: javascript
   :lines: 47-51
   :linenos:

我懂了

该代码段来自实际源代码文件的47-51行,而不是1-5行。

如何显示实际的行号以及此代码段?

最佳答案

当在2011年提出此问题时,这是不可能的,但是自Sphinx 1.3起,就有了lineno-start选项。请参阅以下增强请求:https://github.com/sphinx-doc/sphinx/issues/668
当前文档:

  • literalinclude
  • code-block
  • 关于python-sphinx - 狮身人面像,literalinclude,linenos : How to display the actual line numbers from the source code file on the doc's code snippet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6867961/

    相关文章:

    python - Sphinx/Pygments 中有没有一种方法可以在文字包含中强调一行或多行代码?

    python-sphinx - 如何使用 sphinx 链接到 rst 中的文件?

    python - 模块内的 Sphinx autodoc 函数

    python-sphinx - 如何将 Logo 添加到我的 readthedocs - 0px 宽的 Logo 渲染

    javascript - 压缩静态 HTML 文件中的 JS 和 CSS

    python - 我在哪里可以找到有关带有 sphinx-doc 拿破仑扩展的 Google 风格文档字符串中支持的新语法的更多信息?

    python-3.x - Sphinx 和 Markdown .md 链接

    python - 如何在 Python 中记录类型参数?

    python - 狮身人面像 :ivar tag goes looking for cross-references

    c++ - Sphinx 是否已经适用于 C++ 文档?