summaryrefslogtreecommitdiff
path: root/src/stream_template.c
diff options
context:
space:
mode:
authorDwayne Litzenberger <dlitz@dlitz.net>2013-07-14 20:26:53 -0700
committerDwayne Litzenberger <dlitz@dlitz.net>2013-07-14 20:26:53 -0700
commit63bc0fb0aa463a70a0d115fad21219b896683c8d (patch)
tree1e1542325314e7af8df6c85d44cb3015f9f206e6 /src/stream_template.c
parent103bf3ecccf7f5d048385b0494081f140df71cc4 (diff)
downloadpycrypto-63bc0fb0aa463a70a0d115fad21219b896683c8d.tar.gz
Improve C extension autodocs
- Add __all__ to C cipher & hash modules - Update hash module docstrings to document the block_size and digest_size variables. Closes: https://bugs.launchpad.net/pycrypto/+bug/1179255
Diffstat (limited to 'src/stream_template.c')
-rw-r--r--src/stream_template.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/stream_template.c b/src/stream_template.c
index 1770a3c..c0aa42c 100644
--- a/src/stream_template.c
+++ b/src/stream_template.c
@@ -278,6 +278,7 @@ PyMODINIT_FUNC
_MODULE_NAME (void)
{
PyObject *m = NULL;
+ PyObject *__all__ = NULL;
if (PyType_Ready(&ALGtype) < 0)
goto errout;
@@ -292,9 +293,24 @@ _MODULE_NAME (void)
if (m == NULL)
goto errout;
+ /* Add the type object to the module (using the name of the module itself),
+ * so that its methods docstrings are discoverable by introspection tools. */
+ PyObject_SetAttrString(m, _MODULE_STRING, (PyObject *)&ALGtype);
+
+ /* Add some symbolic constants to the module */
PyModule_AddIntConstant(m, "block_size", BLOCK_SIZE);
PyModule_AddIntConstant(m, "key_size", KEY_SIZE);
+ /* Create __all__ (to help generate documentation) */
+ __all__ = PyList_New(4);
+ if (__all__ == NULL)
+ goto errout;
+ PyList_SetItem(__all__, 0, PyString_FromString(_MODULE_STRING)); /* This is the ALGType object */
+ PyList_SetItem(__all__, 1, PyString_FromString("new"));
+ PyList_SetItem(__all__, 2, PyString_FromString("block_size"));
+ PyList_SetItem(__all__, 3, PyString_FromString("key_size"));
+ PyObject_SetAttrString(m, "__all__", __all__);
+
out:
/* Final error check */
if (m == NULL && !PyErr_Occurred()) {
@@ -303,6 +319,7 @@ out:
}
/* Free local objects here */
+ Py_CLEAR(__all__);
/* Return */
#ifdef IS_PY3K