;;; HyperSpec handling ;;; ;;; Copyright (C) 1999-2002 by Sam Steingold ;;; This is Free Software, covered by the GNU GPL (v2) ;;; See http://www.gnu.org/copyleft/gpl.html ;;; ;;; $Id: clhs.lisp,v 3.1 2002/04/21 20:07:37 sds Exp $ ;;; $Source: /cvsroot/clocc/clocc/src/cllib/clhs.lisp,v $ (eval-when (compile load eval) (require :cllib-base (translate-logical-pathname "clocc:src;cllib;base")) ;; `index-t' (require :cllib-withtype (translate-logical-pathname "cllib:withtype")) ;; `string-beg-with', `substitute-subseq' (require :cllib-string (translate-logical-pathname "cllib:string")) ;; `skip-search' (require :cllib-fileio (translate-logical-pathname "cllib:fileio")) ;; `with-timing' (require :cllib-log (translate-logical-pathname "cllib:log")) ;; `html-translate-specials' (require :cllib-html (translate-logical-pathname "cllib:html"))) (in-package :cllib) (export '(*clhs-root* *clhs-hashtable* clhs-doc clhs-write-entities)) #+nil (setq gtki::*gtkd-executable* "/usr/src/clisp/cl-gtk/bin/gtkd") ;;; ;;; ;;; (defcustom *clhs-root* url (url "http://www.lisp.org/HyperSpec/") "The root of the HyperSpec tree.") (defcustom *clhs-root-local* pathname (parse-namestring "/usr/share/doc/HyperSpec/") "The root of the local HyperSpec tree.") (defun clhs-snarf-examples (&key (root *clhs-root-local*) (out *standard-output*)) "Get the examples from the HyperSpec." (declare (pathname root) (stream out)) (format t " *** processing `~a'~%" root) (dolist (fl (directory (merge-pathnames "*.html" root))) (with-open-file (ff fl) (unless (or (null (skip-search ff "
Examples:
")) (null (skip-search ff "
"))) (format out " +++ `~a'~%" fl) (do ((st (read-line ff nil nil) (read-line ff nil nil))) ((or (null st) (string= st ""))) (princ (html-translate-specials st) out) (terpri out))))) (dolist (dir (directory (merge-pathnames "*/" root))) (clhs-snarf-examples :root dir :out out))) (defstruct clhs-version (name (required-argument)) (sym-tab (required-argument) :type string) ; file in Data/ symbol->file (any (required-argument) :type string) ; "any" file prefix: choice (fun (required-argument) :type list) ; FUNCTION prefixes (mac (required-argument) :type list) ; MACRO prefixes (spe (required-argument) :type list) ; SPECIAL-OPERATOR & SYMBOL prefixes (typ (required-argument) :type list) ; TYPE prefixes (var (required-argument) :type list) ; VARIABLE prefixes (dec (required-argument) :type list) ; DECLARE prefixes (res (required-argument) :type list) ; RESTART prefixes (glo (required-argument) :type list) ; GLOSSARY prefixes (doc (required-argument) :type string)) ; file name for DOCUMENTATION (defcustom *clhs-version-table* list (list (make-clhs-version :name :long :sym-tab "Symbol-Table.text" :any "any" :doc "stagenfun_doc_umentationcp.html" :fun '("acc" "fun" "locfun" "stagenfun") :spe '("sym" "spefor" "speope") :mac '("locmac" "mac") :typ '("cla" "contyp" "syscla" "typ" "typspe") :var '( "convar" "var") :dec '("dec") :res '("res") :glo '("glo")) (make-clhs-version :name :short :sym-tab "Map_Sym.txt" :any "a" :doc "f_docume.htm" :fun '("f") :mac '("m") :spe '( "s") :typ '("t" "e") :var '("v") :dec '("d") :res '("r") :glo '("26"))) "*The list of known CLHS versions.") (defparameter *clhs-alist* nil) (defparameter *clhs-version* nil) (defun clhs-read-map (map root old-path ver err) (declare (stream map)) (loop :with rec :for sym = (read-line map nil nil) :for file = (read-line map nil nil) :while (and sym file) :do (setq rec (list sym (subseq file #.(length "../Body/")))) :collect rec :when (string-beg-with (clhs-version-any ver) (second rec)) :do ; get all the options for the symbol (setf (url-path root) (concatenate 'string old-path "Body/" (second rec))) (mesg :log err "expanding the choices for ~s" (first rec)) (with-open-url (any root :err err) (case (url-prot root) ((:http :www) (flush-http any))) (loop :for line = (read-line any) :until (string-beg-with "Please select which reference to" line)) (read-line any) ; skip