8000 [MRG] DOC: add binder links to examples by lesteve · Pull Request #11221 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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