Creating doxygen comments for created Swig C # that wraps C ++

I have a project written in C ++ where I use swig to create some C # wrappers. C ++ code uses Doxygen style comments to annotate classes and functions. Is it possible to get Swig to take these doxygen comments and produce doxygen comments for C # shell classes and functions?

+5
source share
1 answer

SWIG does not currently parse code comments, including the Doxygen documentation.

For several years there has been a development of a SWIG branch that allows SWIG to process Doxygen comments, but even now (AFAIK) it only compares them with the documentation in Java and Python.

Currently, the best option is to extract the Doxygen documentation from the C ++ source code and paste it into the generated SWIG wrapper. To understand how this can be done, here is a brief explanation of what doxy2swig.py does (and this is really intended for python docstrings):

  • Let Doxygen extract the documentation into its XML format
  • Parse the XML and reformat it to the appropriate Python docs
  • Write the SWIG directives %feature("docstring") to tell SWIG to attach docstrings to wrapped classes and methods.

In principle, something similar can be done for C #. I don’t know how to do this (2) for C #, that is, how to translate Doxygen XML output into suitable documentation in C #, it may need to be implemented independently (perhaps by changing the doxy2swig.py script).

There is a neat trick for (3) that is kind of documented here , noting that the same can be done for C # using %csclassmodifiers and %csmethodmodifiers . These SWIG function directives are AFAIKs used to add public or protected methods to C # methods or classes. But they can be stolen to add the extracted documentation (+ the public keyword, not to forget). Thus, they effectively allow you to use the same functions as the %feature("docstring") directive for Python.

Finally, I don't know C #, but what's the point of having Doxygen comments included in the C # shell? If you want to use Doxygen to create documentation, you can do it directly from C ++ sources so you don't get anything. In Python, dockers can appear as help at runtime and are used by some IDEs. Does C # have this too?

+4
source

All Articles