Skip to content

Commit f3714c1

Browse files
DOC/BLD: doc building with python 3 (#15012)
* DOC/BLD: only use mpl.use once to prevent warnings * DOC/BLD: make the custom accessor documenters py3 compat - give lower priority (eg if both MethodDocumenter and AccessorMethodDocumenter have priority 1, in python 3 one of both is randomly chosen, also for normal methods (because the can_document_member method cannot distinguish both) - adapt templates (module and objname were differently split between py2 and py3) * DOC/BLD: add specific AccessorDocumenter to prevent warning 'error while formatting arguments' during doc build * DOC/BLD: switch travis dev doc building to python 3.5 * fix dateutil specification * fix beatifulsoup package name for python 3
1 parent d2a4b33 commit f3714c1

10 files changed

+34
-11
lines changed

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ matrix:
182182
- CACHE_NAME="35_ascii"
183183
- USE_CACHE=true
184184
# In allow_failures
185-
- python: 2.7
185+
- python: 3.5
186186
env:
187-
- PYTHON_VERSION=2.7
187+
- PYTHON_VERSION=3.5
188188
- JOB_NAME: "doc_build"
189189
- FULL_DEPS=true
190190
- DOC_BUILD=true
@@ -275,9 +275,9 @@ matrix:
275275
- LOCALE_OVERRIDE="C"
276276
- CACHE_NAME="35_ascii"
277277
- USE_CACHE=true
278-
- python: 2.7
278+
- python: 3.5
279279
env:
280-
- PYTHON_VERSION=2.7
280+
- PYTHON_VERSION=3.5
281281
- JOB_NAME: "doc_build"
282282
- FULL_DEPS=true
283283
- DOC_BUILD=true
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
dateutil
1+
python-dateutil
22
pytz
33
numpy
44
cython

ci/requirements-2.7_DOC_BUILD.run renamed to ci/requirements-3.5_DOC_BUILD.run

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ notebook
77
matplotlib
88
scipy
99
lxml
10-
beautiful-soup
10+
beautifulsoup4
1111
html5lib
1212
pytables
1313
openpyxl=1.8.5
File renamed without changes.

doc/_templates/autosummary/accessor.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
.. currentmodule:: {{ module.split('.')[0] }}
55

6-
.. automethod:: {{ [module.split('.')[1], objname]|join('.') }}
6+
.. autoaccessor:: {{ (module.split('.')[1:] + [objname]) | join('.') }}

doc/_templates/autosummary/accessor_attribute.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
.. currentmodule:: {{ module.split('.')[0] }}
55

6-
.. autoaccessorattribute:: {{ [module.split('.')[1], objname]|join('.') }}
6+
.. autoaccessorattribute:: {{ (module.split('.')[1:] + [objname]) | join('.') }}

doc/_templates/autosummary/accessor_callable.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
.. currentmodule:: {{ module.split('.')[0] }}
55

6-
.. autoaccessorcallable:: {{ [module.split('.')[1], objname]|join('.') }}.__call__
6+
.. autoaccessorcallable:: {{ (module.split('.')[1:] + [objname]) | join('.') }}.__call__

doc/_templates/autosummary/accessor_method.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
.. currentmodule:: {{ module.split('.')[0] }}
55

6-
.. autoaccessormethod:: {{ [module.split('.')[1], objname]|join('.') }}
6+
.. autoaccessormethod:: {{ (module.split('.')[1:] + [objname]) | join('.') }}

doc/source/conf.py

+23
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,23 @@
326326
from sphinx.ext.autosummary import Autosummary
327327

328328

329+
class AccessorDocumenter(MethodDocumenter):
330+
"""
331+
Specialized Documenter subclass for accessors.
332+
"""
333+
334+
objtype = 'accessor'
335+
directivetype = 'method'
336+
337+
# lower than MethodDocumenter so this is not chosen for normal methods
338+
priority = 0.6
339+
340+
def format_signature(self):
341+
# this method gives an error/warning for the accessors, therefore
342+
# overriding it (accessor has no arguments)
343+
return ''
344+
345+
329346
class AccessorLevelDocumenter(Documenter):
330347
"""
331348
Specialized Documenter subclass for objects on accessor level (methods,
@@ -381,12 +398,17 @@ class AccessorAttributeDocumenter(AccessorLevelDocumenter, AttributeDocumenter):
381398
objtype = 'accessorattribute'
382399
directivetype = 'attribute'
383400

401+
# lower than AttributeDocumenter so this is not chosen for normal attributes
402+
priority = 0.6
384403

385404
class AccessorMethodDocumenter(AccessorLevelDocumenter, MethodDocumenter):
386405

387406
objtype = 'accessormethod'
388407
directivetype = 'method'
389408

409+
# lower than MethodDocumenter so this is not chosen for normal methods
410+
priority = 0.6
411+
390412

391413
class AccessorCallableDocumenter(AccessorLevelDocumenter, MethodDocumenter):
392414
"""
@@ -483,6 +505,7 @@ def remove_flags_docstring(app, what, name, obj, options, lines):
483505

484506
def setup(app):
485507
app.connect("autodoc-process-docstring", remove_flags_docstring)
508+
app.add_autodocumenter(AccessorDocumenter)
486509
app.add_autodocumenter(AccessorAttributeDocumenter)
487510
app.add_autodocumenter(AccessorMethodDocumenter)
488511
app.add_autodocumenter(AccessorCallableDocumenter)

doc/sphinxext/ipython_sphinxext/ipython_directive.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ def setup(self):
786786
# EmbeddedSphinxShell is created, its interactive shell member
787787
# is the same for each instance.
788788

789-
if mplbackend:
789+
if mplbackend and 'matplotlib.backends' not in sys.modules:
790790
import matplotlib
791791
# Repeated calls to use() will not hurt us since `mplbackend`
792792
# is the same each time.

0 commit comments

Comments
 (0)