# docs.icn -- generate documentation index web page
# 20-oct-97/gmt
# 17-jul-20/gmt
#
# reads:
# docs.dat data (see below)
# docs.head boilerplate header
# docs.tail boilerplate tailer
#
# writes:
# HTML on standard output
#
# data format:
# one entry per line: file basename, then descriptive text
# lines beginning with $ are passed through after stripping $
$define DESTDIR "../../docs" # ultimate home of output file
# the following are relative to DESTDIR
$define HTMDIR "." # directory for HTML files
$define INLDIR "../inl" # special handling for inlxx.htm references
$define PDFDIR "../ftp/doc" # directory for PDF files
$define TXTDIR "../ftp/doc" # directory for text files
procedure main()
local f1, f2, f3, line
f1 := open("docs.head") | stop("can't open docs.head")
f2 := open("docs.dat") | stop("can't open docs.dat")
f3 := open("docs.tail") | stop("can't open docs.tail")
chdir(DESTDIR) | stop("can't chdir to ", DESTDIR)
write("")
write()
while write(read(f1))
write("
")
while line := trim(read(f2)) do
if line ? ="$" then
write("| ", line[2:0], " |
")
else if *line > 0 then
doc(line) | write(&errout, "bad line: ", line)
write("
")
while write(read(f3))
end
procedure doc(line)
local fbase, text, refs, inl
line ? {
fbase := tab(upto(' \t')) | fail
tab(many(' \t'))
text := tab(0)
}
if *fbase = 0 | *text = 0 then fail
refs := []
put(refs, check(fbase, "htm", "HTML", HTMDIR))
put(refs, check(fbase, "pdf", "PDF", PDFDIR))
put(refs, check(fbase, "txt", "Text", TXTDIR))
if *refs = 0 then {
write(&errout, "not found: ", line)
return
}
writes("| (")
while *refs > 1 do
write(get(refs), ",")
write(get(refs),") | | ")
write("", text, " | ")
return
end
procedure check(fbase, extn, label, dir)
local fname
if (extn == "htm") & (fbase ? (="inl" & tab(many(&digits)) & pos(0))) then
fname := INLDIR || "/" || fbase || "/" || fbase || "." || extn
else if dir == "." then
fname := fbase || "." || extn
else
fname := dir || "/" || fbase || "." || extn
if close(open(fname)) then {
return "" || label || ""
}
end