docs: use PyDoc_STRVAR in the Object type

This commit is contained in:
J. David Ibáñez
2013-02-02 22:20:03 +01:00
parent 4b72047260
commit c0543b5db4

View File

@@ -48,6 +48,10 @@ Object_dealloc(Object* self)
PyObject_Del(self); PyObject_Del(self);
} }
PyDoc_STRVAR(Object_get_oid__doc__,
"The object id, a byte string 20 bytes long.");
PyObject * PyObject *
Object_get_oid(Object *self) Object_get_oid(Object *self)
{ {
@@ -59,6 +63,10 @@ Object_get_oid(Object *self)
return git_oid_to_python(oid->id); return git_oid_to_python(oid->id);
} }
PyDoc_STRVAR(Object_get_hex__doc__,
"Hexadecimal representation of the object id, a text string 40 chars long.");
PyObject * PyObject *
Object_get_hex(Object *self) Object_get_hex(Object *self)
{ {
@@ -70,12 +78,21 @@ Object_get_hex(Object *self)
return git_oid_to_py_str(oid); return git_oid_to_py_str(oid);
} }
PyDoc_STRVAR(Object_get_type__doc__,
"One of the GIT_OBJ_COMMIT, GIT_OBJ_TREE, GIT_OBJ_BLOB or GIT_OBJ_TAG "
"constants.");
PyObject * PyObject *
Object_get_type(Object *self) Object_get_type(Object *self)
{ {
return PyInt_FromLong(git_object_type(self->obj)); return PyInt_FromLong(git_object_type(self->obj));
} }
PyDoc_STRVAR(Object_read_raw__doc__,
"Returns the byte string with the raw contents of the of the object.");
PyObject * PyObject *
Object_read_raw(Object *self) Object_read_raw(Object *self)
{ {
@@ -99,25 +116,21 @@ Object_read_raw(Object *self)
} }
PyGetSetDef Object_getseters[] = { PyGetSetDef Object_getseters[] = {
{"oid", (getter)Object_get_oid, NULL, {"oid", (getter)Object_get_oid, NULL, Object_get_oid__doc__, NULL},
"The object id, a byte string 20 bytes long.", NULL}, {"hex", (getter)Object_get_hex, NULL, Object_get_hex__doc__, NULL},
{"hex", (getter)Object_get_hex, NULL, {"type", (getter)Object_get_type, NULL, Object_get_type__doc__, NULL},
"Hexadecimal representation of the object id, a text string 40 chars "
"long.",
NULL},
{"type", (getter)Object_get_type, NULL,
"One of the GIT_OBJ_COMMIT, GIT_OBJ_TREE, GIT_OBJ_BLOB or "
"GIT_OBJ_TAG constants.",
NULL},
{NULL} {NULL}
}; };
PyMethodDef Object_methods[] = { PyMethodDef Object_methods[] = {
{"read_raw", (PyCFunction)Object_read_raw, METH_NOARGS, {"read_raw", (PyCFunction)Object_read_raw, METH_NOARGS,
"Returns the byte string with the raw contents of the of the object."}, Object_read_raw__doc__},
{NULL} {NULL}
}; };
PyDoc_STRVAR(Object__doc__, "Base class for Git objects.");
PyTypeObject ObjectType = { PyTypeObject ObjectType = {
PyVarObject_HEAD_INIT(NULL, 0) PyVarObject_HEAD_INIT(NULL, 0)
"_pygit2.Object", /* tp_name */ "_pygit2.Object", /* tp_name */
@@ -139,7 +152,7 @@ PyTypeObject ObjectType = {
0, /* tp_setattro */ 0, /* tp_setattro */
0, /* tp_as_buffer */ 0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
"Object objects", /* tp_doc */ Object__doc__, /* tp_doc */
0, /* tp_traverse */ 0, /* tp_traverse */
0, /* tp_clear */ 0, /* tp_clear */
0, /* tp_richcompare */ 0, /* tp_richcompare */