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 | Classes providing more user-friendly interfaces to the doxygen xml |
| 23 | docs than the generated classes provide. |
| 24 | """ |
| 25 | |
| 26 | import os |
| 27 | |
| 28 | from generated import index |
| 29 | from base import Base |
| 30 | from text import description |
| 31 | |
| 32 | class DoxyIndex(Base): |
| 33 | """ |
| 34 | Parses a doxygen xml directory. |
| 35 | """ |
| 36 | |
| 37 | __module__ = "gnuradio.utils.doxyxml" |
| 38 | |
| 39 | def _parse(self): |
| 40 | if self._parsed: |
| 41 | return |
| 42 | super(DoxyIndex, self)._parse() |
| 43 | self._root = index.parse(os.path.join(self._xml_path, 'index.xml')) |
| 44 | for mem in self._root.compound: |
| 45 | converted = self.convert_mem(mem) |
| 46 | # For files we want the contents to be accessible directly |
| 47 | # from the parent rather than having to go through the file |
| 48 | # object. |
| 49 | if self.get_cls(mem) == DoxyFile: |
| 50 | if mem.name.endswith('.h'): |
| 51 | self._members += converted.members() |
| 52 | self._members.append(converted) |
| 53 | else: |
| 54 | self._members.append(converted) |
| 55 | |
| 56 | |
| 57 | def generate_swig_doc_i(self): |
| 58 | """ |
| 59 | %feature("docstring") gr_make_align_on_samplenumbers_ss::align_state " |
| 60 | Wraps the C++: gr_align_on_samplenumbers_ss::align_state"; |
| 61 | """ |
| 62 | pass |
| 63 | |
| 64 | |
| 65 | class DoxyCompMem(Base): |
| 66 | |
| 67 | |
| 68 | kind = None |
| 69 | |
| 70 | def __init__(self, *args, **kwargs): |
| 71 | super(DoxyCompMem, self).__init__(*args, **kwargs) |
| 72 | |
| 73 | @classmethod |
| 74 | def can_parse(cls, obj): |
| 75 | return obj.kind == cls.kind |
| 76 | |
| 77 | def set_descriptions(self, parse_data): |
| 78 | bd = description(getattr(parse_data, 'briefdescription', None)) |
| 79 | dd = description(getattr(parse_data, 'detaileddescription', None)) |
| 80 | self._data['brief_description'] = bd |
| 81 | self._data['detailed_description'] = dd |
| 82 | |
| 83 | class DoxyCompound(DoxyCompMem): |
| 84 | pass |
| 85 | |
| 86 | class DoxyMember(DoxyCompMem): |
| 87 | pass |
| 88 | |
| 89 | |
| 90 | class DoxyFunction(DoxyMember): |
| 91 | |
| 92 | __module__ = "gnuradio.utils.doxyxml" |
| 93 | |
| 94 | kind = 'function' |
| 95 | |
| 96 | def _parse(self): |
| 97 | if self._parsed: |
| 98 | return |
| 99 | super(DoxyFunction, self)._parse() |
| 100 | self.set_descriptions(self._parse_data) |
| 101 | self._data['params'] = [] |
| 102 | prms = self._parse_data.param |
| 103 | for prm in prms: |
| 104 | self._data['params'].append(DoxyParam(prm)) |
| 105 | |
| 106 | brief_description = property(lambda self: self.data()['brief_description']) |
| 107 | detailed_description = property(lambda self: self.data()['detailed_description']) |
| 108 | params = property(lambda self: self.data()['params']) |
| 109 | |
| 110 | Base.mem_classes.append(DoxyFunction) |
| 111 | |
| 112 | |
| 113 | class DoxyParam(DoxyMember): |
| 114 | |
| 115 | __module__ = "gnuradio.utils.doxyxml" |
| 116 | |
| 117 | def _parse(self): |
| 118 | if self._parsed: |
| 119 | return |
| 120 | super(DoxyParam, self)._parse() |
| 121 | self.set_descriptions(self._parse_data) |
| 122 | self._data['declname'] = self._parse_data.declname |
| 123 | |
| 124 | brief_description = property(lambda self: self.data()['brief_description']) |
| 125 | detailed_description = property(lambda self: self.data()['detailed_description']) |
| 126 | declname = property(lambda self: self.data()['declname']) |
| 127 | |
| 128 | class DoxyClass(DoxyCompound): |
| 129 | |
| 130 | __module__ = "gnuradio.utils.doxyxml" |
| 131 | |
| 132 | kind = 'class' |
| 133 | |
| 134 | def _parse(self): |
| 135 | if self._parsed: |
| 136 | return |
| 137 | super(DoxyClass, self)._parse() |
| 138 | self.retrieve_data() |
| 139 | if self._error: |
| 140 | return |
| 141 | self.set_descriptions(self._retrieved_data.compounddef) |
| 142 | # Sectiondef.kind tells about whether private or public. |
| 143 | # We just ignore this for now. |
| 144 | self.process_memberdefs() |
| 145 | |
| 146 | brief_description = property(lambda self: self.data()['brief_description']) |
| 147 | detailed_description = property(lambda self: self.data()['detailed_description']) |
| 148 | |
| 149 | Base.mem_classes.append(DoxyClass) |
| 150 | |
| 151 | |
| 152 | class DoxyFile(DoxyCompound): |
| 153 | |
| 154 | __module__ = "gnuradio.utils.doxyxml" |
| 155 | |
| 156 | kind = 'file' |
| 157 | |
| 158 | def _parse(self): |
| 159 | if self._parsed: |
| 160 | return |
| 161 | super(DoxyFile, self)._parse() |
| 162 | self.retrieve_data() |
| 163 | self.set_descriptions(self._retrieved_data.compounddef) |
| 164 | if self._error: |
| 165 | return |
| 166 | self.process_memberdefs() |
| 167 | |
| 168 | brief_description = property(lambda self: self.data()['brief_description']) |
| 169 | detailed_description = property(lambda self: self.data()['detailed_description']) |
| 170 | |
| 171 | Base.mem_classes.append(DoxyFile) |
| 172 | |
| 173 | |
| 174 | class DoxyNamespace(DoxyCompound): |
| 175 | |
| 176 | __module__ = "gnuradio.utils.doxyxml" |
| 177 | |
| 178 | kind = 'namespace' |
| 179 | |
| 180 | Base.mem_classes.append(DoxyNamespace) |
| 181 | |
| 182 | |
| 183 | class DoxyGroup(DoxyCompound): |
| 184 | |
| 185 | __module__ = "gnuradio.utils.doxyxml" |
| 186 | |
| 187 | kind = 'group' |
| 188 | |
| 189 | def _parse(self): |
| 190 | if self._parsed: |
| 191 | return |
| 192 | super(DoxyGroup, self)._parse() |
| 193 | self.retrieve_data() |
| 194 | if self._error: |
| 195 | return |
| 196 | cdef = self._retrieved_data.compounddef |
| 197 | self._data['title'] = description(cdef.title) |
| 198 | # Process inner groups |
| 199 | grps = cdef.innergroup |
| 200 | for grp in grps: |
| 201 | converted = DoxyGroup.from_refid(grp.refid, top=self.top) |
| 202 | self._members.append(converted) |
| 203 | # Process inner classes |
| 204 | klasses = cdef.innerclass |
| 205 | for kls in klasses: |
| 206 | converted = DoxyClass.from_refid(kls.refid, top=self.top) |
| 207 | self._members.append(converted) |
| 208 | # Process normal members |
| 209 | self.process_memberdefs() |
| 210 | |
| 211 | title = property(lambda self: self.data()['title']) |
| 212 | |
| 213 | |
| 214 | Base.mem_classes.append(DoxyGroup) |
| 215 | |
| 216 | |
| 217 | class DoxyFriend(DoxyMember): |
| 218 | |
| 219 | __module__ = "gnuradio.utils.doxyxml" |
| 220 | |
| 221 | kind = 'friend' |
| 222 | |
| 223 | Base.mem_classes.append(DoxyFriend) |
| 224 | |
| 225 | |
| 226 | class DoxyOther(Base): |
| 227 | |
| 228 | __module__ = "gnuradio.utils.doxyxml" |
| 229 | |
| 230 | kinds = set(['variable', 'struct', 'union', 'define', 'typedef', 'enum', 'dir', 'page']) |
| 231 | |
| 232 | @classmethod |
| 233 | def can_parse(cls, obj): |
| 234 | return obj.kind in cls.kinds |
| 235 | |
| 236 | Base.mem_classes.append(DoxyOther) |
| 237 | |