将一个文档包含到另一个文档中的 sphinx 指令是什么?
What is the sphinx directive for including a document into another document?
在我的文档中,我有一个 examples
目录,我可以在其中说,
.. literalinclude:: examples/1_basic_usage.py
:language: python
:linenos:
..效果很好,因为它们是代码并且格式正确。
不过,我想对非代码文档做一个literalinclude
。在整个项目级别,我已经定义了 AUTHORS
、DESCRIPTION
、ATTRIBUTION
等,我想(基本上)将它们粘贴到位,但我不知道如何.
希望它类似于此非工作示例:
Authors
-------
.. literalinclude:: ../../AUTHORS
Attribution
-----------
.. literalinclude:: ../../ATTRIBUTION
显然,使用 .. include:: <path>
指令可以做到这一点。
在他们的文档中没有明显的地方,根本没有示例存根。
可以在 docutils
reStructuredText reference (#include).
中找到完整的文档
The "include" directive reads a text file. The directive argument is the path to the file to be included, relative to the document containing the directive. Unless the options literal or code are given, the file is parsed in the current document's context at the point of the directive. For example:
This first example will be parsed at the document level, and can
thus contain any construct, including section headers.
.. include:: inclusion.txt
Back in the main document.
This second example will be parsed in a block quote context.
Therefore it may only contain body elements. It may not
contain section headers.
.. include:: inclusion.txt
在我的文档中,我有一个 examples
目录,我可以在其中说,
.. literalinclude:: examples/1_basic_usage.py
:language: python
:linenos:
..效果很好,因为它们是代码并且格式正确。
不过,我想对非代码文档做一个literalinclude
。在整个项目级别,我已经定义了 AUTHORS
、DESCRIPTION
、ATTRIBUTION
等,我想(基本上)将它们粘贴到位,但我不知道如何.
希望它类似于此非工作示例:
Authors
-------
.. literalinclude:: ../../AUTHORS
Attribution
-----------
.. literalinclude:: ../../ATTRIBUTION
显然,使用 .. include:: <path>
指令可以做到这一点。
在他们的文档中没有明显的地方,根本没有示例存根。
可以在 docutils
reStructuredText reference (#include).
The "include" directive reads a text file. The directive argument is the path to the file to be included, relative to the document containing the directive. Unless the options literal or code are given, the file is parsed in the current document's context at the point of the directive. For example:
This first example will be parsed at the document level, and can thus contain any construct, including section headers.
.. include:: inclusion.txt
Back in the main document.
This second example will be parsed in a block quote context.
Therefore it may only contain body elements. It may not
contain section headers.
.. include:: inclusion.txt