]>
git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/doxymlparser.py
4 License: wxWidgets License
8 Takes the output of Doxygen XML and parses it to retrieve metadata about the classes and methods.
10 To create the Doxygen XML files, from the wxWidgets/docs/doxygen directory, do:
14 To see the results from parsing a particular class, do:
16 python doxymlparser.py --report out/xml/classwx_<whatever>.xml
26 from xml
.dom
import minidom
29 "report" : (False, "Print out the classes and methods found by this script."),
32 parser
= optparse
.OptionParser(usage
="usage: %prog [options] <doxyml files to parse>\n" + __description__
, version
="%prog 1.0")
34 for opt
in option_dict
:
35 default
= option_dict
[opt
][0]
38 if type(default
) == types
.BooleanType
:
40 parser
.add_option("--" + opt
, default
=default
, action
=action
, dest
=opt
, help=option_dict
[opt
][1])
42 options
, arguments
= parser
.parse_args()
44 class ClassDefinition
:
48 self
.brief_description
= ""
49 self
.detailed_description
= ""
63 """ % (self
.name
, string
.join(self
.bases
, ", "), self
.includes
, self
.brief_description
, self
.detailed_description
)
64 str_repr
+= "Methods:\n"
66 for method
in self
.methods
:
67 str_repr
+= str(method
)
71 class MethodDefinition
:
78 self
.brief_description
= ""
79 self
.detailed_description
= ""
92 """ % (self
.name
, self
.return_type
, self
.params
, self
.definition
+ self
.argsstring
, self
.brief_description
, self
.detailed_description
)
95 def getTextValue(node
, recursive
=False):
97 for child
in node
.childNodes
:
98 if child
.nodeType
== child
.ELEMENT_NODE
and child
.nodeName
== "ref":
99 text
+= getTextValue(child
)
100 if child
.nodeType
== child
.TEXT_NODE
:
101 text
+= child
.nodeValue
.strip()
105 def doxyMLToText(node
):
112 def parse(self
, filename
):
113 self
.xmldoc
= minidom
.parse(filename
).documentElement
114 for node
in self
.xmldoc
.getElementsByTagName("compounddef"):
115 self
.classes
.append(self
.parse_class(node
))
117 def parse_class(self
, class_node
):
118 new_class
= ClassDefinition()
119 for node
in class_node
.childNodes
:
120 if node
.nodeName
== "compoundname":
121 new_class
.name
= getTextValue(node
)
122 print "Parsing class %s" % new_class
.name
123 elif node
.nodeName
== "basecompoundref":
124 new_class
.bases
.append(getTextValue(node
))
125 elif node
.nodeName
== "briefdescription":
126 # let the post-processor determ
127 new_class
.brief_description
= node
.toxml()
128 elif node
.nodeName
== "detaileddescription":
129 new_class
.detailed_description
= node
.toxml()
131 self
.parse_methods(new_class
, class_node
)
134 def parse_methods(self
, new_class
, root
):
135 for method
in root
.getElementsByTagName("memberdef"):
136 new_method
= MethodDefinition()
137 for node
in method
.childNodes
:
138 if node
.nodeName
== "name":
139 new_method
.name
= getTextValue(node
)
140 elif node
.nodeName
== "type":
141 new_method
.return_type
= getTextValue(node
)
142 elif node
.nodeName
== "definition":
143 new_method
.definition
= getTextValue(node
)
144 elif node
.nodeName
== "argsstring":
145 new_method
.argsstring
= getTextValue(node
)
146 elif node
.nodeName
== "param":
148 for child
in node
.childNodes
:
149 if child
.nodeType
== child
.ELEMENT_NODE
:
150 param
[child
.nodeName
] = getTextValue(child
)
151 new_method
.params
.append(param
)
152 print "Adding %s" % (new_method
.name
+ new_method
.argsstring
)
153 new_class
.methods
.append(new_method
)
155 if __name__
== "__main__":
156 if len(arguments
) < 1:
160 doxyparse
= DoxyMLParser()
161 for arg
in arguments
:
165 for aclass
in doxyparse
.classes
: