Sphinx RST扩展html输出中的子页面

时间:2018-03-22 10:02:39

标签: python-sphinx restructuredtext

我正在使用sphinx文档系统生成HTML和Latex输出格式的报告。所以有一个层次结构,我有一个read index.rst,它包含一个toctree,按顺序引用所有章节。然后章节是一个文件夹,它还包含一个只有标题的index.rst和一个包含该章节所有部分的toctree。

作为一个例子,我的结构看起来像这样:

root
    - index.rst <- Contains only a toctree that references other chapters index.rst.
    - SomeChapter
        - index.rst <- Contains heading and toctree that references actual content
        - section1.rst <- actual content
        - section2.rst <- actual content
        ....

这使得乳胶呈现精美,因为你会得到一些章节和下面的部分但是在html中这些都是单独的页面,因为你不得不一直点击,所以对于一些较小的部分来说很快。有没有办法指示html构建器在某些情况下它应该在子页面中显示它们在toctree中的子页面而不是为它创建子页面?

我知道singlehtml但是它确实为它构建了一个完整的单个html页面,我想部分地这样做,因为很多时候不同的章节对于不同的页面都很好但是部分可以很容易地在同一页面上。

感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

未经考验的答案。

有两个不同的索引页面,一个用于HTML(index.rst)和LaTeX(indexlatex.rst),后者是前者的副本,然后前者被修改。

然后在conf.py中,指定indexlatex.rst作为条目toctree。 Pyramid的示例:

latex_documents = [
  ('latexindex', 'pyramid.tex',
  ...
  )

最后要修改index.rst,您将使用一系列include指令并删除toctree指令。

.. include:: section1.rst
.. include:: section2.rst

您可能还需要在latexindex文件上使用:orphan: metadata来禁止警告,使其不包含在index toctree中。

相关问题