Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'd like to know if there are any good techniques for constructing/maintaining documentation on the interface.

I'm building an interface from c++ code to python using swig; mostly I'm just %including the c++ header files. I'm dealing with at least dozens of classes and 100's of functions, so automated tools are preferred.

Ideally, I'd like to use the doxygen formatted comments in the c++ headers to populate the docstrings in the python classes/methods.

Alternately, generating separate documentation (in ascii, html...) would also be useful. It looks like this kind of functionality was supported in earlier versions of swig (1.3 and earlier) but I don't see a way to do it with 2.0.

Are there any useful (automated) techniques for documenting the interface?

like image 540
Dave Avatar asked Jul 11 '12 14:07

Dave


People also ask

What is SWIG programming?

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of target languages including common scripting languages such as Javascript, Perl, PHP, Python, Tcl and Ruby.

What is SWIG compiler?

SWIG is a software development tool that simplifies the task of interfacing different languages to C and C++ programs. In a nutshell, SWIG is a compiler that takes C/C++ declarations and creates the wrappers needed to access those declarations from other languages including Perl, Python, Tcl, Ruby, Guile, and Java.

How do I use SWIG in Python?

Built the extension >python setup.py build_ext running build_ext building '_example' extension creating build creating build\temp. win32-3.6 creating build\temp. win32-3.6\Release …. That's it now we are able to wrap our c language to python language.

What is SWIG library?

The Simplified Wrapper and Interface Generator (SWIG) is an open-source software tool used to connect computer programs or libraries written in C or C++ with scripting languages such as Lua, Perl, PHP, Python, R, Ruby, Tcl, and other languages like C#, Java, JavaScript, Go, D, OCaml, Octave, Scilab and Scheme.


1 Answers

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.

like image 121
Andreas Walter Avatar answered Oct 21 '22 20:10

Andreas Walter