Gustavo Carneiro wrote:

Sounds good.

Sorry I wasn't online to help with the other questions. I assume those problems are solved, if not please ask again the questions.


    Where I've got to now is I can't find how to declare a docstring
    for a function or method.


Doesn't this work?

     module.add_function(..., docstring="this is a docstring")

OK, looking at the code I found two bugs in pybindgen wrt docstrings:

1. there is a bug with handling docstrings with overloaded functions; they will only work if the function is not overloaded with another function with the same name;

2. I forgot to add a docstring parameter to method objects. But it's a simple workaround, just:

        method = MyClass.add_method(...)
        method.docstring = "this is a docstring"

    Again, only works if the method is not overloaded.

Thanks Gustavo

That gave me all the clues I needed. I've only just started using Python so my patch (below) is very much derived from the 'suck it and see' philosophy. It seems to work for me however!!

diff -PurN pybindgen/cppmethod.py ../../pybindgen-0.10.0/pybindgen/cppmethod.py
--- pybindgen/cppmethod.py      2008-11-08 07:55:41.000000000 +1300
+++ ../../pybindgen-0.10.0/pybindgen/cppmethod.py 2009-04-27 23:05:27.000000000 +1200
@@ -19,7 +19,7 @@
    Class that generates a wrapper to a C++ class method
    """

- def __init__(self, method_name, return_value, parameters, is_static=False, + def __init__(self, method_name, return_value, parameters, is_static=False, docstring=None,
                 template_parameters=(), is_virtual=False, is_const=False,
                 unblock_threads=None, is_pure_virtual=False,
                 custom_template_method_name=None, visibility='public',
@@ -95,7 +95,7 @@
        #self.static_decl = True
        self._class = None
        self._helper_class = None
-        self.docstring = None
+        self.docstring = docstring
        self.wrapper_base_name = None
        self.wrapper_actual_name = None
        self.return_value = None


Cheers

--
Robin


=======================================================================
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
=======================================================================

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to