问题
I'm trying to find out how to use the _template overrides option in Sphinx to override the default ReadTheDocs theme for hosting Sphinx documentation on http://readthedocs.org.
Specifically, I'm wanting to remove/hide the "Edit on Github" link shown in the upper right hand corner of this theme.
Any tips would be greatly appreciated! Thanks!
I've reviewed the documentation here: http://www.sphinx-doc.org/en/stable/templating.html, however, I'm stumped and really need some help.
Thank you!
回答1:
Okay, I figured it out so I'll answer my own inquiry in hopes to assist others.
Assuming you're using the ReadTheDocs default theme this should work just fine.
- Clone the ReadTheDocs theme from the Github repo to your computer. (https://github.com/snide/sphinx_rtd_theme/)
- Locate
breadcrumbs.html
file (https://github.com/snide/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/breadcrumbs.html) - Add
breadcrumbs.html
file to your Sphinx documentation folder in the_templates
folder. If this directory doesn't yet exist you'll need to create it. In your
conf.py
file locate yourhtml_context
section, if you do not already have this, you can create it. (Sample linked below).html_context = { "display_github": False, # Add 'Edit on Github' link instead of 'View page source' "last_updated": True, "commit": False, }
Add the
breadcrumbs.html
file to your tracked files usingGit
- Commit the changes to your
conf.py
- Push to remote Github repo
- Profit
References
- https://github.com/duelingdogs/dueling-docs/blob/master/source/conf.py#L36-L40
- http://help.duelingdogs.net/en/latest/ (Example showing that the
Edit on Github
option is now removed.
回答2:
My needs was very similar but not exactly the same. I wanted to both remove this link for generated pages ("search" and "genindex"), and change the link text because we use framagit as a project hosting.
Here is my version at the end:
{%- 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 %}
See it live here: https://framagit.org/simgrid/simgrid/tree/master/docs/source
回答3:
The Read the Docs documentation has similar instructions: https://docs.readthedocs.io/en/latest/guides/remove-edit-buttons.html#. So perhaps there've been underlying code changes since the original answer was posted.
来源:https://stackoverflow.com/questions/36019670/removing-the-edit-on-github-link-when-using-read-the-docs-sphinx-with-readthed