;;; make-printable.mhtml: -*- Meta-HTML -*- Make a printed version of the
;;; manual.

;;;  Copyright (c) 1996 Brian J. Fox
;;;  Author: Brian J. Fox (bfox@ai.mit.edu) Wed Aug 14 18:39:54 1996.
<set-var title="Make Printable" footer-already-included=true printing=true>
<include header.mhtml>
<include texinfo.mhtml>
SYSTEM:ERRORS:??<SYSTEM-ERROR-OUTPUT>??

<defsubst write-output>
  <subst-in-var %1 "&amp;" "&" "&lt;" "<" "&gt;" ">" "\n[ \t\r\n]*\n" "\n\n">
  <stream-put %0 <get-var-once %1>>
</defsubst>

<defvar output-stream /tmp/metahtml.texi>

<with-open-stream s <get-var output-stream> type=file mode=write-create>
  <texinfo-write-header
   stream=<get-var default::s>
   filename=metahtml.info
   title="The Meta-HTML Reference Manual"
   author[0]="Brian J. Fox, Universal Access Inc."
   description = <prog
		   This document describes the Meta-HTML Programming Language,
		   a language specifically designed for writing applications
		   for the World Wide Web.>

   draft=""
   version=1.2>
  <stream-put s <include manual-prologue.texi verbatim>>

  <set-var output=<concat "\n@node The Purpose of Meta-HTML"
			  "\n@section The Purpose of Meta-HTML"
			  "\n\n"
			  <include purpose.mhtml>>>
  <write-output s output>
  <set-var output=<concat "\n@node Implementation Design"
			  "\n@section Implementation Design"
			  "\n\n"
			  <include implementation.mhtml>>>
  <write-output s output>
  <set-var output=<concat "\n@node Language Syntax"
			  "\n@section Language Syntax"
			  "\n\n"
			  <include syntax.mhtml>>>
  <write-output s output>

  <stream-put s <concat "\n@node Essential Language Features"
			"\n@chapter Essential Language Features\n">>

  <set-var output=<texinfo-format-section "Variables">>
  <write-output s output>
  <set-var output=<texinfo-format-section "Arrays">>
  <write-output s output>
  <set-var output=<texinfo-format-section "Packages">>
  <write-output s output>
  <set-var output=<texinfo-format-section "Flow Control">>
  <write-output s output>
  <set-var output=<texinfo-format-section "Language Operators"
					  "Convenience Primitives">>
  <write-output s output>

  <stream-put s <concat "\n@node Strings and Numbers"
			"\n@chapter Strings and Numbers\n">>
  <set-var output=<texinfo-format-section "String Operators">>
  <write-output s output>
  <set-var output=<texinfo-format-section "Arithmetic Operators">>
  <write-output s output>
  <set-var output=<texinfo-format-section "Relational Operators">>
  <write-output s output>

  <stream-put s <concat "\n@node Input and Output"
			"\n@chapter Input and Output\n">>
  <set-var output=<texinfo-format-section "File Operators">>
  <write-output s output>
  <set-var output=<texinfo-format-section "Stream Operators">>
  <write-output s output>

  <stream-put s <concat "\n@node Defining New Tags"
			"\n@chapter Defining New Tags\n">>
  <set-var output=<texinfo-format-section "Macro Commands">>
  <write-output s output>

  <stream-put s <concat "\n@node Managing the Page"
			"\n@chapter Managing the Page\n">>
  <set-var output=<texinfo-format-section "Page Operators">>
  <write-output s output>
  <set-var output=<texinfo-format-section "Page Variables">>
  <write-output s output>

  ;;; Get all of the page variable references.
  <with-open-database db <metahtml::function-db> mode=read>
    <database-query db
      <and <string-eq <get-var-once funtype> variable>
	   <string-eq <get-var-once section> page-variables>>
      keys=vars>
    <set-var i=0>
    <sort vars>
    <while <get-var vars[i]>>
      <package-delete var>
      <set-var x=<database-load-record db <get-var vars[i]> package=var>>
      <subst-in-var var::short-desc "\r\n" "\n" "-->" "==&gt;">
      <subst-in-var var::long-desc "\r\n" "\n" "-->" "==&gt;">
      <subst-in-var var::long-desc "\\.blank" "">
      <set-var output=<concat "\n\n@defvr {@i{Page Variable}} {<get-var var::name>}"
			      "\n<get-var var::short-desc>\n"
			      "\n<get-var var::long-desc>\n"
			      "@end defvr\n">>
      <write-output s output>
      <increment i>
    </while>
  </with-open-database>

  <set-var output=<texinfo-format-section "Block Commands">>
  <write-output s output>

  <stream-put s <concat "\n@node Working with Sessions"
			"\n@chapter Working with Sessions\n">>
  <set-var output=<texinfo-format-section "Session Operators">>
  <write-output s output>

  <stream-put s <concat "\n@node Working with Databases"
			"\n@chapter Working with Databases\n">>
  <set-var output=<texinfo-format-section "Direct Dbm Access"
					  "Database Commands">>
  <write-output s output>
  <set-var output=<texinfo-format-section "Database Commands"
					  "GDBM Based Records">>
  <write-output s output>
  <set-var output=<texinfo-format-section "MSQL Database Extensions"
					  "MSQL Database Extensions">>
  <write-output s output>
  <set-var output=<texinfo-format-section "ODBC Database Operators"
					  "ODBC Database Extensions">>
  <write-output s output>

  <stream-put s <concat "\n@node Working with the Server"
			"\n@chapter Working with the Server\n">>
  <set-var output=<texinfo-format-section "Server Variables">>
  <write-output s output>

  ;;; Get all of the server variable references.
  <with-open-database db <metahtml::function-db> mode=read>
    <database-query db
      <and <string-eq <get-var-once funtype> variable>
	   <string-eq <get-var-once section> server-variables>>
      keys=vars>
    <set-var i=0>
    <sort vars>
    <while <get-var vars[i]>>
      <package-delete var>
      <set-var x=<database-load-record db <get-var vars[i]> package=var>>
      <subst-in-var var::short-desc "\r\n" "\n" "-->" "==&gt;">
      <subst-in-var var::long-desc "\r\n" "\n" "-->" "==&gt;">
      <set-var output=<concat "\n\n@defvr {@i{Server Variable}} {<get-var var::name>}"
			      "\n<get-var var::short-desc>\n"
			      "\n<get-var var::long-desc>\n"
			      "@end defvr\n">>
      <write-output s output>
      <increment i>
    </while>
  </with-open-database>


  <stream-put s <concat "\n@node Working with Modules"
			"\n@chapter Working with Modules\n">>
  <set-var output=<texinfo-format-section "Dynamic Modules">>
  <write-output s output>
  
  <stream-put s <concat "\n@node Installation Guide"
			"\n@chapter Installation Guide\n">>

  <set-var output=<concat "\n@node Installing the Server"
			  "\n@section Installing the Server"
			  "\n\n"
			  <include server-install.mhtml>>>
  <write-output s output>

  <set-var i=0 pages[]=<prog
			 Apache
			 Netscape
			 NSAPI
			 NCSA
			 CERN
			 PLEXUS>>
  <while <get-var pages[i]>>
    <set-var ipage=<include <downcase <get-var pages[i]>>.mhtml verbatim>>
    <subst-in-var ipage "@" "@@">
    <set-var output =
      <concat "\n@node Configuring the <get-var pages[i]> Server"
	      "\n@section Configuring the <get-var pages[i]> Server"
	      "\n\n"
	      <get-var ipage>>>
    <write-output s output>
    <increment i>
  </while>

  <stream-put s <concat "\n@node Defined Meta-HTML Variables"
			"\n@appendix Defined Meta-HTML Variables\n">>

  ;;; Get all of the variable references.
  <with-open-database db <metahtml::function-db> mode=read>
    <database-query db <string-eq <get-var-once funtype> variable> keys=vars>
    <set-var i=0>
    <sort vars>
    <while <get-var vars[i]>>
      <package-delete var>
      <set-var x=<database-load-record db <get-var vars[i]> package=var>>
      <subst-in-var var::short-desc "\r\n" "\n" "-->" "==&gt;">
      <subst-in-var var::long-desc "\r\n" "\n" "-->" "==&gt;">
      <set-var output=<concat "\n\n@defvr {@i{Variable}} {<get-var var::name>}"
			      "\n<get-var var::short-desc>\n"
			      "\n<get-var var::long-desc>\n"
			      "@end defvr\n">>
      <write-output s output>
      <increment i>
    </while>
  </with-open-database>

  <stream-put s <concat "\n@node Function Index"
			"\n@appendix Function Index"
			"\n@printindex fn"
			"\n"
			 "\n@node Variable Index"
			"\n@appendix Variable Index"
			"\n@printindex vr"
			"\n"
			"\n@node Contents"
			"\n@contents"
			"\n@bye">>
</with-open-stream>

Done.
<unset-var mhtml::cacheable>
