File tree 3 files changed +26
-0
lines changed
3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 3
3
from . import _api
4
4
5
5
6
+ def kwdoc (text ):
7
+ """
8
+ Decorator for adding kwdoc documentation to Artist property setters.
9
+
10
+ The given text is stored in a privat variable ``_kwdoc`` on the method.
11
+ It is used for generating the kwdoc list for artists, which we
12
+ auto-generate through docstring interpolation, e.g. via
13
+ ``%(Line2D:kwdoc)s``.
14
+
15
+ The text should contain the supported types as well as the default value
16
+ if applicable, e.g.:
17
+
18
+ @_docstring.kwdoc("bool, default: :rc:`text.usetex`")
19
+ def set_usetex(self, usetex):
20
+
21
+ """
22
+ def decorator (func ):
23
+ func ._kwdoc = text
24
+ return func
25
+ return decorator
26
+
27
+
6
28
class Substitution :
7
29
"""
8
30
A decorator that performs %-substitution on an object's docstring.
Original file line number Diff line number Diff line change @@ -1433,6 +1433,9 @@ def get_valid_values(self, attr):
1433
1433
raise AttributeError ('%s has no function %s' % (self .o , name ))
1434
1434
func = getattr (self .o , name )
1435
1435
1436
+ if hasattr (func , '_kwdoc' ):
1437
+ return func ._kwdoc
1438
+
1436
1439
docstring = inspect .getdoc (func )
1437
1440
if docstring is None :
1438
1441
return 'unknown'
Original file line number Diff line number Diff line change @@ -1279,6 +1279,7 @@ def set_fontproperties(self, fp):
1279
1279
self ._fontproperties = FontProperties ._from_any (fp ).copy ()
1280
1280
self .stale = True
1281
1281
1282
+ @_docstring .kwdoc ("bool, default: :rc:`text.usetex`" )
1282
1283
def set_usetex (self , usetex ):
1283
1284
"""
1284
1285
Parameters
You can’t perform that action at this time.
0 commit comments