8000 DOC: add binder links to examples (#11221) · scikit-learn/scikit-learn@f0faaee · GitHub
[go: up one dir, main page]

Skip to content

Commit f0faaee

Browse files
lestevejnothman
authored andcommitted
DOC: add binder links to examples (#11221)
1 parent 35c0ca0 commit f0faaee

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

doc/binder/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# A binder requirement file is required by sphinx-gallery. We don't really need
2+
# one since the binder requirement files live in the
3+
# scikit-learn/binder-examples repo and not in the scikit-learn.github.io repo
4+
# that comes from the scikit-learn doc build. This file can be removed if
5+
# 'dependencies' is made an optional key for binder in sphinx-gallery.

doc/conf.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sys
1616
import os
1717
import warnings
18+
import re
1819

1920
# If extensions (or modules to document with autodoc) are in another
2021
# directory, add these directories to sys.path here. If the directory
@@ -247,12 +248,35 @@
247248
'joblib': ('https://joblib.readthedocs.io/en/latest/', None),
248249
}
249250

251+
if 'dev' in version:
252+
binder_branch = 'master'
253+
else:
254+
match = re.match(r'^(\d+)\.(\d+)(?:\.\d+)?$', version)
255+
if match is None:
256+
raise ValueError(
257+
'Ill-formed version: {!r}. Expected either '
258+
"a version containing 'dev' "
259+
'or a version like X.Y or X.Y.Z.'.format(version))
260+
261+
major, minor = match.groups()
262+
binder_branch = '{}.{}.X'.format(major, minor)
263+
250264
sphinx_gallery_conf = {
251265
'doc_module': 'sklearn',
252266
'backreferences_dir': os.path.join('modules', 'generated'),
253267
'show_memory': True,
254268
'reference_url': {
255-
'sklearn': None}
269+
'sklearn': None},
270+
'examples_dirs': ['../examples'],
271+
'gallery_dirs': ['auto_examples'],
272+
'binder': {
273+
'org': 'scikit-learn',
274+
'repo': 'binder-examples',
275+
'binderhub_url': 'https://mybinder.org',
276+
'branch': binder_branch,
277+
'dependencies': './binder/requirements.txt',
278+
'use_jupyter_lab': True
279+
}
256280
}
257281

258282

0 commit comments

Comments
 (0)
0