Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,7 @@ namespace dynamicgraph { ...@@ -50,6 +50,7 @@ namespace dynamicgraph {
extern PyObject* executeCommand(PyObject* self, PyObject* args); extern PyObject* executeCommand(PyObject* self, PyObject* args);
extern PyObject* listCommands(PyObject* self, PyObject* args); extern PyObject* listCommands(PyObject* self, PyObject* args);
extern PyObject* getCommandDocstring(PyObject* self, PyObject* args); extern PyObject* getCommandDocstring(PyObject* self, PyObject* args);
extern PyObject* getDocString(PyObject* self, PyObject* args);
} }
namespace factory { namespace factory {
...@@ -186,6 +187,10 @@ static PyMethodDef dynamicGraphMethods[] = { ...@@ -186,6 +187,10 @@ static PyMethodDef dynamicGraphMethods[] = {
dynamicgraph::python::entity::getCommandDocstring, dynamicgraph::python::entity::getCommandDocstring,
METH_VARARGS, METH_VARARGS,
"get the docstring of an entity command"}, "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", {"factory_get_entity_class_list",
dynamicgraph::python::factory::getEntityClassList, dynamicgraph::python::factory::getEntityClassList,
METH_VARARGS, METH_VARARGS,
......
...@@ -85,6 +85,7 @@ class Entity (object) : ...@@ -85,6 +85,7 @@ class Entity (object) :
Entity.__init__(self, self.className, name) Entity.__init__(self, self.className, name)
if not self.__class__.commandCreated: if not self.__class__.commandCreated:
self.boundClassCommands() self.boundClassCommands()
self.__class__.__doc__ = wrap.entity_get_docstring (self.obj)
self.__class__.commandCreated = True self.__class__.commandCreated = True
@property @property
......
...@@ -305,6 +305,32 @@ namespace dynamicgraph { ...@@ -305,6 +305,32 @@ namespace dynamicgraph {
return Py_BuildValue("s", docstring.c_str()); 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) PyObject* display(PyObject* /*self*/, PyObject* args)
{ {
/* Retrieve the entity instance. */ /* Retrieve the entity instance. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment