From f98c840f6a2e505daa220f61ed2b0cc669a6afb2 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sat, 14 Sep 2002 13:17:10 +0000 Subject: [PATCH] adding automatic example extraction from manual Original commit message from CVS: adding automatic example extraction from manual --- examples/Makefile.am | 4 +-- examples/manual/Makefile.am | 23 ++++++++++++++++ examples/manual/extract.pl | 52 +++++++++++++++++++++++++++++++++++ tests/old/examples/Makefile.am | 4 +-- tests/old/examples/manual/Makefile.am | 23 ++++++++++++++++ tests/old/examples/manual/extract.pl | 52 +++++++++++++++++++++++++++++++++++ 6 files changed, 154 insertions(+), 4 deletions(-) create mode 100644 examples/manual/Makefile.am create mode 100755 examples/manual/extract.pl create mode 100644 tests/old/examples/manual/Makefile.am create mode 100755 tests/old/examples/manual/extract.pl diff --git a/examples/Makefile.am b/examples/Makefile.am index b834077..8587133 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -7,10 +7,10 @@ endif SUBDIRS = autoplug $(GST_LOADSAVE_DIRS) \ helloworld helloworld2 \ queue queue2 queue3 queue4 \ - launch thread plugins mixer cutter pingpong + launch thread plugins mixer cutter pingpong manual DIST_SUBDIRS = autoplug \ helloworld helloworld2 \ queue queue2 queue3 queue4 \ - launch thread xml plugins typefind mixer cutter pingpong + launch thread xml plugins typefind mixer cutter pingpong manual diff --git a/examples/manual/Makefile.am b/examples/manual/Makefile.am new file mode 100644 index 0000000..856071c --- /dev/null +++ b/examples/manual/Makefile.am @@ -0,0 +1,23 @@ +if HAVE_LIBGNOMEUI +GNOME=gnome +else +GNOME= +endif + +EXAMPLES = $(GNOME) xml +noinst_PROGRAMS = $(EXAMPLES) + +LDADD = $(GST_LIBS) +INCLUDES = $(GST_CFLAGS) + +gnome_LDADD = $(GST_LIBS) $(LIBGNOMEUI_LIBS) +gnome_CFLAGS = $(GST_CFLAGS) $(LIBGNOMEUI_CFLAGS) + +# for some reason specifying %.c runs us into trouble when running make +# clean, it starts looking for things like mostlyclean-am.c, please +# help me fix that so we don't need to specify all sources here +# also, it's a bit irritating that right now a change in any xml file +# triggers a rebuild of all examples +#%.c: +gnome.c xml.c: $(top_srcdir)/docs/manual/*.xml + $(srcdir)/extract.pl $@ $(top_srcdir)/docs/manual/*.xml diff --git a/examples/manual/extract.pl b/examples/manual/extract.pl new file mode 100755 index 0000000..7f6839a --- /dev/null +++ b/examples/manual/extract.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl + +# extract code fragments from xml program listings +# first argument: source code file to find +# second argument: xml files to extract code from + +# main + +# decodes xml by translating & < > back to what they should be +sub +xml_decode ($) +{ + my $input = shift; + + $input =~ s/\&/&/g; + $input =~ s/<//g; + + return $input; +} + +# main +my $output = shift @ARGV; + +foreach $file (@ARGV) +{ + open FILE, $file or die "Cannot open file $file"; + + while ($line = ) + { + if ($line =~ /\/\* example-begin $output \*\//) + { + print "Extracting $output from $file\n"; + open OUTPUT, ">$output"; + print OUTPUT xml_decode ($line); + my $example = 1; + while (($line = ) && $example) + { + if ($line =~ /\/\* example-end/) + { + print OUTPUT xml_decode ($line); + close OUTPUT; + $example = 0; + } + else + { + print OUTPUT xml_decode ($line); + } + } + } + } +} diff --git a/tests/old/examples/Makefile.am b/tests/old/examples/Makefile.am index b834077..8587133 100644 --- a/tests/old/examples/Makefile.am +++ b/tests/old/examples/Makefile.am @@ -7,10 +7,10 @@ endif SUBDIRS = autoplug $(GST_LOADSAVE_DIRS) \ helloworld helloworld2 \ queue queue2 queue3 queue4 \ - launch thread plugins mixer cutter pingpong + launch thread plugins mixer cutter pingpong manual DIST_SUBDIRS = autoplug \ helloworld helloworld2 \ queue queue2 queue3 queue4 \ - launch thread xml plugins typefind mixer cutter pingpong + launch thread xml plugins typefind mixer cutter pingpong manual diff --git a/tests/old/examples/manual/Makefile.am b/tests/old/examples/manual/Makefile.am new file mode 100644 index 0000000..856071c --- /dev/null +++ b/tests/old/examples/manual/Makefile.am @@ -0,0 +1,23 @@ +if HAVE_LIBGNOMEUI +GNOME=gnome +else +GNOME= +endif + +EXAMPLES = $(GNOME) xml +noinst_PROGRAMS = $(EXAMPLES) + +LDADD = $(GST_LIBS) +INCLUDES = $(GST_CFLAGS) + +gnome_LDADD = $(GST_LIBS) $(LIBGNOMEUI_LIBS) +gnome_CFLAGS = $(GST_CFLAGS) $(LIBGNOMEUI_CFLAGS) + +# for some reason specifying %.c runs us into trouble when running make +# clean, it starts looking for things like mostlyclean-am.c, please +# help me fix that so we don't need to specify all sources here +# also, it's a bit irritating that right now a change in any xml file +# triggers a rebuild of all examples +#%.c: +gnome.c xml.c: $(top_srcdir)/docs/manual/*.xml + $(srcdir)/extract.pl $@ $(top_srcdir)/docs/manual/*.xml diff --git a/tests/old/examples/manual/extract.pl b/tests/old/examples/manual/extract.pl new file mode 100755 index 0000000..7f6839a --- /dev/null +++ b/tests/old/examples/manual/extract.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl + +# extract code fragments from xml program listings +# first argument: source code file to find +# second argument: xml files to extract code from + +# main + +# decodes xml by translating & < > back to what they should be +sub +xml_decode ($) +{ + my $input = shift; + + $input =~ s/\&/&/g; + $input =~ s/<//g; + + return $input; +} + +# main +my $output = shift @ARGV; + +foreach $file (@ARGV) +{ + open FILE, $file or die "Cannot open file $file"; + + while ($line = ) + { + if ($line =~ /\/\* example-begin $output \*\//) + { + print "Extracting $output from $file\n"; + open OUTPUT, ">$output"; + print OUTPUT xml_decode ($line); + my $example = 1; + while (($line = ) && $example) + { + if ($line =~ /\/\* example-end/) + { + print OUTPUT xml_decode ($line); + close OUTPUT; + $example = 0; + } + else + { + print OUTPUT xml_decode ($line); + } + } + } + } +} -- 2.7.4