mardi 30 juin 2015

Use sphinx to create documentation of Python modules adding a module containing C wrappers


I am using sphinx to generate automatic documentation when writing my Python modules. Everything works fine till I want to add to the documentation also a section including a module having wrappers to C functions.

For instance, suppose that I have written a file c_module.c that look like this

#include <Python.h>

/*  wrapped function */
static PyObject* some_func(PyObject* self, PyObject* args)
{
    ...
}

/*  define functions in module */
static PyMethodDef CMethods[] =
{
     {"some_func", some_func, METH_VARARGS, ""},
     {NULL, NULL, 0, NULL}
};

/* module initialization */
PyMODINIT_FUNC

initcos_module(void)
{
     (void) Py_InitModule("c_module", CMethods);
}

where and how shall I put my comments so that sphinx is able to understand them? Moreover, what do I have to include in the index.rst file to add the documentation related to this c_module? Shall I add another rst file, somehow like "c_module.rst"? If so what should I put inside?

I came across the concept of "Domains" reading the sphinx documentation but I cannot understand the rationale behind them. Any help is really appreciated, thanks!


Aucun commentaire:

Enregistrer un commentaire