1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: File and directory functions for LML
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Aug 2002
10 ;;;; This file, part of LML, is Copyright (c) 2002 by Kevin M. Rosenberg
12 ;;;; LML users are granted the rights to distribute and use this software
13 ;;;; as governed by the terms of the GNU General Public License v2
14 ;;;; (http://www.gnu.org/licenses/gpl.html)
15 ;;;; *************************************************************************
17 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
20 (eval-when (:compile-toplevel :load-toplevel :execute)
21 (defvar *output-dir* nil)
22 (defvar *sources-dir* nil)
25 (defvar *html-output* *standard-output*)
27 (defmacro lml-file-name (file &optional (type :source))
29 (when (and (consp f) (eql (car f) 'cl:quote))
32 (setq f (string-downcase (symbol-name f))))
34 (unless (position #\. f)
35 (setq f (concatenate 'string f ".html"))))
37 `(make-pathname :defaults (ecase ,type
38 (:source *sources-dir*)
39 (:output *output-dir*))
40 :name (pathname-name ,f)
41 :type (pathname-type ,f))
46 (defmacro with-dir ((output-dir &key sources) &body body)
47 (when (stringp output-dir)
48 (setq output-dir (parse-namestring output-dir)))
50 (setq sources output-dir))
51 `(let ((*output-dir* ,output-dir)
52 (*sources-dir* ,sources))
55 (defun lml-load-path (file)
57 (with-open-file (in file :direction :input)
58 (do ((form (read in nil 'lml::eof) (read in nil 'lml::eof)))
61 (format *trace-output* "Warning: unable to load LML file ~S" file)))
63 (defun process-dir (dir &key sources)
64 (with-dir (dir :sources sources)
65 (let ((lml-files (directory
66 (make-pathname :defaults *sources-dir*
69 (dolist (file lml-files)
70 (format *trace-output* "~&; Processing ~A~%" file)
71 (lml-load-path file)))))
73 (defun lml-load (file)
74 (lml-load-path (eval `(lml-file-name ,file :source))))
76 (defun include-file (file)
77 (print-file-contents file *html-output*))