fiddle with pyvips8 docstrings

This commit is contained in:
John Cupitt 2014-11-10 22:37:16 +00:00
parent 2c93340c77
commit 70e470b0a5
2 changed files with 26 additions and 2 deletions

15
TODO
View File

@ -2,7 +2,20 @@
- can we generate python docstrings?
when we make a __getattr__ object, make it respond to __doc__
this works
help(Vips.Image.black)
but this does not
help(Vips.Image.add)
since add is an instance method ... this does work
a = Vips.Image.black(10, 10)
help(a.add)
do we need to override __getattribute__ as well?
- test other arg types

View File

@ -418,7 +418,11 @@ class Image(Vips.Image):
if name in dir(self.props):
return getattr(self.props, name)
return lambda *args, **kwargs: _call_instance(self, name, args, kwargs)
def call_function(*args, **kwargs):
return _call_instance(self, name, args, kwargs)
call_function.__doc__ = "hello world, from " + name
return call_function
def __add__(self, other):
if isinstance(other, Vips.Image):
@ -747,8 +751,15 @@ class_methods = [
"fitsload",
"openexrload"]
def add_doc(value):
def _doc(func):
func.__doc__ = value
return func
return _doc
def generate_class_method(name):
@classmethod
@add_doc('hello, world!')
def class_method(cls, *args, **kwargs):
return _call_base(name, args, kwargs)