From: <ef...@us...> - 2009-08-15 18:34:05
|
Revision: 7491 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7491&view=rev Author: efiring Date: 2009-08-15 18:33:54 +0000 (Sat, 15 Aug 2009) Log Message: ----------- Use decorators to manipulate docstrings; patch by Jason Coombs Tracker 2835685, file DocstringOptimizedTypeErrorRev5.patch Modified Paths: -------------- trunk/matplotlib/boilerplate.py trunk/matplotlib/lib/matplotlib/artist.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/collections.py trunk/matplotlib/lib/matplotlib/colorbar.py trunk/matplotlib/lib/matplotlib/figure.py trunk/matplotlib/lib/matplotlib/lines.py trunk/matplotlib/lib/matplotlib/mlab.py trunk/matplotlib/lib/matplotlib/offsetbox.py trunk/matplotlib/lib/matplotlib/patches.py trunk/matplotlib/lib/matplotlib/projections/geo.py trunk/matplotlib/lib/matplotlib/projections/polar.py trunk/matplotlib/lib/matplotlib/pyplot.py trunk/matplotlib/lib/matplotlib/quiver.py trunk/matplotlib/lib/matplotlib/scale.py trunk/matplotlib/lib/matplotlib/spines.py trunk/matplotlib/lib/matplotlib/table.py trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/boilerplate.py =================================================================== --- trunk/matplotlib/boilerplate.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/boilerplate.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -20,6 +20,7 @@ _fmtplot = """\ # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost +@autogen_docstring(Axes.%(func)s) def %(func)s(%(argspec)s): %(ax)s = gca() # allow callers to override the hold state by passing hold=True|False @@ -34,19 +35,16 @@ %(ax)s.hold(%(washold)s) %(mappable)s return %(ret)s -if Axes.%(func)s.__doc__ is not None: - %(func)s.__doc__ = dedent(Axes.%(func)s.__doc__) + __docstring_addendum """ _fmtmisc = """\ # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost +...@do...py_dedent(Axes.%(func)s) def %(func)s(%(argspec)s): %(ret)s = gca().%(func)s(%(call)s) draw_if_interactive() return %(ret)s -if Axes.%(func)s.__doc__ is not None: - %(func)s.__doc__ = dedent(Axes.%(func)s.__doc__) """ # these methods are all simple wrappers of Axes methods by the same Modified: trunk/matplotlib/lib/matplotlib/artist.py =================================================================== --- trunk/matplotlib/lib/matplotlib/artist.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/artist.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -2,6 +2,7 @@ import re, warnings import matplotlib import matplotlib.cbook as cbook +from matplotlib import docstring from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath from path import Path @@ -1193,5 +1194,4 @@ else: return '\n'.join(ArtistInspector(a).pprint_setters(leadingspace=2)) -kwdocd = dict() -kwdocd['Artist'] = kwdoc(Artist) +docstring.interpd.update(Artist=kwdoc(Artist)) Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/axes.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -15,6 +15,7 @@ import matplotlib.colors as mcolors import matplotlib.contour as mcontour import matplotlib.dates as mdates +from matplotlib import docstring import matplotlib.font_manager as font_manager import matplotlib.image as mimage import matplotlib.legend as mlegend @@ -33,7 +34,6 @@ is_string_like = cbook.is_string_like is_sequence_of_strings = cbook.is_sequence_of_strings - def _process_plot_format(fmt): """ Process a matlab(TM) style color/line style format string. Return a @@ -1787,6 +1787,7 @@ """ self._axisbelow = b + @docstring.dedent_interpd def grid(self, b=None, **kwargs): """ call signature:: @@ -1810,7 +1811,6 @@ if len(kwargs): b = True self.xaxis.grid(b, **kwargs) self.yaxis.grid(b, **kwargs) - grid.__doc__ = cbook.dedent(grid.__doc__) % martist.kwdocd def ticklabel_format(self, **kwargs): """ @@ -2018,6 +2018,7 @@ ", ".join(mscale.get_scale_names())) return self.xaxis.get_scale() + @docstring.dedent_interpd def set_xscale(self, value, **kwargs): """ call signature:: @@ -2035,10 +2036,6 @@ self.autoscale_view() self._update_transScale() - set_xscale.__doc__ = cbook.dedent(set_xscale.__doc__) % { - 'scale': ' | '.join([repr(x) for x in mscale.get_scale_names()]), - 'scale_docs': mscale.get_scale_docs().strip()} - def get_xticks(self, minor=False): 'Return the x ticks as a list of locations' return self.xaxis.get_ticklocs(minor=minor) @@ -2066,6 +2063,7 @@ return cbook.silent_list('Text xticklabel', self.xaxis.get_ticklabels(minor=minor)) + @docstring.dedent_interpd def set_xticklabels(self, labels, fontdict=None, minor=False, **kwargs): """ call signature:: @@ -2083,8 +2081,6 @@ """ return self.xaxis.set_ticklabels(labels, fontdict, minor=minor, **kwargs) - set_xticklabels.__doc__ = cbook.dedent( - set_xticklabels.__doc__) % martist.kwdocd def invert_yaxis(self): "Invert the y-axis." @@ -2192,6 +2188,7 @@ ", ".join(mscale.get_scale_names())) return self.yaxis.get_scale() + @docstring.dedent_interpd def set_yscale(self, value, **kwargs): """ call signature:: @@ -2209,10 +2206,6 @@ self.autoscale_view() self._update_transScale() - set_yscale.__doc__ = cbook.dedent(set_yscale.__doc__) % { - 'scale': ' | '.join([repr(x) for x in mscale.get_scale_names()]), - 'scale_docs': mscale.get_scale_docs().strip()} - def get_yticks(self, minor=False): 'Return the y ticks as a list of locations' return self.yaxis.get_ticklocs(minor=minor) @@ -2245,6 +2238,7 @@ return cbook.silent_list('Text yticklabel', self.yaxis.get_ticklabels(minor=minor)) + @docstring.dedent_interpd def set_yticklabels(self, labels, fontdict=None, minor=False, **kwargs): """ call signature:: @@ -2262,8 +2256,6 @@ """ return self.yaxis.set_ticklabels(labels, fontdict, minor=minor, **kwargs) - set_yticklabels.__doc__ = cbook.dedent( - set_yticklabels.__doc__) % martist.kwdocd def xaxis_date(self, tz=None): """Sets up x-axis ticks and labels that treat the x data as dates. @@ -2693,6 +2685,7 @@ """ return self.title.get_text() + @docstring.dedent_interpd def set_title(self, label, fontdict=None, **kwargs): """ call signature:: @@ -2722,7 +2715,6 @@ if fontdict is not None: self.title.update(fontdict) self.title.update(kwargs) return self.title - set_title.__doc__ = cbook.dedent(set_title.__doc__) % martist.kwdocd def get_xlabel(self): """ @@ -2731,6 +2723,7 @@ label = self.xaxis.get_label() return label.get_text() + @docstring.dedent_interpd def set_xlabel(self, xlabel, fontdict=None, labelpad=None, **kwargs): """ call signature:: @@ -2752,7 +2745,6 @@ """ if labelpad is not None: self.xaxis.labelpad = labelpad return self.xaxis.set_label_text(xlabel, fontdict, **kwargs) - set_xlabel.__doc__ = cbook.dedent(set_xlabel.__doc__) % martist.kwdocd def get_ylabel(self): """ @@ -2761,6 +2753,7 @@ label = self.yaxis.get_label() return label.get_text() + @docstring.dedent_interpd def set_ylabel(self, ylabel, fontdict=None, labelpad=None, **kwargs): """ call signature:: @@ -2782,8 +2775,8 @@ """ if labelpad is not None: self.yaxis.labelpad = labelpad return self.yaxis.set_label_text(ylabel, fontdict, **kwargs) - set_ylabel.__doc__ = cbook.dedent(set_ylabel.__doc__) % martist.kwdocd + @docstring.dedent_interpd def text(self, x, y, s, fontdict=None, withdash=False, **kwargs): """ @@ -2864,8 +2857,8 @@ #if t.get_clip_on(): t.set_clip_box(self.bbox) if 'clip_on' in kwargs: t.set_clip_box(self.bbox) return t - text.__doc__ = cbook.dedent(text.__doc__) % martist.kwdocd + @docstring.dedent_interpd def annotate(self, *args, **kwargs): """ call signature:: @@ -2885,10 +2878,10 @@ if kwargs.has_key('clip_on'): a.set_clip_path(self.patch) self.texts.append(a) return a - annotate.__doc__ = cbook.dedent(annotate.__doc__) % martist.kwdocd #### Lines and spans + @docstring.dedent_interpd def axhline(self, y=0, xmin=0, xmax=1, **kwargs): """ call signature:: @@ -2948,8 +2941,7 @@ self.autoscale_view(scalex=False, scaley=scaley) return l - axhline.__doc__ = cbook.dedent(axhline.__doc__) % martist.kwdocd - + @docstring.dedent_interpd def axvline(self, x=0, ymin=0, ymax=1, **kwargs): """ call signature:: @@ -3009,8 +3001,7 @@ self.autoscale_view(scalex=scalex, scaley=False) return l - axvline.__doc__ = cbook.dedent(axvline.__doc__) % martist.kwdocd - + @docstring.dedent_interpd def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs): """ call signature:: @@ -3066,8 +3057,8 @@ self.add_patch(p) self.autoscale_view(scalex=False) return p - axhspan.__doc__ = cbook.dedent(axhspan.__doc__) % martist.kwdocd + @docstring.dedent_interpd def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs): """ call signature:: @@ -3123,9 +3114,9 @@ self.add_patch(p) self.autoscale_view(scaley=False) return p - axvspan.__doc__ = cbook.dedent(axvspan.__doc__) % martist.kwdocd + @docstring.dedent def hlines(self, y, xmin, xmax, colors='k', linestyles='solid', label='', **kwargs): """ @@ -3210,8 +3201,8 @@ return coll - hlines.__doc__ = cbook.dedent(hlines.__doc__) + @docstring.dedent_interpd def vlines(self, x, ymin, ymax, colors='k', linestyles='solid', label='', **kwargs): """ @@ -3290,9 +3281,9 @@ self.autoscale_view() return coll - vlines.__doc__ = cbook.dedent(vlines.__doc__) % martist.kwdocd #### Basic plotting + @docstring.dedent_interpd def plot(self, *args, **kwargs): """ Plot lines and/or markers to the @@ -3425,8 +3416,7 @@ self.autoscale_view(scalex=scalex, scaley=scaley) return lines - plot.__doc__ = cbook.dedent(plot.__doc__) % martist.kwdocd - + @docstring.dedent_interpd def plot_date(self, x, y, fmt='bo', tz=None, xdate=True, ydate=False, **kwargs): """ @@ -3496,9 +3486,9 @@ self.autoscale_view() return ret - plot_date.__doc__ = cbook.dedent(plot_date.__doc__) % martist.kwdocd + @docstring.dedent_interpd def loglog(self, *args, **kwargs): """ call signature:: @@ -3557,8 +3547,8 @@ self._hold = b # restore the hold return l - loglog.__doc__ = cbook.dedent(loglog.__doc__) % martist.kwdocd + @docstring.dedent_interpd def semilogx(self, *args, **kwargs): """ call signature:: @@ -3608,8 +3598,8 @@ l = self.plot(*args, **kwargs) self._hold = b # restore the hold return l - semilogx.__doc__ = cbook.dedent(semilogx.__doc__) % martist.kwdocd + @docstring.dedent_interpd def semilogy(self, *args, **kwargs): """ call signature:: @@ -3659,8 +3649,8 @@ self._hold = b # restore the hold return l - semilogy.__doc__ = cbook.dedent(semilogy.__doc__) % martist.kwdocd + @docstring.dedent_interpd def acorr(self, x, **kwargs): """ call signature:: @@ -3722,8 +3712,8 @@ .. plot:: mpl_examples/pylab_examples/xcorr_demo.py """ return self.xcorr(x, x, **kwargs) - acorr.__doc__ = cbook.dedent(acorr.__doc__) % martist.kwdocd + @docstring.dedent_interpd def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none, usevlines=True, maxlags=10, **kwargs): """ @@ -3810,7 +3800,6 @@ a, = self.plot(lags, c, **kwargs) b = None return lags, c, a, b - xcorr.__doc__ = cbook.dedent(xcorr.__doc__) % martist.kwdocd def _get_legend_handles(self): @@ -4064,6 +4053,7 @@ return self.plot(x, y, *args, **kwargs) + @docstring.dedent_interpd def bar(self, left, height, width=0.8, bottom=None, color=None, edgecolor=None, linewidth=None, yerr=None, xerr=None, ecolor=None, capsize=3, @@ -4331,8 +4321,8 @@ self.dataLim.intervaly = (ymin, ymax) self.autoscale_view() return patches - bar.__doc__ = cbook.dedent(bar.__doc__) % martist.kwdocd + @docstring.dedent_interpd def barh(self, bottom, width, height=0.8, left=None, **kwargs): """ call signature:: @@ -4403,8 +4393,7 @@ orientation='horizontal', **kwargs) return patches - barh.__doc__ = cbook.dedent(barh.__doc__) % martist.kwdocd - + @docstring.dedent_interpd def broken_barh(self, xranges, yrange, **kwargs): """ call signature:: @@ -4447,8 +4436,6 @@ return col - broken_barh.__doc__ = cbook.dedent(broken_barh.__doc__) % martist.kwdocd - def stem(self, x, y, linefmt='b-', markerfmt='bo', basefmt='r-'): """ call signature:: @@ -4642,6 +4629,7 @@ if autopct is None: return slices, texts else: return slices, texts, autotexts + @docstring.dedent_interpd def errorbar(self, x, y, yerr=None, xerr=None, fmt='-', ecolor=None, elinewidth=None, capsize=3, barsabove=False, lolims=False, uplims=False, @@ -4900,7 +4888,6 @@ self.autoscale_view() return (l0, caplines, barcols) - errorbar.__doc__ = cbook.dedent(errorbar.__doc__) % martist.kwdocd def boxplot(self, x, notch=0, sym='b+', vert=1, whis=1.5, positions=None, widths=None): @@ -5092,6 +5079,7 @@ return dict(whiskers=whiskers, caps=caps, boxes=boxes, medians=medians, fliers=fliers) + @docstring.dedent_interpd def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=1.0, linewidths=None, faceted=True, verts=None, @@ -5407,8 +5395,7 @@ self.add_collection(collection) return collection - scatter.__doc__ = cbook.dedent(scatter.__doc__) % martist.kwdocd - + @docstring.dedent_interpd def hexbin(self, x, y, C = None, gridsize = 100, bins = None, xscale = 'linear', yscale = 'linear', extent = None, cmap=None, norm=None, vmin=None, vmax=None, @@ -5821,9 +5808,8 @@ return collection - hexbin.__doc__ = cbook.dedent(hexbin.__doc__) % martist.kwdocd - + @docstring.dedent_interpd def arrow(self, x, y, dx, dy, **kwargs): """ call signature:: @@ -5843,7 +5829,6 @@ a = mpatches.FancyArrow(x, y, dx, dy, **kwargs) self.add_artist(a) return a - arrow.__doc__ = cbook.dedent(arrow.__doc__) % martist.kwdocd def quiverkey(self, *args, **kw): qk = mquiver.QuiverKey(*args, **kw) @@ -5860,6 +5845,7 @@ return q quiver.__doc__ = mquiver.Quiver.quiver_doc + @docstring.dedent_interpd def barbs(self, *args, **kw): """ %(barbs_doc)s @@ -5873,9 +5859,8 @@ self.update_datalim(b.get_offsets()) self.autoscale_view() return b - barbs.__doc__ = cbook.dedent(barbs.__doc__) % { - 'barbs_doc': mquiver.Barbs.barbs_doc} + @docstring.dedent_interpd def fill(self, *args, **kwargs): """ call signature:: @@ -5922,8 +5907,8 @@ patches.append( poly ) self.autoscale_view() return patches - fill.__doc__ = cbook.dedent(fill.__doc__) % martist.kwdocd + @docstring.dedent_interpd def fill_between(self, x, y1, y2=0, where=None, **kwargs): """ call signature:: @@ -6029,8 +6014,8 @@ self.add_collection(collection) self.autoscale_view() return collection - fill_between.__doc__ = cbook.dedent(fill_between.__doc__) % martist.kwdocd + @docstring.dedent_interpd def fill_betweenx(self, y, x1, x2=0, where=None, **kwargs): """ call signature:: @@ -6136,10 +6121,10 @@ self.add_collection(collection) self.autoscale_view() return collection - fill_between.__doc__ = cbook.dedent(fill_between.__doc__) % martist.kwdocd #### plotting z(x,y): imshow, pcolor and relatives, contour + @docstring.dedent_interpd def imshow(self, X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=1.0, vmin=None, vmax=None, origin=None, extent=None, shape=None, filternorm=1, @@ -6276,7 +6261,6 @@ self.images.append(im) return im - imshow.__doc__ = cbook.dedent(imshow.__doc__) % martist.kwdocd def _pcolorargs(self, funcname, *args): @@ -6304,6 +6288,7 @@ funcname, funcname)) return X, Y, C + @docstring.dedent_interpd def pcolor(self, *args, **kwargs): """ call signatures:: @@ -6511,8 +6496,8 @@ self.autoscale_view() self.add_collection(collection) return collection - pcolor.__doc__ = cbook.dedent(pcolor.__doc__) % martist.kwdocd + @docstring.dedent_interpd def pcolormesh(self, *args, **kwargs): """ call signatures:: @@ -6634,8 +6619,8 @@ self.autoscale_view() self.add_collection(collection) return collection - pcolormesh.__doc__ = cbook.dedent(pcolormesh.__doc__) % martist.kwdocd + @docstring.dedent_interpd def pcolorfast(self, *args, **kwargs): """ pseudocolor plot of a 2-D array @@ -6829,6 +6814,7 @@ return CS.clabel(*args, **kwargs) clabel.__doc__ = mcontour.ContourSet.clabel.__doc__ + @docstring.dedent_interpd def table(self, **kwargs): """ call signature:: @@ -6853,7 +6839,6 @@ %(Table)s """ return mtable.table(self, **kwargs) - table.__doc__ = cbook.dedent(table.__doc__) % martist.kwdocd def twinx(self): """ @@ -6905,6 +6890,7 @@ #### Data analysis + @docstring.dedent_interpd def hist(self, x, bins=10, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, @@ -7257,8 +7243,8 @@ return n[0], bins, cbook.silent_list('Patch', patches[0]) else: return n, bins, cbook.silent_list('Lists of Patches', patches) - hist.__doc__ = cbook.dedent(hist.__doc__) % martist.kwdocd + @docstring.dedent_interpd def psd(self, x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, **kwargs): @@ -7330,12 +7316,7 @@ return pxx, freqs - psd_doc_dict = dict() - psd_doc_dict.update(martist.kwdocd) - psd_doc_dict.update(mlab.kwdocd) - psd_doc_dict['PSD'] = cbook.dedent(psd_doc_dict['PSD']) - psd.__doc__ = cbook.dedent(psd.__doc__) % psd_doc_dict - + @docstring.dedent_interpd def csd(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, **kwargs): @@ -7403,8 +7384,8 @@ self.set_yticks(ticks) return pxy, freqs - csd.__doc__ = cbook.dedent(csd.__doc__) % psd_doc_dict + @docstring.dedent_interpd def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, **kwargs): @@ -7460,8 +7441,8 @@ self.grid(True) return cxy, freqs - cohere.__doc__ = cbook.dedent(cohere.__doc__) % psd_doc_dict + @docstring.dedent_interpd def specgram(self, x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=128, cmap=None, xextent=None, pad_to=None, sides='default', @@ -7534,8 +7515,6 @@ self.axis('auto') return Pxx, freqs, bins, im - specgram.__doc__ = cbook.dedent(specgram.__doc__) % psd_doc_dict - del psd_doc_dict #So that this does not become an Axes attribute def spy(self, Z, precision=0, marker=None, markersize=None, aspect='equal', **kwargs): @@ -7908,7 +7887,8 @@ # This is provided for backward compatibility Subplot = subplot_class_factory() -martist.kwdocd['Axes'] = martist.kwdocd['Subplot'] = martist.kwdoc(Axes) +docstring.interpd.update(Axes=martist.kwdoc(Axes)) +docstring.interpd.update(Subplot=martist.kwdoc(Axes)) """ # this is some discarded code I was using to find the minimum positive Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/collections.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -15,6 +15,7 @@ import matplotlib.cbook as cbook import matplotlib.colors as mcolors import matplotlib.cm as cm +from matplotlib import docstring import matplotlib.transforms as transforms import matplotlib.artist as artist from matplotlib.artist import allow_rasterization @@ -496,7 +497,7 @@ # these are not available for the object inspector until after the # class is built so we define an initial set here for the init # function and they will be overridden after object defn -artist.kwdocd['Collection'] = """\ +docstring.interpd.update(Collection = """\ Valid Collection keyword arguments: * *edgecolors*: None @@ -516,12 +517,13 @@ If any of *edgecolors*, *facecolors*, *linewidths*, *antialiaseds* are None, they default to their :data:`matplotlib.rcParams` patch setting, in sequence form. -""" +""") class PathCollection(Collection): """ This is the most basic :class:`Collection` subclass. """ + @docstring.dedent_interpd def __init__(self, paths, **kwargs): """ *paths* is a sequence of :class:`matplotlib.path.Path` @@ -532,7 +534,6 @@ Collection.__init__(self, **kwargs) self.set_paths(paths) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def set_paths(self, paths): @@ -540,6 +541,7 @@ class PolyCollection(Collection): + @docstring.dedent_interpd def __init__(self, verts, sizes = None, closed = True, **kwargs): """ *verts* is a sequence of ( *verts0*, *verts1*, ...) where @@ -562,7 +564,6 @@ Collection.__init__(self,**kwargs) self._sizes = sizes self.set_verts(verts, closed) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def set_verts(self, verts, closed=True): '''This allows one to delay initialization of the vertices.''' @@ -599,6 +600,7 @@ A collection of horizontal bars spanning *yrange* with a sequence of *xranges*. """ + @docstring.dedent_interpd def __init__(self, xranges, yrange, **kwargs): """ *xranges* @@ -613,7 +615,6 @@ ymax = ymin + ywidth verts = [ [(xmin, ymin), (xmin, ymax), (xmin+xwidth, ymax), (xmin+xwidth, ymin), (xmin, ymin)] for xmin, xwidth in xranges] PolyCollection.__init__(self, verts, **kwargs) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd @staticmethod @@ -640,6 +641,7 @@ """Draw a collection of regular polygons with *numsides*.""" _path_generator = mpath.Path.unit_regular_polygon + @docstring.dedent_interpd def __init__(self, numsides, rotation = 0 , @@ -682,8 +684,6 @@ self._rotation = rotation self.set_transform(transforms.IdentityTransform()) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd - @allow_rasterization def draw(self, renderer): self._transforms = [ @@ -875,6 +875,7 @@ """ A collection of circles, drawn using splines. """ + @docstring.dedent_interpd def __init__(self, sizes, **kwargs): """ *sizes* @@ -886,7 +887,6 @@ self._sizes = sizes self.set_transform(transforms.IdentityTransform()) self._paths = [mpath.Path.unit_circle()] - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def get_sizes(self): "return sizes of circles" @@ -906,6 +906,7 @@ """ A collection of ellipses, drawn using splines. """ + @docstring.dedent_interpd def __init__(self, widths, heights, angles, units='points', **kwargs): """ *widths*: sequence @@ -937,8 +938,6 @@ self._initialized = False - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd - def _init(self): def on_dpi_change(fig): self._transforms = [] @@ -1230,9 +1229,10 @@ -artist.kwdocd['Collection'] = patchstr = artist.kwdoc(Collection) +patchstr = artist.kwdoc(Collection) for k in ('QuadMesh', 'PolyCollection', 'BrokenBarHCollection', 'RegularPolyCollection', 'PathCollection', - 'StarPolygonCollection', 'PatchCollection', 'CircleCollection'): - artist.kwdocd[k] = patchstr -artist.kwdocd['LineCollection'] = artist.kwdoc(LineCollection) + 'StarPolygonCollection', 'PatchCollection', + 'CircleCollection', 'Collection',): + docstring.interpd.update({k:patchstr}) +docstring.interpd.update(LineCollection = artist.kwdoc(LineCollection)) Modified: trunk/matplotlib/lib/matplotlib/colorbar.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colorbar.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/colorbar.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -23,6 +23,7 @@ import matplotlib as mpl import matplotlib.colors as colors import matplotlib.cm as cm +from matplotlib import docstring import matplotlib.ticker as ticker import matplotlib.cbook as cbook import matplotlib.lines as lines @@ -150,6 +151,7 @@ ''' % (make_axes_kw_doc, colormap_kw_doc) +docstring.interpd.update(colorbar_doc=colorbar_doc) class ColorbarBase(cm.ScalarMappable): @@ -693,7 +695,25 @@ # be recalculating everything if there was a simple alpha # change. +...@do...bstitution(make_axes_kw_doc) def make_axes(parent, **kw): + ''' + Resize and reposition a parent axes, and return a child + axes suitable for a colorbar:: + + cax, kw = make_axes(parent, **kw) + + Keyword arguments may include the following (with defaults): + + *orientation* + 'vertical' or 'horizontal' + + %s + + All but the first of these are stripped from the input kw set. + + Returns (cax, kw), the child axes and the reduced kw dictionary. + ''' orientation = kw.setdefault('orientation', 'vertical') fraction = kw.pop('fraction', 0.15) shrink = kw.pop('shrink', 1.0) @@ -720,22 +740,5 @@ cax = fig.add_axes(pbcb) cax.set_aspect(aspect, anchor=anchor, adjustable='box') return cax, kw -make_axes.__doc__ =''' - Resize and reposition a parent axes, and return a child - axes suitable for a colorbar:: - cax, kw = make_axes(parent, **kw) - Keyword arguments may include the following (with defaults): - - *orientation* - 'vertical' or 'horizontal' - - %s - - All but the first of these are stripped from the input kw set. - - Returns (cax, kw), the child axes and the reduced kw dictionary. - ''' % make_axes_kw_doc - - Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/figure.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -32,7 +32,9 @@ from matplotlib.blocking_input import BlockingMouseInput, BlockingKeyMouseInput import matplotlib.cbook as cbook +from matplotlib import docstring +docstring.interpd.update(projection_names = get_projection_names()) class SubplotParams: """ @@ -555,6 +557,7 @@ key = fixlist(args), fixitems(kwargs.items()) return key + @docstring.dedent_interpd def add_axes(self, *args, **kwargs): """ Add an a axes with axes rect [*left*, *bottom*, *width*, @@ -564,7 +567,7 @@ sets the projection type of the axes. (For backward compatibility, ``polar=True`` may also be provided, which is equivalent to ``projection='polar'``). Valid values for - *projection* are: %(list)s. Some of these projections support + *projection* are: %(projection_names)s. Some of these projections support additional kwargs, which may be provided to :meth:`add_axes`:: rect = l,b,w,h @@ -624,10 +627,7 @@ self._seen[key] = a return a - add_axes.__doc__ = dedent(add_axes.__doc__) % \ - {'list': (", ".join(get_projection_names())), - 'Axes': artist.kwdocd['Axes']} - + @docstring.dedent_interpd def add_subplot(self, *args, **kwargs): """ Add a subplot. Examples: @@ -642,7 +642,7 @@ *projection*, which chooses a projection type for the axes. (For backward compatibility, *polar=True* may also be provided, which is equivalent to *projection='polar'*). Valid - values for *projection* are: %(list)s. Some of these projections + values for *projection* are: %(projection_names)s. Some of these projections support additional *kwargs*, which may be provided to :meth:`add_axes`. @@ -693,9 +693,6 @@ self._axstack.push(a) self.sca(a) return a - add_subplot.__doc__ = dedent(add_subplot.__doc__) % { - 'list': ", ".join(get_projection_names()), - 'Axes': artist.kwdocd['Axes']} def clf(self): """ @@ -891,6 +888,7 @@ self.legends.append(l) return l + @docstring.dedent_interpd def text(self, x, y, s, *args, **kwargs): """ Call signature:: @@ -915,13 +913,13 @@ self._set_artist_props(t) self.texts.append(t) return t - text.__doc__ = dedent(text.__doc__) % artist.kwdocd def _set_artist_props(self, a): if a!= self: a.set_figure(self) a.set_transform(self.transFigure) + @docstring.dedent_interpd def gca(self, **kwargs): """ Return the current axes, creating one if necessary @@ -945,7 +943,6 @@ if isinstance(ax, projection_class): return ax return self.add_subplot(111, **kwargs) - gca.__doc__ = dedent(gca.__doc__) % artist.kwdocd def sca(self, a): 'Set the current axes to be a and return a' @@ -1038,7 +1035,14 @@ for ax, alpha in zip(self.axes, original_axes_alpha): ax.patch.set_alpha(alpha) + @docstring.dedent_interpd def colorbar(self, mappable, cax=None, ax=None, **kw): + """ + Create a colorbar for a ScalarMappable instance. + + Documentation for the pylab thin wrapper: + %(colorbar_doc)s + """ if ax is None: ax = self.gca() if cax is None: @@ -1056,14 +1060,7 @@ mappable.set_colorbar(cb, cax) self.sca(ax) return cb - colorbar.__doc__ = ''' - Create a colorbar for a ScalarMappable instance. - Documentation for the pylab thin wrapper: - %s - - '''% cbar.colorbar_doc - def subplots_adjust(self, *args, **kwargs): """ fig.subplots_adjust(left=None, bottom=None, right=None, wspace=None, hspace=None) @@ -1220,4 +1217,4 @@ newsize = np.clip(newsize,figsize_min,figsize_max) return newsize -artist.kwdocd['Figure'] = artist.kwdoc(Figure) +docstring.interpd.update(Figure=artist.kwdoc(Figure)) Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/lines.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -19,6 +19,7 @@ from matplotlib import rcParams from artist import allow_rasterization +from matplotlib import docstring # special-purpose marker identifiers: (TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN, @@ -172,7 +173,7 @@ markeredgewidth = None, markeredgecolor = None, markerfacecolor = None, - fillstyle = 'full', + fillstyle = 'full', antialiased = None, dash_capstyle = None, solid_capstyle = None, @@ -1546,8 +1547,8 @@ lineMarkers = Line2D._markers drawStyles = Line2D.drawStyles -artist.kwdocd['Line2D'] = artist.kwdoc(Line2D) +docstring.interpd.update(Line2D = artist.kwdoc(Line2D)) # You can not set the docstring of an instancemethod, # but you can on the underlying function. Go figure. -Line2D.__init__.im_func.__doc__ = dedent(Line2D.__init__.__doc__) % artist.kwdocd +docstring.dedent_interpd(Line2D.__init__.im_func) Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -147,6 +147,7 @@ import matplotlib.nxutils as nxutils import matplotlib.cbook as cbook +from matplotlib import docstring def logspace(xmin,xmax,N): @@ -288,8 +289,7 @@ return Pxy, freqs, t #Split out these keyword docs so that they can be used elsewhere -kwdocd = dict() -kwdocd['PSD'] =""" +docstring.interpd.update(PSD=cbook.dedent(""" Keyword arguments: *NFFT*: integer @@ -346,8 +346,9 @@ by the scaling frequency, which gives density in units of Hz^-1. This allows for integration over the returned frequency values. The default is True for MatLab compatibility. -""" +""")) +...@do...dent_interpd def psd(x, NFFT=256, Fs=2, detrend=detrend_none, window=window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None): """ @@ -373,8 +374,7 @@ scale_by_freq) return Pxx.real,freqs -psd.__doc__ = psd.__doc__ % kwdocd - +...@do...dent_interpd def csd(x, y, NFFT=256, Fs=2, detrend=detrend_none, window=window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None): """ @@ -405,8 +405,7 @@ Pxy = Pxy.mean(axis=1) return Pxy, freqs -csd.__doc__ = csd.__doc__ % kwdocd - +...@do...dent_interpd def specgram(x, NFFT=256, Fs=2, detrend=detrend_none, window=window_hanning, noverlap=128, pad_to=None, sides='default', scale_by_freq=None): """ @@ -445,11 +444,10 @@ return Pxx, freqs, t -specgram.__doc__ = specgram.__doc__ % kwdocd - _coh_error = """Coherence is calculated by averaging over *NFFT* length segments. Your signal is too short for your choice of *NFFT*. """ +...@do...dent_interpd def cohere(x, y, NFFT=256, Fs=2, detrend=detrend_none, window=window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None): """ @@ -488,9 +486,7 @@ Cxy.shape = (len(f),) return Cxy, f -cohere.__doc__ = cohere.__doc__ % kwdocd - def donothing_callback(*args): pass Modified: trunk/matplotlib/lib/matplotlib/offsetbox.py =================================================================== --- trunk/matplotlib/lib/matplotlib/offsetbox.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/offsetbox.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -26,6 +26,7 @@ from matplotlib.patches import FancyBboxPatch, FancyArrowPatch from matplotlib import rcParams +from matplotlib import docstring import matplotlib.cbook as cbook #from bboximage import BboxImage @@ -1171,6 +1172,7 @@ def __str__(self): return "AnnotationBbox(%g,%g)"%(self.xy[0],self.xy[1]) + @docstring.dedent_interpd def __init__(self, offsetbox, xy, xybox=None, xycoords='data', @@ -1236,8 +1238,6 @@ self._drawFrame = frameon - __init__.__doc__ = cbook.dedent(__init__.__doc__) % martist.kwdocd - def contains(self,event): t,tinfo = self.offsetbox.contains(event) if self.arrow is not None: Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/patches.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -9,13 +9,14 @@ import matplotlib.artist as artist from matplotlib.artist import allow_rasterization import matplotlib.colors as colors +from matplotlib import docstring import matplotlib.transforms as transforms from matplotlib.path import Path # these are not available for the object inspector until after the # class is built so we define an initial set here for the init # function and they will be overridden after object definition -artist.kwdocd['Patch'] = """ +docstring.interpd.update(Patch = """ ================= ============================================== Property Description @@ -38,7 +39,7 @@ zorder any number ================= ============================================== - """ + """) class Patch(artist.Artist): """ @@ -51,6 +52,38 @@ def __str__(self): return str(self.__class__).split('.')[-1] + def __init__(self, + edgecolor=None, + facecolor=None, + linewidth=None, + linestyle=None, + antialiased = None, + hatch = None, + fill=True, + **kwargs + ): + """ + The following kwarg properties are supported + + %(Patch)s + """ + artist.Artist.__init__(self) + + if linewidth is None: linewidth = mpl.rcParams['patch.linewidth'] + if linestyle is None: linestyle = "solid" + if antialiased is None: antialiased = mpl.rcParams['patch.antialiased'] + + self.set_edgecolor(edgecolor) + self.set_facecolor(facecolor) + self.set_linewidth(linewidth) + self.set_linestyle(linestyle) + self.set_antialiased(antialiased) + self.set_hatch(hatch) + self.fill = fill + self._combined_transform = transforms.IdentityTransform() + + if len(kwargs): artist.setp(self, **kwargs) + def get_verts(self): """ Return a copy of the vertices used in this patch @@ -337,53 +370,20 @@ def get_window_extent(self, renderer=None): return self.get_path().get_extents(self.get_transform()) -artist.kwdocd['Patch'] = patchdoc = artist.kwdoc(Patch) +patchdoc = artist.kwdoc(Patch) for k in ('Rectangle', 'Circle', 'RegularPolygon', 'Polygon', 'Wedge', 'Arrow', 'FancyArrow', 'YAArrow', 'CirclePolygon', 'Ellipse', 'Arc', - 'FancyBboxPatch'): - artist.kwdocd[k] = patchdoc + 'FancyBboxPatch', 'Patch'): + docstring.interpd.update({k:patchdoc}) -# define Patch.__init__ after the class so that the docstring can be -# auto-generated. -def __patch__init__(self, - edgecolor=None, - facecolor=None, - linewidth=None, - linestyle=None, - antialiased = None, - hatch = None, - fill=True, - **kwargs - ): - """ - The following kwarg properties are supported +# define Patch.__init__ docstring after the class has been added to interpd +docstring.dedent_interpd(Patch.__init__.im_func) - %(Patch)s - """ - artist.Artist.__init__(self) - - if linewidth is None: linewidth = mpl.rcParams['patch.linewidth'] - if linestyle is None: linestyle = "solid" - if antialiased is None: antialiased = mpl.rcParams['patch.antialiased'] - - self.set_edgecolor(edgecolor) - self.set_facecolor(facecolor) - self.set_linewidth(linewidth) - self.set_linestyle(linestyle) - self.set_antialiased(antialiased) - self.set_hatch(hatch) - self.fill = fill - self._combined_transform = transforms.IdentityTransform() - - if len(kwargs): artist.setp(self, **kwargs) - -__patch__init__.__doc__ = cbook.dedent(__patch__init__.__doc__) % artist.kwdocd -Patch.__init__ = __patch__init__ - class Shadow(Patch): def __str__(self): return "Shadow(%s)"%(str(self.patch)) + @docstring.dedent_interpd def __init__(self, patch, ox, oy, props=None, **kwargs): """ Create a shadow of the given *patch* offset by *ox*, *oy*. @@ -400,7 +400,6 @@ self._ox, self._oy = ox, oy self._shadow_transform = transforms.Affine2D() self._update() - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def _update(self): self.update_from(self.patch) @@ -451,6 +450,7 @@ return self.__class__.__name__ \ + "(%g,%g;%gx%g)" % (self._x, self._y, self._width, self._height) + @docstring.dedent_interpd def __init__(self, xy, width, height, **kwargs): """ @@ -468,7 +468,6 @@ self._height = height # Note: This cannot be calculated until this is added to an Axes self._rect_transform = transforms.IdentityTransform() - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def get_path(self): """ @@ -589,6 +588,7 @@ def __str__(self): return "Poly%d(%g,%g)"%(self._numVertices,self._xy[0],self._xy[1]) + @docstring.dedent_interpd def __init__(self, xy, numVertices, radius=5, orientation=0, **kwargs): """ @@ -619,8 +619,6 @@ Patch.__init__(self, **kwargs) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd - def _update_transform(self): self._poly_transform.clear() \ .scale(self.radius) \ @@ -665,6 +663,7 @@ def __str__(self): return "Poly((%g, %g) ...)" % tuple(self._path.vertices[0]) + @docstring.dedent_interpd def __init__(self, path, **kwargs): """ *path* is a :class:`matplotlib.path.Path` object. @@ -680,7 +679,6 @@ """ Patch.__init__(self, **kwargs) self._path = path - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def get_path(self): return self._path @@ -692,6 +690,7 @@ def __str__(self): return "Poly((%g, %g) ...)" % tuple(self._path.vertices[0]) + @docstring.dedent_interpd def __init__(self, xy, closed=True, **kwargs): """ *xy* is a numpy array with shape Nx2. @@ -713,8 +712,6 @@ self._path = Path(xy) self.set_closed(closed) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd - def get_path(self): return self._path @@ -753,6 +750,7 @@ def __str__(self): return "Wedge(%g,%g)"%(self.theta1,self.theta2) + @docstring.dedent_interpd def __init__(self, center, r, theta1, theta2, width=None, **kwargs): """ Draw a wedge centered at *x*, *y* center with radius *r* that @@ -798,7 +796,6 @@ v += np.asarray(center) self._path = Path(v,c) self._patch_transform = transforms.IdentityTransform() - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def get_path(self): return self._path @@ -818,6 +815,7 @@ [ 1.0, 0.0 ], [ 0.8, 0.3], [ 0.8, 0.1 ], [ 0.0, 0.1] ] ) + @docstring.dedent_interpd def __init__( self, x, y, dx, dy, width=1.0, **kwargs ): """ Draws an arrow, starting at (*x*, *y*), direction and length @@ -836,7 +834,6 @@ trans3 = transforms.Affine2D().translate(x, y) trans = trans1 + trans2 + trans3 self._patch_transform = trans.frozen() - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def get_path(self): return self._path @@ -852,6 +849,7 @@ def __str__(self): return "FancyArrow()" + @docstring.dedent_interpd def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False, \ head_width=None, head_length=None, shape='full', overhang=0, \ head_starts_at_zero=False,**kwargs): @@ -924,7 +922,6 @@ verts = np.dot(coords, M) + (x+dx, y+dy) Polygon.__init__(self, map(tuple, verts), **kwargs) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd class YAArrow(Patch): """ @@ -936,6 +933,7 @@ def __str__(self): return "YAArrow()" + @docstring.dedent_interpd def __init__(self, figure, xytip, xybase, width=4, frac=0.1, headwidth=12, **kwargs): """ Constructor arguments: @@ -970,7 +968,6 @@ self.frac = frac self.headwidth = headwidth Patch.__init__(self, **kwargs) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def get_path(self): # Since this is dpi dependent, we need to recompute the path @@ -1034,6 +1031,7 @@ def __str__(self): return "CirclePolygon(%d,%d)"%self.center + @docstring.dedent_interpd def __init__(self, xy, radius=5, resolution=20, # the number of vertices **kwargs): @@ -1052,7 +1050,6 @@ radius, orientation=0, **kwargs) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd class Ellipse(Patch): @@ -1062,6 +1059,7 @@ def __str__(self): return "Ellipse(%s,%s;%sx%s)"%(self.center[0],self.center[1],self.width,self.height) + @docstring.dedent_interpd def __init__(self, xy, width, height, angle=0.0, **kwargs): """ *xy* @@ -1087,7 +1085,6 @@ self._path = Path.unit_circle() # Note: This cannot be calculated until this is added to an Axes self._patch_transform = transforms.IdentityTransform() - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def _recompute_transform(self): """NOTE: This cannot be called until after this has been added @@ -1127,6 +1124,7 @@ def __str__(self): return "Circle((%g,%g),r=%g)"%(self.center[0],self.center[1],self.radius) + @docstring.dedent_interpd def __init__(self, xy, radius=5, **kwargs): """ Create true circle at center *xy* = (*x*, *y*) with given @@ -1145,7 +1143,6 @@ self.radius = radius Ellipse.__init__(self, xy, radius*2, radius*2, **kwargs) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def set_radius(self, radius): """ @@ -1175,6 +1172,7 @@ def __str__(self): return "Arc(%s,%s;%sx%s)"%(self.center[0],self.center[1],self.width,self.height) + @docstring.dedent_interpd def __init__(self, xy, width, height, angle=0.0, theta1=0.0, theta2=360.0, **kwargs): """ The following args are supported: @@ -1212,7 +1210,6 @@ self.theta1 = theta1 self.theta2 = theta2 - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd @allow_rasterization def draw(self, renderer): @@ -1987,9 +1984,11 @@ _style_list["roundtooth"] = Roundtooth - __doc__ = cbook.dedent(__doc__) % \ - {"AvailableBoxstyles": _pprint_styles(_style_list)} + if __doc__: # __doc__ could be None if -OO optimization is enabled + __doc__ = cbook.dedent(__doc__) % \ + {"AvailableBoxstyles": _pprint_styles(_style_list)} +docstring.interpd.update(AvailableBoxstyles=_pprint_styles(BoxStyle._style_list)) class FancyBboxPatch(Patch): """ @@ -2007,6 +2006,7 @@ return self.__class__.__name__ \ + "FancyBboxPatch(%g,%g;%gx%g)" % (self._x, self._y, self._width, self._height) + @docstring.dedent_interpd def __init__(self, xy, width, height, boxstyle="round", bbox_transmuter=None, @@ -2054,13 +2054,7 @@ self._mutation_aspect=mutation_aspect - kwdoc = dict() - kwdoc["AvailableBoxstyles"]=_pprint_styles(BoxStyle._style_list) - kwdoc.update(artist.kwdocd) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % kwdoc - del kwdoc - - + @docstring.dedent_interpd def set_boxstyle(self, boxstyle=None, **kw): """ Set the box style. @@ -2092,12 +2086,6 @@ self._bbox_transmuter = BoxStyle(boxstyle, **kw) - kwdoc = dict() - kwdoc["AvailableBoxstyles"]=_pprint_styles(BoxStyle._style_list) - kwdoc.update(artist.kwdocd) - set_boxstyle.__doc__ = cbook.dedent(set_boxstyle.__doc__) % kwdoc - del kwdoc - def set_mutation_scale(self, scale): """ Set the mutation scale. @@ -2682,12 +2670,12 @@ _style_list["bar"] = Bar + if __doc__: + __doc__ = cbook.dedent(__doc__) % \ + {"AvailableConnectorstyles": _pprint_styles(_style_list)} - __doc__ = cbook.dedent(__doc__) % \ - {"AvailableConnectorstyles": _pprint_styles(_style_list)} - class ArrowStyle(_Style): """ :class:`ArrowStyle` is a container class which defines several @@ -3438,11 +3426,16 @@ _style_list["wedge"] = Wedge - __doc__ = cbook.dedent(__doc__) % \ - {"AvailableArrowstyles": _pprint_styles(_style_list)} + if __doc__: + __doc__ = cbook.dedent(__doc__) % \ + {"AvailableArrowstyles": _pprint_styles(_style_list)} +docstring.interpd.update( + AvailableArrowstyles = _pprint_styles(ArrowStyle._style_list), + AvailableConnectorstyles = _pprint_styles(ConnectionStyle._style_list), +) class FancyArrowPatch(Patch): """ @@ -3454,6 +3447,7 @@ return self.__class__.__name__ \ + "FancyArrowPatch(%g,%g,%g,%g,%g,%g)" % tuple(self._q_bezier) + @docstring.dedent_interpd def __init__(self, posA=None, posB=None, path=None, arrowstyle="simple", @@ -3535,14 +3529,6 @@ #self._draw_in_display_coordinate = True - kwdoc = dict() - kwdoc["AvailableArrowstyles"]=_pprint_styles(ArrowStyle._style_list) - kwdoc["AvailableConnectorstyles"]=_pprint_styles(ConnectionStyle._style_list) - - kwdoc.update(artist.kwdocd) - __init__.__doc__ = cbook.dedent(__init__.__doc__) % kwdoc - del kwdoc - def set_positions(self, posA, posB): """ set the begin end end positions of the connecting path. Use current vlaue if None. @@ -3768,6 +3754,7 @@ return "ConnectionPatch((%g,%g),(%g,%g))" % \ (self.xy1[0],self.xy1[1],self.xy2[0],self.xy2[1]) + @docstring.dedent_interpd def __init__(self, xyA, xyB, coordsA, coordsB=None, axesA=None, axesB=None, arrowstyle="-", @@ -3859,9 +3846,7 @@ # if True, draw annotation only if self.xy is inside the axes self._annotation_clip = None - __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd - def _get_xy(self, x, y, s, axes=None): """ caculate the pixel position of given point Modified: trunk/matplotlib/lib/matplotlib/projections/geo.py =================================================================== --- trunk/matplotlib/lib/matplotlib/projections/geo.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/projections/geo.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -5,7 +5,6 @@ import matplotlib rcParams = matplotlib.rcParams -from matplotlib.artist import kwdocd from matplotlib.axes import Axes from matplotlib import cbook from matplotlib.patches import Circle Modified: trunk/matplotlib/lib/matplotlib/projections/polar.py =================================================================== --- trunk/matplotlib/lib/matplotlib/projections/polar.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/projections/polar.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -5,10 +5,10 @@ import matplotlib rcParams = matplotlib.rcParams -from matplotlib.artist import kwdocd from matplotlib.axes import Axes import matplotlib.axis as maxis from matplotlib import cbook +from matplotlib import docstring from matplotlib.patches import Circle from matplotlib.path import Path from matplotlib.ticker import Formatter, Locator @@ -317,6 +317,7 @@ set_rscale = Axes.set_yscale set_rticks = Axes.set_yticks + @docstring.dedent_interpd def set_thetagrids(self, angles, labels=None, frac=None, **kwargs): """ @@ -353,8 +354,8 @@ for t in self.xaxis.get_ticklabels(): t.update(kwargs) return self.xaxis.get_ticklines(), self.xaxis.get_ticklabels() - set_thetagrids.__doc__ = cbook.dedent(set_thetagrids.__doc__) % kwdocd + @docstring.dedent_interpd def set_rgrids(self, radii, labels=None, angle=None, rpad=None, **kwargs): """ Set the radial locations and labels of the *r* grids. @@ -399,8 +400,6 @@ t.update(kwargs) return self.yaxis.get_gridlines(), self.yaxis.get_ticklabels() - set_rgrids.__doc__ = cbook.dedent(set_rgrids.__doc__) % kwdocd - def set_xscale(self, scale, *args, **kwargs): if scale != 'linear': raise NotImplementedError("You can not set the xscale on a polar plot.") Modified: trunk/matplotlib/lib/matplotlib/pyplot.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pyplot.py 2009-08-15 17:56:44 UTC (rev 7490) +++ trunk/matplotlib/lib/matplotlib/pyplot.py 2009-08-15 18:33:54 UTC (rev 7491) @@ -3,6 +3,7 @@ import matplotlib from matplotlib import _pylab_helpers, interactive from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike +from matplotlib import docstring from matplotlib.figure import Figure, figaspect from matplotlib.backend_bases import FigureCanvasBase from matplotlib.image import imread as _imread @@ -119,16 +120,14 @@ 'Turn interactive mode on.' matplotlib.interactive(True) +...@do...py_dedent(matplotlib.rc) def rc(*args, **kwargs): matplotlib.rc(*args, **kwargs) -if matplotlib.rc.__doc__ is not None: - rc.__doc__ = dedent(matplotlib.rc.__doc__) +...@do...py_dedent(matplotlib.rcdefaults) def rcdefaults(): matplotlib.rcdefaults() draw_if_interactive() -if matplotlib.rcdefaults.__doc__ is not None: - rcdefaults.__doc__ = dedent(matplotlib.rcdefaults.__doc__) # The current "image" (ScalarMappable) is tracked here on a # per-pylab-session basis: @@ -161,12 +160,11 @@ # (getp is simply imported) +...@do...py(_setp) def setp(*args, **kwargs): ret = _setp(*args, **kwargs) draw_if_interactive() return ret -if _setp.__doc__ is not None: - setp.__doc__ = _setp.__doc__ @@ -290,17 +288,13 @@ figManager = _pylab_helpers.Gcf.get_active() return figManager -# note we check for __doc__ is not None since py2exe optimize removes -# the docstrings +...@do...py_dedent(FigureCanvasBase.mpl_connect) def connect(s, func): return get_current_fig_manager().canvas.mpl_connect(s, func) -if FigureCanvasBase.mpl_connect.__doc__ is not None: - connect.__doc__ = dedent(FigureCanvasBase.mpl_connect.__doc__) +...@do...py_dedent(FigureCanvasBase.mpl_disconnect) def disconnect(cid): return get_current_fig_manager().canvas.mpl_disconnect(cid) -if FigureCanvasBase.mpl_disconnect.__doc__ is not None: - disconnect.__doc__ = dedent(FigureCanvasBase.mpl_disconnect.__doc__) def close(*args): """ @@ -351,12 +345,12 @@ 'redraw the current figure' get_current_fig_manager().canvas.draw() +...@do...py_dedent(Figure.savefig) def savefig(*args, **kwargs): fig = gcf() return fig.savefig(*args, **kwargs) -if Figure.savefig.__doc__ is not None: - savefig.__doc__ = dedent(Figure.savefig.__doc__) +...@do...py_dedent(Figure.ginput) def ginput(*args, **kwargs): """ Blocking call to interact with the figure. @@ -367,9 +361,8 @@ If *timeout* is negative, does not timeout. """ return gcf().ginput(*args, **kwargs) -if Figure.ginput.__doc__ is not None: - ginput.__doc__ = dedent(Figure.ginput.__doc__) +...@do...py_dedent(Figure.waitforbuttonpress) def waitforbuttonpress(*args, **kwargs): """ Blocking call to interact with the figure. @@ -381,36 +374,31 @@ If *timeout* is negative, does not timeout. """ return gcf().waitforbuttonpress(*args, **kwargs) -if Figure.waitforbuttonpress.__doc__ is not None: - waitforbuttonpress.__doc__ = dedent(Figure.waitforbuttonpress.__doc__) # Putting things in figures +...@do...py_dedent(Figure.text) def figtext(*args, **kwargs): ret = gcf().text(*args, **kwargs) draw_if_interactive() return ret -if Figure.text.__doc__ is not None: - figtext.__doc__ = dedent(Figure.text.__doc__) +...@do...py_dedent(Figure.suptitle) def suptitle(*args, **kwargs): ret = gcf().suptitle(*args, **kwargs) draw_if_interactive() return ret -if Figure.suptitle.__doc__ is not None: - suptitle.__doc__ = dedent(Figure.suptitle.__doc__) +@docstring.Appender("Addition kwargs: hold = [True|False] overrides default hold state", "\n") +...@do...py_dedent(Figure.figimage) def figimage(*args, **kwargs): # allow callers to override the hold state by passing hold=True|False ret = gcf().figimage(*args, **kwargs) draw_if_interactive() gci._current = ret return ret -if Figure.figimage.__doc__ is not None: - figimage.__doc__ = dedent(Figure.figimage.__doc__) + """ -Addition kwargs: hold = [True|False] overrides default hold state""" def figlegend(handles, labels, loc, **kwargs): """ @@ -930,6 +918,7 @@ return ret +...@do...dent_interpd def xscale(*args, **kwargs): """ call signature:: @@ -946,10 +935,8 @@ ret = ax.set_xscale(*args, **kwargs) draw_if_interactive() return ret -xscale.__doc__ = dedent(xscale.__doc__) % { - 'scale': ' | '.join([repr(_x) for _x in get_scale_names()]), - 'scale_docs': get_scale_docs()} +...@do...dent_interpd def yscale(*args, **kwargs): """ call signature:: @@ -966,9 +953,6 @@ ret = ax.set_yscale(*args, **kwargs) draw_if_interactive() return ret -yscale.__doc__ = dedent(yscale.__doc__) % { - 'scale': ' | '.join([repr(_x) for _x in get_scale_names()]), - 'scale_docs': get_scale_docs()} def xticks(*args, **kwargs): """ @@ -1415,15 +1399,13 @@ draw_if_interactive() +...@do...py_dedent(_imread) def imre... [truncated message content] |