2 # vi:si:et:sw=4:sts=4:ts=4
5 examine all plugins and elements and output xml documentation for them
6 used as part of the plugin documentation build
16 ELEMENT_TEMPLATE = """<element>
18 <longname>%(longname)s</longname>
19 <class>%(class)s</class>
20 <description>%(description)s</description>
21 <author>%(author)s</author>
24 PLUGIN_TEMPLATE = """<plugin>
26 <description>%(description)s</description>
27 <filename>%(filename)s</filename>
28 <basename>%(basename)s</basename>
29 <version>%(version)s</version>
30 <license>%(license)s</license>
31 <package>%(package)s</package>
32 <origin>%(origin)s</origin>
42 line = "&".join(line.split("&"))
43 line = "<".join(line.split("<"))
44 line = ">".join(line.split(">"))
47 def get_offset(indent):
48 return " " * INDENT_SIZE * indent
50 def output_element_factory(elf, indent=0):
51 print "ELEMENT", elf.get_name()
53 'name': xmlencode(elf.get_name()),
54 'longname': xmlencode(elf.get_longname()),
55 'class': xmlencode(elf.get_klass()),
56 'description': xmlencode(elf.get_description()),
57 'author': xmlencode(elf.get_author()),
59 block = ELEMENT_TEMPLATE % d
61 offset = get_offset(indent)
62 return offset + ("\n" + offset).join(block.split("\n"))
65 def output_plugin(plugin, indent=0):
66 print "PLUGIN", plugin.get_name()
67 version = ".".join([str(i) for i in plugin.get_version()])
70 for feature in plugin.get_feature_list():
71 if isinstance(feature, gst.ElementFactory):
72 elements.append(output_element_factory(feature, indent + 2))
74 filename = plugin.get_filename()
77 basename = os.path.basename(basename)
79 'name': xmlencode(plugin.get_name()),
80 'description': xmlencode(plugin.get_description()),
84 'license': xmlencode(plugin.get_license()),
85 'package': xmlencode(plugin.get_package()),
86 'origin': xmlencode(plugin.get_origin()),
87 'elements': "\n".join(elements),
89 block = PLUGIN_TEMPLATE % d
91 offset = get_offset(indent)
92 return offset + ("\n" + offset).join(block.split("\n"))
98 all = gst.registry_pool_plugin_list()
100 filename = "plugin-%s.xml" % plugin.get_name()
101 handle = open(filename, "w")
102 handle.write(output_plugin(plugin))