Sphinx latexpdf 忽略文件的一部分

Sphinx latexpdf ignore parts of a file

在使用 latexpdf 构建 pdf 时,是否可以让 Sphinx 忽略 index.rst 的一部分?

例如,我的 index.rst 文件包含(但不是开头)行


.. image:: https://img.shields.io/....
  :target: https://pypi.org/....

.. image::  https://travis-ci.org/....
  :target: https://travis-ci.org/...

.. image:: https://coveralls.io/repos/github/....
  :target: https://coveralls.io/github/....

.. image::  https://readthedocs.org/.....
  :target: https://libensemble.readthedocs.org/....

这些应该出现在构建的 html 中,但不会出现在 PDF 中。我在这里什么都没看到: https://www.sphinx-doc.org/en/master/latex.html

是否可以告诉 sphinx 忽略这些行?

我想你可以使用 only directive:

  • index.rst
 .. only:: html

     .. image::  https://readthedocs.org/.....
     :target: https://libensemble.readthedocs.org/....
  • Makefile
 htmldoc:

    make -e SPHINXOPTS="-t html" html