# docpro.icn -- documentation processor for Jcon # # usage: docpro section-list header-1 header-2 # # The section-list file lists individual sections to be copied # both into the combined document and into individual pages. # # The header files are boilerplate for the combined document, # which is written to standard output. # #%#% TO DO: edit internal HTML refs $define JHOME "http://www.cs.arizona.edu/icon/jcon/" record section( fbase, # file basename ftag, # footer tag stitle, # section title wtitle # webpage title ) global sectlist # list of section records procedure main(args) local sfile, h1file, h2file, line, fbase, ftag, stitle, wtitle, s if *args ~= 3 then stop("usage: ", &progname, " sectlist head1 head2"); sfile := open(args[1]) | stop("cannot open ", args[1]) h1file := open(args[2]) | stop("cannot open ", args[2]) h2file := open(args[3]) | stop("cannot open ", args[3]) sectlist := [] while line := read(sfile) do line ? { tab(many(' \t')) if pos(0) | ="#" then next fbase := trim(tab(upto('/') + 1), ' \t/') | stop("bad input: ", line) tab(many(' \t')) ftag := trim(tab(upto('/') + 1), ' \t/') | stop("bad input: ", line) tab(many(' \t')) stitle := trim(tab(upto('/') + 1), ' \t/') | stop("bad input: ", line) tab(many(' \t')) wtitle := trim(tab(0),' \t') put(sectlist, section(fbase, ftag, stitle, wtitle)) } dontedit(&output) while write(read(h1file)) every s := !sectlist do { write("", s.stitle, "
") } while write(read(h2file)) every s := !sectlist do { wrsect(s.fbase, s.stitle) wrpage(s.fbase, s.wtitle) } write("\n") end # wrsect(fbase, title) -- copy section into combined document procedure wrsect(fbase, title) local f f := open(fbase || ".txt") | stop("cannot open ", fbase, ".txt") write("\n\n



\n\n

", title, "

\n") while write(read(f)) close(f) return end # wrpage(fbase, title) -- copy section into separate web page procedure wrpage(fbase, title) local f1, f2, s f1 := open(fbase || ".txt") | stop("cannot open ", fbase, ".txt") f2 := open(fbase || ".htm", "w") | stop("cannot create ", fbase, ".htm") dontedit(f2) write(f2, "") write(f2, "", title, "") write(f2, "") write(f2, "") write(f2, "

", title, "

") while write(f2, read(f1)) write(f2, "\n


") writes(f2, "index\n|") every s := !sectlist do { write(f2, "| ", s.ftag, "") } write(f2, "|| home\n") write(f2, "") write(f2, "") close(f2) return end procedure dontedit(f) write(f, repl("\n", 20)) write(f, "\n") write(f, repl("\n", 20)) return end