Skip to content

Commit

Permalink
Remove "Edit on..." button on autogenerated docs
Browse files Browse the repository at this point in the history
Remove the "Edit on GitHub" button on doc pages that are autogenerated
by Sphinx's `autosummary` extension, because these doc pages do not have
a source file on GitHub.

See
sphinx-doc/sphinx#2386 (comment)
  • Loading branch information
andthum committed Aug 12, 2021
1 parent f7da907 commit 14899fe
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 14 deletions.
15 changes: 15 additions & 0 deletions docs/source/_templates/breadcrumbs.html
@@ -0,0 +1,15 @@
<!--
Custom template to remove the "Edit on ..." button in the header of doc
pages hosted by Read the Docs. See
https://docs.readthedocs.io/en/stable/guides/remove-edit-buttons.html
and
https://github.com/sphinx-doc/sphinx/issues/2386#issuecomment-478403897
-->

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

{% block breadcrumbs_aside %}
{% if not meta or meta.get('github_url') != 'hide' %}
{{ super() }}
{% endif %}
{% endblock %}
2 changes: 2 additions & 0 deletions docs/source/_templates/custom-attribute-template.rst
@@ -1,3 +1,5 @@
:github_url: hide

{{ name | escape | underline}}

.. currentmodule:: {{ module }}
Expand Down
9 changes: 5 additions & 4 deletions docs/source/_templates/custom-class-template.rst
Expand Up @@ -7,18 +7,19 @@
and
https://sphinx-autosummary-recursion.readthedocs.io/en/latest/index.html
:github_url: hide

{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:members:

{% block methods %}
{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
:template: custom-method-template.rst
:nosignatures:
Expand All @@ -29,11 +30,11 @@
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
:template: custom-attribute-template.rst
:nosignatures:
Expand Down
2 changes: 2 additions & 0 deletions docs/source/_templates/custom-function-template.rst
@@ -1,3 +1,5 @@
:github_url: hide

{{ name | escape | underline}}

.. currentmodule:: {{ module }}
Expand Down
2 changes: 2 additions & 0 deletions docs/source/_templates/custom-method-template.rst
@@ -1,3 +1,5 @@
:github_url: hide

{{ name | escape | underline}}

.. currentmodule:: {{ module }}
Expand Down
17 changes: 9 additions & 8 deletions docs/source/_templates/custom-module-template.rst
Expand Up @@ -7,15 +7,16 @@
and
https://sphinx-autosummary-recursion.readthedocs.io/en/latest/index.html
:github_url: hide

{{ name | escape | underline}}

.. automodule:: {{ fullname }}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Module Attributes') }}

.. autosummary::
:toctree:
:template: custom-attribute-template.rst
Expand All @@ -25,11 +26,11 @@
{%- endfor %}
{% endif %}
{% endblock %}

{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}

.. autosummary::
:toctree:
:template: custom-function-template.rst
Expand All @@ -39,11 +40,11 @@
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}

.. autosummary::
:toctree:
:template: custom-class-template.rst
Expand All @@ -53,11 +54,11 @@
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}

.. autosummary::
:toctree:
:nosignatures:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Expand Up @@ -302,11 +302,11 @@

# If True, the reStructuredText sources are included in the HTML build
# as _sources/name.
html_copy_source = False
html_copy_source = True

# If True (and html_copy_source is True as well), links to the
# reStructuredText sources will be added to the sidebar.
html_show_sourcelink = False
html_show_sourcelink = True

# If nonempty, an OpenSearch description file will be output, and all
# pages will contain a <link> tag referring to it. the value of this
Expand Down

0 comments on commit 14899fe

Please sign in to comment.