Commit 516eb712 authored by Florent Lamiraux's avatar Florent Lamiraux Committed by Florent Lamiraux florent@laas.fr
Browse files

Document entity class types with the output of C++ getDocString method.

parent 4b88b840
......@@ -50,6 +50,7 @@ namespace dynamicgraph {
extern PyObject* executeCommand(PyObject* self, PyObject* args);
extern PyObject* listCommands(PyObject* self, PyObject* args);
extern PyObject* getCommandDocstring(PyObject* self, PyObject* args);
extern PyObject* getDocString(PyObject* self, PyObject* args);
}
namespace factory {
......@@ -186,6 +187,10 @@ static PyMethodDef dynamicGraphMethods[] = {
dynamicgraph::python::entity::getCommandDocstring,
METH_VARARGS,
"get the docstring of an entity command"},
{"entity_get_docstring",
dynamicgraph::python::entity::getDocString,
METH_VARARGS,
"get the doc string of an entity type"},
{"factory_get_entity_class_list",
dynamicgraph::python::factory::getEntityClassList,
METH_VARARGS,
......
......@@ -85,6 +85,7 @@ class Entity (object) :
Entity.__init__(self, self.className, name)
if not self.__class__.commandCreated:
self.boundClassCommands()
self.__class__.__doc__ = wrap.entity_get_docstring (self.obj)
self.__class__.commandCreated = True
@property
......
......@@ -305,6 +305,32 @@ namespace dynamicgraph {
return Py_BuildValue("s", docstring.c_str());
}
PyObject* getDocString(PyObject* /*self*/, PyObject* args)
{
PyObject* object = NULL;
if (!PyArg_ParseTuple(args, "O", &object)) {
return NULL;
}
// Retrieve the entity instance
if (!PyCObject_Check(object)) {
PyErr_SetString(dgpyError, "first argument is not an object");
return NULL;
}
void* pointer = PyCObject_AsVoidPtr(object);
Entity* entity = (Entity*)pointer;
try {
return Py_BuildValue ("s", entity->getDocString ().c_str ());
} catch (const std::exception& exc) {
PyErr_SetString(dgpyError, exc.what ()) ;
return NULL;
} catch (...) {
PyErr_SetString(dgpyError, "Unknown exception");
return NULL;
}
return NULL;
}
PyObject* display(PyObject* /*self*/, PyObject* args)
{
/* Retrieve the entity instance. */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment