Hello, I have a docstring related patch which I would like to submit. It outputs nice python signatures with every function, condensing the overloads and displaying the default parameter values. This is how the output of help looks
help(ugui.AngleField.value) Help on method value:
value(...) unbound sitius.ugui.AngleField method value( (AngleField)self) -> Angle : returns the field's value value( (AngleField)self, (Angle)angle [, (bool)invoke_callback=False]) -> AngleField : Sets the value of the field and optionally invokes the activate callback Here is the summary of changes that I have. 1. added "PyTypeObject* converter::registration::expected_from_python_class_object() const" method used to find a python class that is convertible to a given parameter type 2 added type_info member to the signature_element to allow using the method of 1 3. added member template <class Sig> struct extract_return_type{ typename type; }; to every call policy class. for the default_call_policies class for example it is: template <class Sig> struct extract_return_type { typedef BOOST_DEDUCED_TYPENAME mpl::front<Sig>::type type; }; but for return_arg it is: template <class Sig> struct extract_return_type{ typedef BOOST_DEDUCED_TYPENAME mpl::at_c<Sig, arg_pos>::type type; }; 4. added to py_function: virtual python::detail::signature_element const& get_return_type() const {return signature()[0];} and overloaded it for the policy based py_functions 5. *HACK* made the lvalue_from_python_chain::convert(0) and rvalue_from_python_chain::convertible(0) to return PyTypeObject *( the python type they expect or 0) and used it in the implementation of 1 5 is dangerous because it will crash if someone registers lvalue_from_python_chain::convert and rvalue_from_python_chain::convertible directly with the expectation that the parameter is non zero a cleaner way would be to add another member to rvalue_from_python_chain and lvalue_from_python_chain to return their PyTypeObject expectation. 6. added a new class function_doc_signature_generator which uses 1-5 to generate python style signatures. Is there interest for this patch, and What is the best cvs diff format for submiting patch? Regards, Nikolay Mladenov Sitius Automation
participants (1)
-
Nikolay Mladenov