【问题标题】:Sphinx copy html file狮身人面像复制html文件
【发布时间】:2015-10-12 11:52:23
【问题描述】:

我使用 Sphinx 生成文档,其中一些文档是纯 html 文件。 我想 sphinx 将这些文件复制到构建目录到相应的路径。 我可以做吗 ?

【问题讨论】:

  • 也许download 角色正是您想要的。
  • 不,我不想在文档文件中做任何事情,只在配置中。并且很难为所有 html 文件编写角色。不过谢谢你的回复。
  • 好的,html_extra_path 呢?

标签: html copy python-sphinx


【解决方案1】:

不知道我是否明白了你想要做的事情。

我需要的是:用 sphinx 创建 html 内容后

$ make html

我需要将这些 html 复制到 doc 文件夹,以便 github 页面可以看到它。

也就是说,我正在做的是:我创建了一个 python 脚本来调用 sphinx,然后复制文件。

脚本和文档位于 doc_src 文件夹中。结构是:

Project/
 doc/ (where I need my html)
 doc_src/ (where I build them)

doc_src 里面的脚本是这样的:

import os
import sys
import shutil

def make_doc():
    """Run Sphinx to build the doc."""
    try:
        # removing previous build
        print('removing previous build')
        cmd = 'make clean'
        os.system(cmd)
        shutil.rmtree('../doc/', ignore_errors=True)

        # new build
        cmd = 'make html'
        os.system(cmd)

        # copy files - windows cmd here
        print('copy files')
        cmd = r'xcopy _build\html\. ..\doc\ /e /Y'
        os.system(cmd)
    except Exception as error:
        print(error)


if __name__ == '__main__':
    make_doc()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-17
    • 1970-01-01
    相关资源
    最近更新 更多