-try:
- import sphinxcontrib.napoleon
- extensions += ['sphinxcontrib.napoleon']
-except:
- pass
-try:
- import sphinx_rtd_theme
- extensions += ['sphinx_rtd_theme']
- use_rtd_theme = True
-except:
- use_rtd_theme = False
+# Optional extensions
+extra_extensions = ['sphinx_rtd_theme']
+if sphinx.version_info[:2] < (1,3):
+ extra_extensions += ['sphinxcontrib.napoleon']
+else:
+ extra_extensions += ['sphinx.ext.napoleon']
+for ext in extra_extensions:
+ try:
+ importlib.import_module(ext)
+ extensions.append(ext)
+ globals().update({'use_{}'.format(ext):True})
+ except:
+ globals().update({'use_{}'.format(ext):False})