python-sphinx - ..literalinclude::from 标记

标签 python-sphinx code-documentation

我正在使用用于记录 C 代码。我对 提供的功能不感兴趣,但是有时我想包含代码库中的一些片段。

.. literalinclude::看起来不错,但是 :lines:选项有点弱,特别是如果之后编辑代码。

我正在考虑一个新选项,例如 :marker-start: <<<HERE:marker-end: <<<END

实现此行为的最简单方法是什么?

最佳答案

您可以使用start-afterend-before选项。下面是一个例子。

示例.txt:

# START
first line
second line
# END
third line

标记:

.. literalinclude:: example.txt
   :start-after: # START
   :end-before: # END

这将出现在输出中:

first line
second line

参见https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-literalinclude .

关于python-sphinx - ..literalinclude::from 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36135982/

相关文章:

python - 如何让 Sphinx 自动摘要显示实例属性的文档?

python - 代码块中的 Sphinx 变量替换

python - 使用抽象基类仅用于文档目的

android - Android 文档中的不完整方法访问修饰符和/或非访问修饰符

python - 如何使用 Sphinx 的 autodoc 来记录类的 __init__(self) 方法?

python-sphinx - 你是否应该始终记录函数,即使是多余的(特别是 python)?

ios - swift 3 错误 : "See also" callout not showing

visual-studio-code - Visual Studio Code 中是否有 GhostDoc 的类似物?

python-sphinx - 如何为restructuredText表添加标题?

java - 在代码中处理/格式化 Javadoc 和注释的最佳方式是什么?