From 22ed11765884ef97b7346f0723ffc0e7fe540640 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Wed, 14 Sep 2005 20:51:47 +0000 Subject: [PATCH] common/: a simple py script to generate valid xml from a C example probably also need to strip an MIT license when we... 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 | 34 ++++++++++++++++++++++++++++++++++ gtk-doc-plugins.mak | 2 ++ 2 files changed, 36 insertions(+) create mode 100644 c-to-xml.py diff --git a/c-to-xml.py b/c-to-xml.py new file mode 100644 index 0000000..8448fd2 --- /dev/null +++ b/c-to-xml.py @@ -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 '' + print '' + print + print '' + + # print content + print saxutils.escape(content).encode('UTF-8') + print '' + +main() diff --git a/gtk-doc-plugins.mak b/gtk-doc-plugins.mak index 21c1530..67d671d 100644 --- a/gtk-doc-plugins.mak +++ b/gtk-doc-plugins.mak @@ -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) \ -- 2.7.4