[New gfs-highlight script Stephane Popinet **20080610124955 Uses GNU source-highlight for syntax highlighting of simulation files. ] hunk ./configure.in 459 +doc/examples/gfs-highlight hunk ./debian/control.sh 18 -Recommends: gfsview-snapshot +Recommends: gfsview-snapshot, source-highlight hunk ./doc/examples/Makefile.am 27 - gfs2doc + gfs2doc gfs-highlight hunk ./doc/examples/Makefile.am 30 - gfs2doc gfsclasses.py + gfs2doc gfs-highlight gfs.lang hunk ./doc/examples/Makefile.am 34 -pkglib_DATA = gfs2tex.py gfsclasses.py +pkglib_DATA = gfs2tex.py +pkgdata_DATA = gfs.lang hunk ./doc/examples/Makefile.am 37 -gfsclasses.py: classes - $(srcdir)/classes > gfsclasses.py +gfs.lang: classes + $(srcdir)/classes > gfs.lang hunk ./doc/examples/Makefile.am 42 +gfs-highlight: gfs-highlight.in + hunk ./doc/examples/classes.c 1 +#include hunk ./doc/examples/classes.c 3 -#define WIKI "http://gfs.sf.net/wiki/index.php/" +#define WIKI "http\\://gfs.sf.net/wiki/index.php/" hunk ./doc/examples/classes.c 5 -static void key_value_pair (const char * key) +static void key_value_pair (const char * key, FILE * lang) hunk ./doc/examples/classes.c 7 - printf ("'%s' : '" WIKI "%s',\\\n", key, key); + static int first = 1; + if (first) { + fprintf (lang, "gfs_keyword = "); + first = 0; + } + else + fprintf (lang, ",\n"); + + /* keywords must start with Gfs */ + g_assert (strstr (key, "Gfs") == key); + fprintf (lang, " '(Gfs){0,1}%s'", &(key[3])); hunk ./doc/examples/classes.c 26 - printf ("klass = {\\\n"); - key_value_pair ("Define"); - key_value_pair ("GfsProjectionParams"); - key_value_pair ("GfsApproxProjectionParams"); + + printf ("# Language file for source-highlight\n" + "# Generated automatically by classes.c\n" + "\n" + "include \"cpp.lang\"\n" + "\n" + "comment start \"#\"\n" + "\n" + "redef preproc = \"C preprocessor command is not compatible with" + " the use of # as comment character in GTS\"\n" + "\n"); + key_value_pair ("GfsDefine", stdout); + key_value_pair ("GfsProjectionParams", stdout); + key_value_pair ("GfsApproxProjectionParams", stdout); hunk ./doc/examples/classes.c 41 - key_value_pair ((*klass)->info.name); + key_value_pair ((*klass)->info.name, stdout); hunk ./doc/examples/classes.c 44 - printf ("}\n"); addfile ./doc/examples/gfs-highlight hunk ./doc/examples/gfs-highlight 1 +#!/bin/sh + +wiki="http:\/\/gfs.sf.net\/wiki\/index.php" +title="Gerris simulation" +css="darcs.css" + +path="/usr/local/share/gerris" + +usage() +{ + cat < output.html + +Syntax highlighting/hypertext linking of Gerris simulation files. + +Options: + [--title=TITLE] sets the page title + [--css=FILE] sets the CSS stylesheet filename + [--help] displays this message and exits +EOF + exit $1 +} + +while test $# -gt 0; do + case "$1" in + -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + case $1 in + --title=*) + title=$optarg + ;; + --css=*) + css=$optarg + ;; + --help) + usage 0 1>&2 + ;; + *) + usage 0 1>&2 + ;; + esac + shift +done + +cat < + +$title + + + +EOF + +file=`mktemp gfs-highlight.XXXXXX` +ln -s -f $path/gfs.lang $file + +awk 'BEGIN{ infile=0 } { + if ($2 == "Generated" && $3 == "files:") { + infile = 1; + while ($1 == "#") getline; + print $0; + } else if (infile) + print $0; + }' | \ +source-highlight --lang-def=$file --out-format=html-css | \ +sed "s/\"gfs_keyword\">\(Gfs\)\{0,1\}\([a-zA-Z0-9_]*\)<\/span>/"gfs_keyword">\1\2<\/a><\/span>/g" + +rm -f $file + +cat < + +EOF addfile ./doc/examples/gfs-highlight.in hunk ./doc/examples/gfs-highlight.in 1 +#!/bin/sh + +wiki="http:\/\/gfs.sf.net\/wiki\/index.php" +title="Gerris simulation" +css="darcs.css" + +path="@prefix@/share/gerris" + +usage() +{ + cat < output.html + +Syntax highlighting/hypertext linking of Gerris simulation files. + +Options: + [--title=TITLE] sets the page title + [--css=FILE] sets the CSS stylesheet filename + [--help] displays this message and exits +EOF + exit $1 +} + +while test $# -gt 0; do + case "$1" in + -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + case $1 in + --title=*) + title=$optarg + ;; + --css=*) + css=$optarg + ;; + --help) + usage 0 1>&2 + ;; + *) + usage 0 1>&2 + ;; + esac + shift +done + +cat < + +$title + + + +EOF + +file=`mktemp gfs-highlight.XXXXXX` +ln -s -f $path/gfs.lang $file + +awk 'BEGIN{ infile=0 } { + if ($2 == "Generated" && $3 == "files:") { + infile = 1; + while ($1 == "#") getline; + print $0; + } else if (infile) + print $0; + }' | \ +source-highlight --lang-def=$file --out-format=html-css | \ +sed "s/\"gfs_keyword\">\(Gfs\)\{0,1\}\([a-zA-Z0-9_]*\)<\/span>/"gfs_keyword">\1\2<\/a><\/span>/g" + +rm -f $file + +cat < + +EOF hunk ./doc/examples/gfs2doc.in 11 -import gfsclasses hunk ./doc/examples/gfs2doc.in 22 - example.write(gfsclasses.klass) + example.write() hunk ./doc/examples/gfs2tex 8 -import gfsclasses hunk ./doc/examples/gfs2tex 18 - example.write(gfsclasses.klass,style="examples.css") + example.write(style="examples.css") hunk ./doc/examples/gfs2tex.py 98 - def write(self,dico,file=None,style=None): + def write(self,file=None,style=""): hunk ./doc/examples/gfs2tex.py 121 - self.colorize(dico,style) + self.colorize(style) hunk ./doc/examples/gfs2tex.py 123 - def colorize(self,dico,style=None): - file = open(self.path + "/" + self.name + ".gfs") - out = open(self.path + "/" + self.name + ".gfs.html", 'w') - path = "../" * (self.path.count("/") + 3) + "reference/" - out.write("\n" + self.name + ".gfs") - if style == None: - out.write('\n') - else: - out.write('\n') - infile = insthg = 0 - for line in file: - tab = "" - l = "" - first = 1 - comment = 0 - for c in line: - if c == " " and first: - tab += " " - else: - if first and c == "#": - comment = 1 - first = 0 - if c == '<': - l += "<" - elif c == '>': - l += ">" - elif c == '&': - l += "&" - else: - l += c - if comment: - if infile: - record = line.split() - if insthg or len(record) > 1: - out.write('
') - out.write(tab) - out.write(l) - out.write('
') - insthg = 1 - else: - record = line.split() - if len(record) > 2 and record[1] == "Generated" and record[2] == "files:": - infile = 1 - insthg = 0 - else: - out.write(tab) - record = l.split() - for r in record: - key = None - if dico.has_key(r): - key = r - elif dico.has_key("Gfs" + r): - key = "Gfs" + r - if key != None: - out.write("
" + r + " ") - else: - out.write(r + " ") - out.write("
\n") - out.write("
\n\n") + def colorize(self,style=""): + basename = self.path + "/" + self.name + if style != "": + style = " --css=" + ["../","../../"][self.path.count("/")] + style + os.system("gfs-highlight " + \ + "--title=" + self.name + ".gfs" + style + \ + " < " + basename + ".gfs > " + basename + ".gfs.html") hunk ./src/m4.awk 12 - if ($1 == "Define") { + if ($1 == "GfsDefine" || $1 == "Define") {