;;; dump-package.mhtml -*- Meta-HTML -*- code for debugging packages.
;;;
;;; Copyright (c) 1995 Brian J. Fox
;;; Author: Brian J. Fox (bfox@ai.mit.edu) Aug 1995.
;;;
;;; Usage: <dump-package package-name>
;;; Dump the contents of the given package out.
;;;
<defsubst dump-package pack package=local>
  <set-var vars[]=<package-vars <get-var pack>>>
  <p>
  <h3>Dump of package: <b><get-var pack></b></h3>
  <ul>
    <set-var i=0>
    <font size=-1>
    <while <get-var vars[i]>>
      <set-var name=<get-var vars[i]>>
      <li><subst-in-string <get-var name> <get-var pack>:: action=delete>:
      <set-var info[]=<symbol-info <get-var-once name>> size=<get-var info[1]>>
      <if <gt size 1>
	  <prog
	    <ol>
	      <set-var j=0>
	      <while <lt j size>>
	        <set-var value=<get-var-once <get-var-once name>[j]>>
		<subst-in-var value "&" "&amp;" "<" "&lt;" ">" "&gt;">
		<li><get-var value>
		<increment j>
	      </while>
	    </ol>>
	<prog
	  <set-var value=<get-var-once <get-var-once name>>>
	  <subst-in-var value "&" "&amp;" "<" "&lt;" ">" "&gt;">
	  <get-var value>>>
      <increment i>
    </while>
    </font>
  </ul>
</defsubst>

;;;
;;; Usage: <dump-all-packages>
;;; Calls dump-package on every defined package.
;;;
<defsubst dump-all-packages whitespace=delete>
  <package-delete dap>
  <set-var dap::packages[]=<package-names> dap::i=0>
  <in-package dap>
    <while <get-var packages[i]>>
      <dump-package <get-var dap::packages[dap::i]>>
      <br>
      <increment i>
    </while>
  </in-package>
  <package-delete dap>
</defsubst>

