summaryrefslogtreecommitdiff
path: root/Modules/xxmodule.c
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2002-08-14 01:44:33 +0000
committerSkip Montanaro <skip@pobox.com>2002-08-14 01:44:33 +0000
commit07249101083f367d08e3f3a7d7b9095789f599b5 (patch)
tree3344f8c7f667e467a109b2ebc5e14d070f538255 /Modules/xxmodule.c
parenta46298524aa566cf89f676786e3ce8b9a931b2a4 (diff)
downloadcpython-07249101083f367d08e3f3a7d7b9095789f599b5.tar.gz
add PyDoc_STR and PyDoc_STRVAR calls as examples for module authors
Diffstat (limited to 'Modules/xxmodule.c')
-rw-r--r--Modules/xxmodule.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
index 125d2ece1a..4b8822cfc5 100644
--- a/Modules/xxmodule.c
+++ b/Modules/xxmodule.c
@@ -57,7 +57,8 @@ Xxo_demo(XxoObject *self, PyObject *args)
}
static PyMethodDef Xxo_methods[] = {
- {"demo", (PyCFunction)Xxo_demo, METH_VARARGS},
+ {"demo", (PyCFunction)Xxo_demo, METH_VARARGS,
+ PyDoc_STR("demo() -> None")},
{NULL, NULL} /* sentinel */
};
@@ -143,6 +144,11 @@ static PyTypeObject Xxo_Type = {
/* Function of two integers returning integer */
+PyDoc_STRVAR(xx_foo_doc,
+"foo(i,j)\n\
+\n\
+Return the sum of i and j.");
+
static PyObject *
xx_foo(PyObject *self, PyObject *args)
{
@@ -208,13 +214,19 @@ xx_roj(PyObject *self, PyObject *args)
/* List of functions defined in the module */
static PyMethodDef xx_methods[] = {
- {"roj", xx_roj, METH_VARARGS},
- {"foo", xx_foo, METH_VARARGS},
- {"new", xx_new, METH_VARARGS},
- {"bug", xx_bug, METH_VARARGS},
+ {"roj", xx_roj, METH_VARARGS,
+ PyDoc_STR("roj(a,b) -> None")},
+ {"foo", xx_foo, METH_VARARGS,
+ xx_foo_doc},
+ {"new", xx_new, METH_VARARGS,
+ PyDoc_STR("new() -> new Xx object")},
+ {"bug", xx_bug, METH_VARARGS,
+ PyDoc_STR("bug(o) -> None")},
{NULL, NULL} /* sentinel */
};
+PyDoc_STRVAR(module_doc,
+"This is a template module just for instruction.");
/* Initialization function for the module (*must* be called initxx) */
@@ -228,7 +240,7 @@ initxx(void)
Xxo_Type.ob_type = &PyType_Type;
/* Create the module and add the functions */
- m = Py_InitModule("xx", xx_methods);
+ m = Py_InitModule3("xx", xx_methods, module_doc);
/* Add some symbolic constants to the module */
if (ErrorObject == NULL) {