Commit 0ff28d72 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

examples: build examples that are included in the docs

We build the examples that are included in the 'getting started'
chapter of the docs to prevent them from bitrotting. Also
remove the awk scripts used to extract the old examples from
the tutorial, since the tutorial is gone. I'm still leaving
the examples themeselves in place, for possible inclusion in
'getting started' later on.
parent ef7fddac
......@@ -1640,6 +1640,7 @@ po-properties/Makefile.in
demos/Makefile
demos/gtk-demo/Makefile
demos/gtk-demo/geninclude.pl
examples/Makefile
tests/Makefile
docs/Makefile
docs/reference/Makefile
......
SUBDIRS = arrow \
DIST_SUBDIRS = arrow \
aspectframe \
base \
buttonbox \
......@@ -28,18 +28,20 @@ SUBDIRS = arrow \
spinbutton \
statusbar \
table \
tictactoe \
wheelbarrow
tictactoe
# wheelbarrow
all:
list='$(SUBDIRS)'; \
for subdir in $$list; do \
(cd $$subdir && $(MAKE)); \
done
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/gdk \
-DGDK_DISABLE_DEPRECATED \
-DGTK_DISABLE_DEPRECATED \
$(GTK_DEBUG_FLAGS) \
$(GTK_DEP_CFLAGS)
clean:
list='$(SUBDIRS)'; \
for subdir in $$list; do \
(cd $$subdir && $(MAKE) clean); \
done
LDADD = \
$(top_builddir)/gdk/$(gdktargetlib) \
$(top_builddir)/gtk/$(gtktargetlib) \
$(GTK_DEP_LIBS)
bin_PROGRAMS = hello-world window-default
GTK Example Code - Tony Gale <gale@gtk.org> 980623
--------------------------------------------------
I have written an awk script to automatically extract the code
examples from the GTK Tutorial (in sgml), so they only have to be
changed in one place.
It's called 'extract.awk', and there is a shell wrapper to invoke
it called 'extract.sh'
It takes the following switches:
-c : Just do checking rather than output files
-f <filename> : Extract a specific file
-d : Extract file(s) to current directory
Without the -d switch, the code will be placed in the appropriate
sub-directory. Those sub-directories will be created if they do not
exist.
Without the -f switch, all code examples will be extracted.
The shell wrapper assumes that the GTK Tutorial is in the
file "../docs/gtk_tut.sgml"
It works by looking for sections of text in the tutorial surrounded
by, for example:
/* example-start helloworld helloworld.c */
and
/* example-end */
Where "helloworld" is the directory into which the file will be
placed (which can also be a directory spec like hello/hello1), and
"helloworld.c" is the file name for the code.
So, the code between these lines would be extracted to the file
helloworld/helloworld.c
It also handles replacing the sgml tag '&amp;' with '&'
# extract - extract C source files from GTK Tutorial
# Copyright (C) Tony Gale 1998
# Contact: gale@gtk.org
#
# Command Switches:
# -c : Just do checking rather than output files
# -f <filename> : Extract a specific file
# -d : Extract files to current directory
# -v : Verbose
BEGIN {in_example=0; check=0; spec_example=""; do_output=0; flatten=0; verbose=0;
for (i=0 ; i < ARGC ; i++) {
if ( ARGV[i] == "-c" ) {
check = 1;
ARGV[i]="";
} else if ( ARGV[i] == "-f" ) {
spec_example=ARGV[i+1];
ARGV[i]="";
ARGV[i+1]="";
if ( length(spec_example) == 0 ) {
print "usage: -f <filename>";
exit;
}
} else if ( ARGV[i] == "-d" ) {
flatten = 1;
ARGV[i]="";
} else if ( ARGV[i] == "-v" ) {
verbose = 1;
ARGV[i] = "";
}
}
}
$2 == "example-end" && in_example == 0 { printf("\nERROR: multiple ends at line %d\n", NR) > "/dev/stderr";
exit}
$2 == "example-end" { in_example=0; do_output=0 }
in_example==1 && check==0 && do_output==1 { gsub(/&amp;/, "\\&", $0);
gsub(/&lt;/, "<", $0);
gsub(/&gt;/, ">", $0);
print $0 >file_name }
$2 == "example-start" && in_example == 1 { printf("\nERROR: nested example at line %d\n", NR) > "/dev/stderr";
exit}
$2 == "example-start" { in_example=1 }
$2 == "example-start" && check == 0 \
{ if ( (spec_example == "") || (spec_example == $4) ) {
if ( flatten == 0 ) {
if (file_name != "")
close(file_name);
file_name = sprintf("%s/%s",$3, $4);
command = sprintf("mkdir -p %s", $3);
system(command);
} else {
file_name = $4;
}
if (verbose == 1)
printf("%s\n", file_name);
do_output=1;
}
}
END {}
#! /bin/sh
# extract - extract C source files from GTK Tutorial
# Copyright (C) Tony Gale 1998
# Contact: gale@gtk.org
#
# extract.awk command Switches:
# -c : Just do checking rather than output files
# -f <filename> : Extract a specific file
# -d : Extract files to current directory
TUTORIAL=../docs/tutorial/gtk-tut.sgml
if [ -x /usr/bin/gawk ]; then
gawk -f extract.awk $TUTORIAL $1 $2 $3 $4 $5
else
if [ -x /usr/bin/nawk ]; then
nawk -f extract.awk $TUTORIAL $1 $2 $3 $4 $5
else
if [ -x /usr/bin/awk ]; then
awk -f extract.awk $TUTORIAL $1 $2 $3 $4 $5
else
if [ -x /bin/awk ]; then
awk -f extract.awk $TUTORIAL $1 $2 $3 $4 $5
else
echo "Can't find awk... please edit extract.sh by hand"
fi
fi
fi
fi
find . -name CVS -prune -o \
-not \( -type d -o -name Makefile.am -o -name find-examples.sh \) -print |
sed 's%\./\(.*\)% examples/\1 \\%'
echo " examples/find-examples.sh"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment