mirror of
https://github.com/ceph/ceph
synced 2026-08-02 07:03:18 +00:00
doc: remove edit_on_github sphinx extension
Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
5c9fbc7948
commit
be26c566e5
@ -1,43 +0,0 @@
|
||||
"""
|
||||
Adapted from https://gist.github.com/mgedmin/6052926
|
||||
|
||||
Sphinx extension to add ReadTheDocs-style "Edit on GitHub" links to the
|
||||
sidebar.
|
||||
|
||||
Loosely based on https://github.com/astropy/astropy/pull/347
|
||||
"""
|
||||
|
||||
import os
|
||||
import warnings
|
||||
|
||||
|
||||
__licence__ = 'BSD (3 clause)'
|
||||
|
||||
|
||||
def get_github_url(app, view, path):
|
||||
return 'https://github.com/{project}/{view}/{branch}/doc/{path}'.format(
|
||||
project=app.config.edit_on_github_project,
|
||||
view=view,
|
||||
branch=app.config.edit_on_github_branch,
|
||||
path=path)
|
||||
|
||||
|
||||
def html_page_context(app, pagename, templatename, context, doctree):
|
||||
if templatename != 'page.html':
|
||||
return
|
||||
|
||||
if not app.config.edit_on_github_project:
|
||||
warnings.warn("edit_on_github_project not specified")
|
||||
return
|
||||
|
||||
path = os.path.relpath(doctree.get('source'), app.builder.srcdir)
|
||||
show_url = get_github_url(app, 'blob', path)
|
||||
edit_url = get_github_url(app, 'edit', path)
|
||||
|
||||
context['show_on_github_url'] = show_url
|
||||
context['edit_on_github_url'] = edit_url
|
||||
|
||||
def setup(app):
|
||||
app.add_config_value('edit_on_github_project', '', True)
|
||||
app.add_config_value('edit_on_github_branch', 'master', True)
|
||||
app.connect('html-page-context', html_page_context)
|
||||
33
doc/_static/js/ceph.js
vendored
33
doc/_static/js/ceph.js
vendored
@ -1,24 +1,6 @@
|
||||
$(function() {
|
||||
var releases_url = DOCUMENTATION_OPTIONS.URL_ROOT + '_static/releases.json';
|
||||
|
||||
function show_edit(branch, data) {
|
||||
if (branch) {
|
||||
if (branch === "master") {
|
||||
$("#dev-warning").show();
|
||||
return true;
|
||||
}
|
||||
if (data && data.releases && branch in data.releases) {
|
||||
var eol = ("actual_eol" in data.releases[branch]);
|
||||
if (eol) {
|
||||
$("#eol-warning").show();
|
||||
}
|
||||
return !eol;
|
||||
}
|
||||
}
|
||||
$("#dev-warning").show();
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_branch() {
|
||||
var pathname = window.location.pathname;
|
||||
var res = pathname.match(/en\/([a-z]+)\/?/i)
|
||||
@ -30,14 +12,15 @@ $(function() {
|
||||
|
||||
$.getJSON(releases_url, function(data) {
|
||||
var branch = get_branch();
|
||||
if (show_edit(branch, data)) {
|
||||
// patch the edit-on-github URL for correct branch
|
||||
var url = $("#edit-on-github").attr("href");
|
||||
if (url) {
|
||||
url = url.replace("master", branch);
|
||||
$("#edit-on-github").attr("href", url);
|
||||
if (branch === "master") {
|
||||
$("#dev-warning").show();
|
||||
} else if (data && data.releases && branch in data.releases) {
|
||||
var eol = ("actual_eol" in data.releases[branch]);
|
||||
if (eol) {
|
||||
$("#eol-warning").show();
|
||||
}
|
||||
$("#docubetter").show();
|
||||
} else {
|
||||
$("#dev-warning").show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
6
doc/_templates/page.html
vendored
6
doc/_templates/page.html
vendored
@ -11,11 +11,5 @@
|
||||
<p class="last">This document is for an unsupported version of Ceph.</p>
|
||||
</div>
|
||||
|
||||
{%- if edit_on_github_url %}
|
||||
<div id="docubetter" align="right" style="display:none; padding: 15px; font-weight: bold;">
|
||||
<a id="edit-on-github" href="{{ edit_on_github_url }}" rel="nofollow">{{ _('Edit on GitHub')}}</a> | <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
|
||||
</div>
|
||||
{%- endif %}
|
||||
|
||||
{{ super() }}
|
||||
{% endblock %}
|
||||
|
||||
@ -79,7 +79,6 @@ extensions = [
|
||||
'sphinx_autodoc_typehints',
|
||||
'sphinx_substitution_extensions',
|
||||
'breathe',
|
||||
'edit_on_github',
|
||||
'ceph_releases',
|
||||
'sphinxcontrib.openapi'
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user