如何将外部文件包含为类似于代码块的 Sphinx 文档?

use*_*981 2 code-documentation python-sphinx

如何将外部文件包含为类似于代码块的 Sphinx 文档?

我怎样才能让它设置语法颜色的样式?

use*_*981 6

在这里找到:http : //sphinx-doc.org/markup/code.html

.. literalinclude :: <path/to/file>
   :language: <file_language>
Run Code Online (Sandbox Code Playgroud)

  • 谢谢!该链接似乎已过时。该指令的最新链接:https://www.sphinx-doc.org/en/master/usage/restructivetext/directives.html#directive-literalinclude (2认同)