用于集成Sphinx分站工具
项目描述
sphinx-affiliates
允许搜索包含多个 Sphinx文档 html站点的文档。
当您有一个组织下的多个github仓库,并使用sphinx为它们构建文档,使用github pages提供工件时,这很有用。当您为组织中的一个仓库配置一个 自定义域名,例如 https://my.site.org
,任何其他仓库的github pages(例如repo2)将作为 https://my.site.org/repo2
显示。但是,这些站点的 search.html
将不知道对方:它们将完全独立。此扩展将通过以下方式解决这个问题:
- 将搜索引擎更改为允许加载多个索引
- 将搜索索引生成过程更改为生成一个额外的索引
- 添加配置选项,将来自分站的其他索引添加到
search.html
页面。
要使用此功能,请通过 pip
安装它,并在您的 conf.py
中添加如下内容:
extensions = [
'sphinx_affiliates', # Add the extension
]
# Where this site's build is hosted, this will be the URL for all the search
# results from this site.
affiliate_options = {
'canonical_url': "https://affiliate_search.github.io",
}
# Other sites to add to the search of this site. HTTP urls may get blocked
# as cross-site scripting
sphinx_affiliates = [
'../other_repo1/affiliate_searchindex.js',
'https://affiliate_search.github.io/other_repo2/affiliate_searchindex.js',
]