Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doxygen C++ comment string parser in python?

Does anybody know of a python module to parse a doxygen style C++ comment string? I mean a string like this (simple example):

  /**
   * A constructor.
   * A more elaborate description of the constructor.
   * @param param1 test1
   * @param param2 test2
   */

and I would like to extract the brief, the long description, the parameters, the return value etc. I'm currently doing this using string methods and regular expressions but my solution is not very robust. Alternatively can anybody recommend an easy to use python parser lib that I can set up quickly?

Thanks in advance

like image 853
Sebastian Avatar asked Mar 04 '10 09:03

Sebastian


2 Answers

You should take a look at how doxygen is implemented to see how it handles parsing. I very much doubt it uses regex.

like image 30
Taybin Avatar answered Sep 20 '22 13:09

Taybin


You might be able to set something up using the SimpleParse module, but this does require creating an EBNF grammar which might be more investment than you are interested in.

The Sphinx/Doxygen bridge (Breathe) uses the xml output of Doxygen and acts on that instead. Perhaps a similar approach could work here - run Doxygen to extract xml formatted docs and then leverage some of the code from Breathe to get at the data you require.

like image 167
Mark Streatfield Avatar answered Sep 17 '22 13:09

Mark Streatfield