Skip to content
Snippets Groups Projects
Commit 951fb7fd authored by vlorentz's avatar vlorentz
Browse files

Fix 'View page source' link for all pages outside swh-docs/

parent 5ad54e70
No related branches found
No related tags found
No related merge requests found
{% extends "!breadcrumbs.html" %}
{# Overrides RTD's default "View page source" link formatting, which
forces the full page name in the link; but we don't want it because
page names include the repo, eg. "swh-model/index".
The view_in_phabricator.py extension sets swh_source_url to
".../source/swh-model/browse/master/docs/index"
#}
{%- block breadcrumbs_aside %}
foo
<li class="wy-breadcrumbs-aside">
{%- if hasdoc(pagename) and display_vcs_links %}
<a href="{{ swh_source_url }}{{ page_source_suffix }}">{{ _('View page source') }}</a>
{% endif %}
</li>
{%- endblock %}
......@@ -16,15 +16,18 @@ def html_page_context(app, pagename, templatename, context, doctree):
return
elif pagename.startswith("swh-"):
# .rst from a package's docs/ directory
repository = pagename.split("/", 1)[0]
path = "docs/"
(repository, _, path) = pagename.partition("/")
else:
# .rst from swh-docs/docs/
repository = "swh-docs"
path = "docs/"
context[
"source_url_prefix"
] = f"https://forge.softwareheritage.org/source/{repository}/browse/master/{path}"
path = pagename
source_url = (
f"https://forge.softwareheritage.org/source/{repository}"
f"/browse/master/docs/{path}"
)
# Set a variable that can be used by swh-docs/docs/_templates/breadcrumbs.html:
context["swh_source_url"] = source_url
def setup(app):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment