将 Read The Docs & Sphinx 与 ReadTheDocs 主题一起使用时删除 Github link 上的编辑

Removing the Edit on Github link when using Read The Docs & Sphinx with ReadTheDocs Theme

我正在尝试找出如何使用 Sphinx 中的 _template overrides 选项来覆盖默认的 ReadTheDocs 主题,以便在 http://readthedocs.org 上托管 Sphinx 文档。

具体来说,我想要 remove/hide 这个主题右上角显示的 "Edit on Github" link。

如有任何提示,我们将不胜感激!谢谢!

我已经查看了这里的文档:http://www.sphinx-doc.org/en/stable/templating.html,但是,我很困惑,真的需要一些帮助。

谢谢!

好的,我明白了,所以我会回答我自己的问题,希望能帮助到其他人。

假设您使用的是 ReadTheDocs 默认主题,这应该可以正常工作。

  • 将 ReadTheDocs 主题从 Github 存储库克隆到您的计算机。 (https://github.com/snide/sphinx_rtd_theme/)
  • 找到 breadcrumbs.html 文件(https://github.com/snide/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/breadcrumbs.html
  • breadcrumbs.html 文件添加到 _templates 文件夹中的 Sphinx 文档文件夹。 如果此目录尚不存在,您需要创建它。
  • 在您的 conf.py 文件中找到您的 html_context 部分,如果您还没有这个,您可以创建它。 (示例链接如下)。

    html_context = { "display_github": False, # Add 'Edit on Github' link instead of 'View page source' "last_updated": True, "commit": False, }

  • 使用 Git

  • breadcrumbs.html 文件添加到您的跟踪文件
  • 提交对您的 conf.py
  • 的更改
  • 推送到远程 Github 存储库
  • 利润

参考资料

阅读文档文档有类似的说明:https://docs.readthedocs.io/en/latest/guides/remove-edit-buttons.html#。因此,自发布原始答案以来,可能已经进行了基础代码更改。

我的需求非常相似但不完全相同。我想为生成的页面("search" 和 "genindex")删除这个 link,并更改 link 文本,因为我们使用 framagit 作为项目托管。

最后是我的版本:

{%- extends "sphinx_rtd_theme/breadcrumbs.html" %}

{% block breadcrumbs_aside %}
  <li class="wy-breadcrumbs-aside">
    {% if hasdoc(pagename) and pagename != "search" and pagename != "genindex" %}
      <a href="{{ meta['framagit_url'] }}" class="fa fa-bitbucket"> {{ _('Edit on FramaGit') }}</a>
    {% endif %}
  </li>
{% endblock %}

现场观看: https://framagit.org/simgrid/simgrid/tree/master/docs/source