sphinx导入父dir rst文件?

时间:2010-12-29 00:35:02

标签: python-sphinx

我需要为每个模块创建一个sphinx项目,

并且每个模块共享一些常见的rsts,如公司信息,许可证等。

我的项目树是这样的:

./conf.py
./index.rst
./intro.rst
./about.rst

./device1/conf.py
./device1/index.rst 

我在./device1/index.rst中写这个,但它不起作用,我怎么能导入父rst文件?

.. toctree::
   :maxdepth: 1

   ../intro
   ../about

2 个答案:

答案 0 :(得分:6)

我找到了一种方法:

.. include:: ../intro.rst

但它将包括所有文本...... 也许这是唯一的方法?

答案 1 :(得分:0)

我个人无法弄清楚如何修改源搜索路径,因此我最终修改了make文件,以便为sphinx构建目录中的所有*.rst文件创建符号链接。

foreach f ( `\ls OTHER_DIR | egrep '.rst$$'` ) \
    ln -s -f $$f BUILD_DIR \
end

(这假设你使用的是Linux / Unix。)

相关问题