Commit 4ffee69f 4ffee69f8de513f0db0e777ed195476c74c59090 by Sergey Poznyakoff

Fix docfile generation

1 parent 3bd03f85
#! /bin/sh
# Copyright (C) 2002 Sergey Poznyakoff
# Copyright (C) 2002, 2006 Sergey Poznyakoff
#
# This is a snarfer for guile version 1.6
#
......@@ -33,7 +33,7 @@ do
-d) DOCFILE=1; shift;;
*) break;;
esac
done
done
INFILE=$1; shift
......@@ -50,15 +50,8 @@ snarf_x() {
snarf_doc() {
$CPP -DSCM_MAGIC_SNARF_DOCS "$@" > ${temp}
cpp_exit=$?
$AWK '
NF<2 {next}
state == 0 && /\^\^ {/ { state = 1; print; next }
state == 0 && /\^\^/ { print }
state == 1 && /\^\^ }/ { state = 0; print; next }
state == 1 { print }
state == 0 { next }' $temp |\
tr -d '\n' | tr '^' '\n' |\
$AWK -f $BASEDIR/guile-doc-snarf.awk > $OUTFILE
sed -n '/\^^ *{.*^^ *}/{s,\^^,\n,pg}' $temp | \
$AWK -f $BASEDIR/guile-doc-snarf.awk
}
case "$DOCFILE" in
......
# Copyright (C) 2002 Sergey Poznyakoff
# Copyright (C) 2002, 2006 Sergey Poznyakoff
#
# This is a snarfer for guile version 1.6
#
......@@ -27,11 +27,18 @@ function flush() {
if (arg_req + arg_opt + arg_var != numargs)
error(cname " incorrectly defined as taking " numargs " arguments")
print "\f" cname
print "\f" fname
print "@c snarfed from " loc_source ":" loc_line
printf "@deffn {Scheme procedure} %s", cname
for (i = 1; i <= numargs; i++)
printf(" %s", arglist[i])
printf "@deffn {Scheme procedure} %s", fname
# All scheme primitives follow the same naming style:
# SCM argument names are in upper case.
# So, we convert them to lower case for @deffn line and
# replace their occurrences in the docstring by appropriate
# @var{} commands.
for (i = 1; i <= numargs; i++) {
printf(" %s", tolower(arglist[i]))
gsub(arglist[i], "@var{" tolower(arglist[i]) "}", docstring)
}
print ""
print docstring
print "@end deffn\n"
......@@ -46,13 +53,13 @@ function error(s) {
exit 1
}
state == 0 && /{/ {
state == 0 && $1 == "{" {
flush()
cname = $3
next
}
state == 0 && /fname/ { fname = $2; next }
state == 0 && /fname/ { fname = substr($2,2,length($2)-2); next }
state == 0 && /type/ { type = $2; next }
state == 0 && /location/ { loc_source = $2; loc_line = $3 }
state == 0 && /arglist/ {
......@@ -70,13 +77,16 @@ state == 0 && /arglist/ {
n = b[2]
}
if (m > 2 || t != "SCM")
error(cname ": wrong argument type for arg " i " " t)
error(cname ": wrong argument type for arg " i " " t)
arglist[i] = n
}
}
state == 0 && /argsig/ { arg_req = $2; arg_opt = $3; arg_var = $4 }
state == 0 && /.*\"/ {
# Concatenate strings. A very simplified version, but
# works for us
gsub("\\\\n\" *\"", "\n")
gsub("\"\"", "")
gsub("\\\\n", "\n")
match($0,"\".*\"")
......