使用 Sphinx 从单一来源生成内部和外部文档



我正在尝试查找有关狮身人面像将某些文档标记为"内部"的能力的信息,并像sphinx-build -b -include internal source output一样构建它,其中-include标志将包含一系列要包含在输出中的标签。

这将允许我生成 2 个版本(或更多(的文档,同时保持单一来源。

例:

.. audience::internal
Page title
============
This whole page will be available only in the internal docs.

Page title
============
This whole page will be available in the internal and external docs. 
.. audience::internal
That p will only be available in the internal docs.
This p will be available in the internal and external docs.

有这样的机制吗?如果没有,那会很难创建吗?

狮身人面像扩展 ifconfig 可能会做你想要的,尽管你必须缩进内容。

ifconfig确实是一种方法,但是在四处询问之后,似乎有一个更好的机制:

.. only::指令

使用它来标记某些内容:

.. only:: internal
   Page title
   ============
   This whole page will be available only in the internal docs.

然后,您可以使用-t选项运行构建,以发布标记为internal的所有内容(或您使用的任何内容(

sphinx-build -t internal -b html source output

最新更新