Is there a good way to produce documentation for swig interfaces?

你离开我真会死。 提交于 2019-11-30 18:51:10

There's some mileage in %feature("autodoc") with SWIG 2.0, which I think is as far is it goes currently.

For example:

%module test

%feature("autodoc", "3");

void foo (int *a, void *bar, double epsilon);

causes some vaguely sane documentation to be inserted.

If that isn't sufficient I think the next easiest step would be to use %pythonprepend to make a marker that's unique enough sed or similar can be used to insert documentation into the interface after SWIG has run automatically:

%pythonprepend foo "MARKER"

and then:

sed -ei 's/MARKER/some documentation' test.py

Where you could find the functions to %pythonprepend by looking over the Doxygen output using a (Python?) script to generate the markers and substitute them after running SWIG.

To get your doxygen comments into the python files there exists a python tool called doxy2swig.py on the web as described here.

Create xml documentation from your code. Then use the tool:

doxy2swig.py index.xml documentation.i

and import documentation.i in you swig interface file via

%import "documentation.i"

And its done.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!