如何轻松进行本地Sphinx构建并使用readthedocs.org的静态资源?
目前,我找到的唯一方法是安装 完整主题,然后进行构建,这个过程需要用到 SASS 等工具。
我希望能直接获取一套静态文件,这样我就可以在本地查看我的项目在 readthedocs 上的样子。有没有办法在不自己从上面的链接构建这些文件的情况下做到这一点?我的目标是让新手也能轻松地为文档做贡献。
1 个回答
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