common/: a simple py script to generate valid xml from a C example probably also...
authorThomas Vander Stichele <thomas@apestaart.org>
Wed, 14 Sep 2005 20:51:47 +0000 (20:51 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Wed, 14 Sep 2005 20:51:47 +0000 (20:51 +0000)
Original commit message from CVS:

* common/c-to-xml.py:
* common/gtk-doc-plugins.mak:
a simple py script to generate valid xml from a C example
probably also need to strip an MIT license when we decide
* docs/plugins/Makefile.am:
* gst/level/Makefile.am:
* gst/level/gstlevel.c: (gst_level_init):
* gst/level/level-example.c: (message_handler), (main):
add an example to level that will show up in the docs
* gst/rtp/TODO:
add a note for the future

c-to-xml.py [new file with mode: 0644]
gtk-doc-plugins.mak

diff --git a/c-to-xml.py b/c-to-xml.py
new file mode 100644 (file)
index 0000000..8448fd2
--- /dev/null
@@ -0,0 +1,34 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+"""
+Convert a C program to valid XML to be included in docbook
+"""
+
+import sys
+import os
+from xml.sax import saxutils
+
+def main():
+    if len(sys.argv) == 1:
+        sys.stderr.write("Please specify a source file to convert")
+        sys.exit(1)
+    source = sys.argv[1]
+
+    if not os.path.exists(source):
+        sys.stderr.write("%s does not exist.\n" % source)
+        sys.exit(1)
+
+    content = open(source, "r").read()
+
+    # print header
+    print '<?xml version="1.0"?>'
+    print '<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">'
+    print
+    print '<programlisting>'
+
+    # print content
+    print saxutils.escape(content).encode('UTF-8')
+    print '</programlisting>'
+        
+main()
index 21c1530..67d671d 100644 (file)
@@ -150,6 +150,8 @@ sgml-build.stamp: tmpl.stamp inspect.stamp $(CFILE_GLOB) $(top_srcdir)/common/pl
        @for a in $(srcdir)/inspect/*.xml; do \
             xsltproc --stringparam module $(MODULE) \
                $(top_srcdir)/common/plugins.xsl $$a > xml/`basename $$a`; done
+       @for f in $(EXAMPLE_CFILES); do \
+               $(PYTHON) $(top_srcdir)/common/c-to-xml.py $$f > xml/element-`basename $$f .c`.xml; done
        gtkdoc-mkdb \
                --module=$(DOC_MODULE) \
                --source-dir=$(DOC_SOURCE_DIR) \