使用 readthedocs.org 使用的静态资产进行本地 Sphinx 构建的简单方法是什么?

Dav*_*ark 5 css python python-sphinx read-the-docs

目前,我可以找到获取 readthedocs.org 使用的当前设计资产的唯一方法是安装完整的主题,并构建它,这需要 SASS 等。

我只想获得一组静态文件,让我可以在本地查看我的构建在 readthedocs 上的样子。有没有办法在不通过上述链接自己构建资产的情况下做到这一点?目标是让新手可以轻松地为文档做出贡献。

Jas*_*n S 1

如果您想为其做出贡献/开发,您只需要构建主题。您可以使用安装主题pip install sphinx_rtd_theme。然后您可以在 Sphinx 中使用该主题conf.py。请参阅:http ://read-the-docs.readthedocs.org/en/latest/theme.html

# on_rtd is whether we are on readthedocs.org
import os
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

if not on_rtd:  # only import and set the theme if we're building docs locally
    import sphinx_rtd_theme
    html_theme = 'sphinx_rtd_theme'
    html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# otherwise, readthedocs.org uses their theme by default, so no need to specify it
Run Code Online (Sandbox Code Playgroud)