Skip to content

ENH: first draft of ensure_ax decorator #4488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
MNT: put wrapping doc at end of docstring
  • Loading branch information
tacaswell committed Aug 30, 2015
commit c44b7ddfd6aafba84b9b7693adeabe21cfa8b7ff
12 changes: 7 additions & 5 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def uninstall_repl_displayhook():
draw_all = _pylab_helpers.Gcf.draw_all

_ENSURE_AX_DOC = """

This function has been decorated by pyplot to have
an implicit reference to the `plt.gca()` passed as the first argument.

Expand All @@ -206,6 +207,7 @@ def uninstall_repl_displayhook():


_ENSURE_AX_NEW_DOC = """

This function has been decorated by pyplot to create a new
axes if one is not explicitly passed.

Expand Down Expand Up @@ -265,7 +267,7 @@ def inner(*args, **kwargs):
pre_doc = ''
else:
pre_doc = dedent(pre_doc)
inner.__doc__ = _ENSURE_AX_DOC.format(func=func.__name__, obj='') + pre_doc
inner.__doc__ = pre_doc + _ENSURE_AX_DOC.format(func=func.__name__, obj='')

return inner

Expand All @@ -292,8 +294,8 @@ def inner(*args, **kwargs):
pre_doc = ''
else:
pre_doc = dedent(pre_doc)
inner.__doc__ = (_ENSURE_AX_NEW_DOC.format(func=func.__name__, obj='') +
pre_doc)
inner.__doc__ = (pre_doc +
_ENSURE_AX_NEW_DOC.format(func=func.__name__, obj=''))

return inner

Expand Down Expand Up @@ -326,8 +328,8 @@ def inner(*args, **kwargs):
pre_doc = ''
else:
pre_doc = dedent(pre_doc)
inner.__doc__ = _ENSURE_AX_DOC.format(func=func.__name__,
obj='obj.') + pre_doc
inner.__doc__ = pre_doc + _ENSURE_AX_DOC.format(func=func.__name__,
obj='obj.')
return inner


Expand Down