Skip to content

Commit

Permalink
DOC: add binder links to examples (scikit-learn#11221)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesteve authored and jnothman committed Aug 19, 2019
1 parent 35c0ca0 commit f0faaee
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 5 additions & 0 deletions doc/binder/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# A binder requirement file is required by sphinx-gallery. We don't really need
# one since the binder requirement files live in the
# scikit-learn/binder-examples repo and not in the scikit-learn.github.io repo
# that comes from the scikit-learn doc build. This file can be removed if
# 'dependencies' is made an optional key for binder in sphinx-gallery.
26 changes: 25 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import sys
import os
import warnings
import re

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

if 'dev' in version:
binder_branch = 'master'
else:
match = re.match(r'^(\d+)\.(\d+)(?:\.\d+)?$', version)
if match is None:
raise ValueError(
'Ill-formed version: {!r}. Expected either '
"a version containing 'dev' "
'or a version like X.Y or X.Y.Z.'.format(version))

major, minor = match.groups()
binder_branch = '{}.{}.X'.format(major, minor)

sphinx_gallery_conf = {
'doc_module': 'sklearn',
'backreferences_dir': os.path.join('modules', 'generated'),
'show_memory': True,
'reference_url': {
'sklearn': None}
'sklearn': None},
'examples_dirs': ['../examples'],
'gallery_dirs': ['auto_examples'],
'binder': {
'org': 'scikit-learn',
'repo': 'binder-examples',
'binderhub_url': 'https://mybinder.org',
'branch': binder_branch,
'dependencies': './binder/requirements.txt',
'use_jupyter_lab': True
}
}


Expand Down

0 comments on commit f0faaee

Please sign in to comment.