Skip to content

Commit b442f0d

Browse files
committed
further improvements
1 parent 43ecbe3 commit b442f0d

File tree

4 files changed

+30
-51
lines changed

4 files changed

+30
-51
lines changed

_templates/nb-badges.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- Generate correct links and render github/binder/colab badges -->
2+
{% set gh_basepath = github_user + '/' + github_repo + '/blob/' + github_version + '/' %}
3+
{% set encoded_base = github_user + '%252F' + github_repo %}
4+
{% set gh_binder = github_user + '/' + github_repo + '/' + github_version %}
5+
{% set doc_path_aux = doc_path | trim('/') %}
6+
{% set file_path = doc_path_aux + '/' + pagename + page_source_suffix %}
7+
{% set encoded_path = file_path | replace("/", "%252F") %}
8+
9+
10+
<div class="sd-text-right">
11+
<p>
12+
<a href="{{ github_url + '/' + gh_basepath + file_path }}", role="button" target="_blank">
13+
<img src="{{ pathto('_static/github.svg', 1) }}" alt="View On GitHub"></a>
14+
15+
<a href="{{ 'https://mybinder.org/v2/gh/' + sandbox_repo + '?urlpath=git-pull%3Frepo%3Dhttps%253A%252F%252Fgithub.com%252F' + encoded_base + '%26urlpath%3Dtree%252F' + github_repo + '%252F' + encoded_path + '%26branch%3D' + github_version }}" target="_blank">
16+
<img src="{{ pathto('_static/binder.svg', 1) }}" alt="Open In Binder"></a>
17+
18+
<a href="{{ 'https://colab.research.google.com/github/' + gh_basepath + file_path }}" target="_blank">
19+
<img src="{{ pathto('_static/colab.svg', 1) }}" alt="Open In Colab"/></a>
20+
</p>
21+
</div>

_templates/page.html

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,7 @@
22
{% block body %}
33
<!-- Add github/binder/colab badges here? or on the sidebar better? -->
44
{% if pagename in ablog %}
5-
6-
{% set gh_basepath = github_user + '/' + github_repo + '/blob/' + github_version + '/' %}
7-
{% set gh_binder = github_user + '/' + github_repo + '/' + github_version %}
8-
{% set doc_path_aux = doc_path | trim('/') %}
9-
{% set file_path = doc_path_aux + '/' + pagename + page_source_suffix %}
10-
11-
<div class="sd-text-right">
12-
<p>
13-
<a href="{{ github_url + '/' + gh_basepath + file_path }}", role="button" target="_blank">
14-
<img src="{{ pathto('_static/github.svg', 1) }}" alt="View On GitHub">
15-
</a>
16-
17-
<a href="{{ 'https://mybinder.org/v2/gh/' + gh_binder + '?filepath=' + file_path }}" target="_blank">
18-
<img src="{{ pathto('_static/binder.svg', 1) }}" alt="Open In Binder">
19-
</a>
20-
21-
<a href="{{ 'https://colab.research.google.com/github/' + gh_basepath + file_path }}" target="_blank">
22-
<img src="{{ pathto('_static/colab.svg', 1) }}" alt="Open In Colab"/>
23-
</a>
24-
</p>
25-
</div>
5+
{% include "nb-badges.html" %}
266
{% endif %}
277

288
{{ body }}

_templates/postcard.html

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
<nav class="bd-links" id="bd-docs-nav" aria-label="{{ _('Main navigation') }}">
2-
<div class="bd-toc-item active">
31
{% if pagename in ablog %}
42
{% set fa = ablog.fontawesome %}
53
{% set post = ablog[pagename] %}
@@ -40,11 +38,3 @@ <h3>Notebook metadata</h3>
4038
{% endif %}
4139
</ul>
4240
{% endif %}
43-
44-
<!-- Workaround to make the whole sidebar scrollable. See https://github.com/pydata/pydata-sphinx-theme/issues/500 -->
45-
{% include "tagcloud.html" %}
46-
{% include "categories.html" %}
47-
{% include "sidebar-ethical-ads.html" %}
48-
49-
</div>
50-
</nav>

examples/conf.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
1-
# Configuration file for the Sphinx documentation builder.
2-
#
3-
# This file only contains a selection of the most common options. For a full
4-
# list see the documentation:
5-
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6-
7-
# -- Path setup --------------------------------------------------------------
8-
9-
# If extensions (or modules to document with autodoc) are in another directory,
10-
# add these directories to sys.path here. If the directory is relative to the
11-
# documentation root, use os.path.abspath to make it absolute, like shown here.
12-
#
13-
# import os
14-
# import sys
15-
# sys.path.insert(0, os.path.abspath('.'))
1+
import os
162

173

184
# -- Project information -----------------------------------------------------
19-
205
project = "PyMC"
216
copyright = "2021, PyMC Community"
227
author = "PyMC Community"
@@ -82,12 +67,15 @@
8267
{"name": "API", "url": "https://docs.pymc.io/en/stable/api.html"},
8368
],
8469
}
70+
version = os.environ.get("READTHEDOCS_VERSION", "")
71+
version = version if "-" in version else "main"
8572
html_context = {
8673
"github_url": "https://github.com",
8774
"github_user": "pymc-devs",
8875
"github_repo": "pymc-examples",
89-
"github_version": "main",
76+
"github_version": version,
9077
"doc_path": "examples/",
78+
"sandbox_repo": f"pymc-devs/pymc-sandbox/{version}",
9179
}
9280

9381

@@ -105,9 +93,9 @@
10593
"**": [
10694
# "sidebar-nav-bs.html",
10795
"postcard.html",
108-
# "tagcloud.html",
109-
# "categories.html",
110-
# "sidebar-ethical-ads.html",
96+
"tagcloud.html",
97+
"categories.html",
98+
"sidebar-ethical-ads.html",
11199
],
112100
}
113101

0 commit comments

Comments
 (0)