Skip to content

Commit 69a80c0

Browse files
glemaitrechkoar
authored andcommitted
DOC fix intersphinx (scikit-learn-contrib#356)
1 parent 9b132f3 commit 69a80c0

File tree

1 file changed

+58
-60
lines changed

1 file changed

+58
-60
lines changed

doc/conf.py

Lines changed: 58 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,17 @@
1414

1515
import os
1616
import sys
17-
1817
import sphinx_rtd_theme
18+
from sklearn.externals.six import u
1919

2020
# If extensions (or modules to document with autodoc) are in another directory,
2121
# add these directories to sys.path here. If the directory is relative to the
2222
# documentation root, use os.path.abspath to make it absolute, like shown here.
23-
# sys.path.insert(0, os.path.abspath('.'))
24-
25-
# -- General configuration ---------------------------------------------------
26-
27-
# Try to override the matplotlib configuration as early as possible
28-
try:
29-
import gen_rst
30-
except:
31-
pass
32-
# -- General configuration ------------------------------------------------
33-
34-
35-
# If extensions (or modules to document with autodoc) are in another
36-
# directory, add these directories to sys.path here. If the directory
37-
# is relative to the documentation root, use os.path.abspath to make it
38-
# absolute, like shown here.
3923
sys.path.insert(0, os.path.abspath('sphinxext'))
40-
4124
from github_link import make_linkcode_resolve
25+
import sphinx_gallery
26+
27+
# -- General configuration ------------------------------------------------
4228

4329
# If your documentation needs a minimal Sphinx version, state it here.
4430
# needs_sphinx = '1.0'
@@ -47,34 +33,30 @@
4733
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4834
# ones.
4935
extensions = [
50-
'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx',
51-
'sphinx.ext.todo', 'sphinx.ext.imgmath', 'sphinx.ext.ifconfig',
52-
'sphinx.ext.viewcode', 'sphinx_gallery.gen_gallery',
53-
'sphinx.ext.autosummary', 'numpydoc', 'sphinx.ext.intersphinx',
54-
'sphinx_issues', 'sphinx.ext.linkcode'
36+
'sphinx.ext.autodoc',
37+
'sphinx.ext.autosummary',
38+
'sphinx.ext.doctest',
39+
'sphinx.ext.intersphinx',
40+
'sphinx.ext.linkcode',
41+
'sphinx.ext.viewcode',
42+
'numpydoc',
43+
'sphinx_issues',
44+
'sphinx_gallery.gen_gallery',
5545
]
5646

57-
autosummary_generate = True
47+
# this is needed for some reason...
48+
# see https://github.com/numpy/numpydoc/issues/69
5849
numpydoc_show_class_members = False
5950

60-
autodoc_default_flags = ['members', 'inherited-members']
51+
# pngmath / imgmath compatibility layer for different sphinx versions
52+
import sphinx
53+
from distutils.version import LooseVersion
54+
if LooseVersion(sphinx.__version__) < LooseVersion('1.4'):
55+
extensions.append('sphinx.ext.pngmath')
56+
else:
57+
extensions.append('sphinx.ext.imgmath')
6158

62-
sphinx_gallery_conf = {
63-
# path to your examples scripts
64-
'examples_dirs': '../examples',
65-
# path where to save gallery generated examples
66-
'gallery_dirs': 'auto_examples',
67-
# to make references clickable
68-
'doc_module': 'imblearn',
69-
'backreferences_dir': os.path.join('generated'),
70-
'reference_url': {
71-
'imblearn': None,
72-
'sklearn': None,
73-
'matplotlib': None,
74-
'numpy': None,
75-
'scipy': None
76-
}
77-
}
59+
autodoc_default_flags = ['members', 'inherited-members']
7860

7961
# Add any paths that contain templates here, relative to this directory.
8062
templates_path = ['_templates']
@@ -88,15 +70,15 @@
8870
# The encoding of source files.
8971
# source_encoding = 'utf-8-sig'
9072

91-
# Generate the plots for the gallery
73+
# Generate the plot for the gallery
9274
plot_gallery = True
9375

9476
# The master toctree document.
9577
master_doc = 'index'
9678

9779
# General information about the project.
98-
project = u'imbalanced-learn'
99-
copyright = u'2016, G. Lemaitre, F. Nogueira, D. Oliveira, C. Aridas'
80+
project = u('imbalanced-learn')
81+
copyright = u('2016 - 2017, G. Lemaitre, F. Nogueira, D. Oliveira, C. Aridas')
10082

10183
# The version info for the project you're documenting, acts as replacement for
10284
# |version| and |release|, also used in various other places throughout the
@@ -120,7 +102,7 @@
120102

121103
# List of patterns, relative to source directory, that match files and
122104
# directories to ignore when looking for source files.
123-
exclude_patterns = ['_build']
105+
exclude_patterns = ['_build', '_templates']
124106

125107
# The reST default role (used for this markup: `text`) to use for all
126108
# documents.
@@ -250,8 +232,8 @@
250232
# (source start file, target name, title,
251233
# author, documentclass [howto, manual, or own class]).
252234
latex_documents = [
253-
('index', 'imbalanced-learn.tex', u'imbalanced-learn Documentation',
254-
u'G. Lemaitre, F. Nogueira, D. Oliveira, C. Aridas', 'manual'),
235+
('index', 'imbalanced-learn.tex', u('imbalanced-learn Documentation'),
236+
u('G. Lemaitre, F. Nogueira, D. Oliveira, C. Aridas'), 'manual'),
255237
]
256238

257239
# The name of an image file (relative to this directory) to place at the top of
@@ -271,10 +253,29 @@
271253
# Documents to append as an appendix to all manuals.
272254
# latex_appendices = []
273255

256+
# intersphinx configuration
257+
intersphinx_mapping = {
258+
'python': ('https://docs.python.org/{.major}'.format(
259+
sys.version_info), None),
260+
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
261+
'scipy': ('https://docs.scipy.org/doc/scipy/reference', None),
262+
'matplotlib': ('https://matplotlib.org/', None),
263+
'sklearn': ('http://scikit-learn.org/stable', None)
264+
}
265+
266+
# sphinx-gallery configuration
267+
sphinx_gallery_conf = {
268+
'doc_module': 'imblearn',
269+
'backreferences_dir': os.path.join('generated'),
270+
'reference_url': {
271+
'imblearn': None}
272+
}
273+
274+
# -- Options for manual page output ---------------------------------------
275+
274276
# If false, no module index is generated.
275277
# latex_domain_indices = True
276278

277-
# -- Options for manual page output ---------------------------------------
278279

279280
# One entry per manual page. List of tuples
280281
# (source start file, name, description, authors, manual section).
@@ -296,14 +297,14 @@
296297
]
297298

298299

299-
def generate_example_rst(app, what, name, obj, options, lines):
300-
# generate empty examples files, so that we don't get
301-
# inclusion errors if there are no examples for a class / module
302-
examples_path = os.path.join(app.srcdir, "generated",
303-
"%s.examples" % name)
304-
if not os.path.exists(examples_path):
305-
# touch file
306-
open(examples_path, 'w').close()
300+
# def generate_example_rst(app, what, name, obj, options, lines):
301+
# # generate empty examples files, so that we don't get
302+
# # inclusion errors if there are no examples for a class / module
303+
# examples_path = os.path.join(app.srcdir, "generated",
304+
# "%s.examples" % name)
305+
# if not os.path.exists(examples_path):
306+
# # touch file
307+
# open(examples_path, 'w').close()
307308

308309

309310
# Config for sphinx_issues
@@ -315,7 +316,7 @@ def generate_example_rst(app, what, name, obj, options, lines):
315316

316317
def setup(app):
317318
app.add_javascript('js/copybutton.js')
318-
app.connect('autodoc-process-docstring', generate_example_rst)
319+
# app.connect('autodoc-process-docstring', generate_example_rst)
319320

320321

321322
# Documents to append as an appendix to all manuals.
@@ -330,9 +331,6 @@ def setup(app):
330331
# If true, do not generate a @detailmenu in the "Top" node's menu.
331332
# texinfo_no_detailmenu = False
332333

333-
# Example configuration for intersphinx: refer to the Python standard library.
334-
intersphinx_mapping = {'http://docs.python.org/': None}
335-
336334
# The following is used by sphinx.ext.linkcode to provide links to github
337335
linkcode_resolve = make_linkcode_resolve('imblearn',
338336
u'https://github.com/scikit-learn-contrib/'

0 commit comments

Comments
 (0)