piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2010 Free Software Foundation, Inc. |
| 3 | # |
| 4 | # This file is part of GNU Radio |
| 5 | # |
| 6 | # GNU Radio is free software; you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation; either version 3, or (at your option) |
| 9 | # any later version. |
| 10 | # |
| 11 | # GNU Radio is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with GNU Radio; see the file COPYING. If not, write to |
| 18 | # the Free Software Foundation, Inc., 51 Franklin Street, |
| 19 | # Boston, MA 02110-1301, USA. |
| 20 | # |
| 21 | """ |
| 22 | Python interface to contents of doxygen xml documentation. |
| 23 | |
| 24 | Example use: |
| 25 | See the contents of the example folder for the C++ and |
| 26 | doxygen-generated xml used in this example. |
| 27 | |
| 28 | >>> # Parse the doxygen docs. |
| 29 | >>> import os |
| 30 | >>> this_dir = os.path.dirname(globals()['__file__']) |
| 31 | >>> xml_path = this_dir + "/example/xml/" |
| 32 | >>> di = DoxyIndex(xml_path) |
| 33 | |
| 34 | Get a list of all top-level objects. |
| 35 | |
| 36 | >>> print([mem.name() for mem in di.members()]) |
| 37 | [u'Aadvark', u'aadvarky_enough', u'main'] |
| 38 | |
| 39 | Get all functions. |
| 40 | |
| 41 | >>> print([mem.name() for mem in di.in_category(DoxyFunction)]) |
| 42 | [u'aadvarky_enough', u'main'] |
| 43 | |
| 44 | Check if an object is present. |
| 45 | |
| 46 | >>> di.has_member(u'Aadvark') |
| 47 | True |
| 48 | >>> di.has_member(u'Fish') |
| 49 | False |
| 50 | |
| 51 | Get an item by name and check its properties. |
| 52 | |
| 53 | >>> aad = di.get_member(u'Aadvark') |
| 54 | >>> print(aad.brief_description) |
| 55 | Models the mammal Aadvark. |
| 56 | >>> print(aad.detailed_description) |
| 57 | Sadly the model is incomplete and cannot capture all aspects of an aadvark yet. |
| 58 | <BLANKLINE> |
| 59 | This line is uninformative and is only to test line breaks in the comments. |
| 60 | >>> [mem.name() for mem in aad.members()] |
| 61 | [u'aadvarkness', u'print', u'Aadvark', u'get_aadvarkness'] |
| 62 | >>> aad.get_member(u'print').brief_description |
| 63 | u'Outputs the vital aadvark statistics.' |
| 64 | |
| 65 | """ |
| 66 | |
| 67 | from doxyindex import DoxyIndex, DoxyFunction, DoxyParam, DoxyClass, DoxyFile, DoxyNamespace, DoxyGroup, DoxyFriend, DoxyOther |
| 68 | |
| 69 | def _test(): |
| 70 | import os |
| 71 | this_dir = os.path.dirname(globals()['__file__']) |
| 72 | xml_path = this_dir + "/example/xml/" |
| 73 | di = DoxyIndex(xml_path) |
| 74 | # Get the Aadvark class |
| 75 | aad = di.get_member('Aadvark') |
| 76 | aad.brief_description |
| 77 | import doctest |
| 78 | return doctest.testmod() |
| 79 | |
| 80 | if __name__ == "__main__": |
| 81 | _test() |
| 82 | |