Commits

Anonymous committed 35516cf

Generalized package template folder concept, so that templates can reside in different directories; used that mechanism to support documentation templates in a separate directory from package templates

  • Participants
  • Parent commits 2b4f839

Comments (0)

Files changed (5)

doctemplates/doc_index.lisp

+;; Copyright (c) 2011 Phil Hargett
+
+;; Permission is hereby granted, free of charge, to any person obtaining a copy
+;; of this software and associated documentation files (the "Software"), to deal
+;; in the Software without restriction, including without limitation the rights
+;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+;; copies of the Software, and to permit persons to whom the Software is
+;; furnished to do so, subject to the following conditions:
+
+;; The above copyright notice and this permission notice shall be included in
+;; all copies or substantial portions of the Software.
+
+;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+;; THE SOFTWARE.
+
+(+tag-library :html)
+(+tag-library :script)
+
+(page 
+ (+title "Documentation for hh-web-tags")
+ (p "Documentation forthcoming"))

documentation.lisp

 
 (deftemplates :tag-library-packages ( "hh-web-tags" )
   :template-packages ( "hh-web-tags")
-  :templates ((wt-package-docs-index "wt_package_docs_index.lisp")))
+  :templates ((doc-index "doc_index.lisp"))
+  :folder "doctemplates")
 
 (defun generate-package-documentation ()
   (flet ((report (&rest args)
 						       :directory (pathname-directory documentation-path)))))
       (report "Generating documentation to directory ~s~%" documentation-path)
       (ensure-directories-exist documentation-path)
-      (with-open-file (os index-path :direction :output :if-does-not-exist :create)
+      (with-open-file (os index-path :direction :output :if-does-not-exist :create :if-exists :overwrite)
 	(report "Generating index at ~s~%" index-path)
-	(write-string (wt-package-docs-index) os)))))
+	(write-string (doc-index) os))))
+  t)

package-hh-web-tags.lisp

    ;; For tag libraries
   #:*tag-library*
   #:*tag-library-provider-registry*
+  #:*package-template-folder*
+  #:*template*
+  #:*minimum-template-stale-time*
   #:create-folder-tag-library-provider
   #:create-asdf-system-tag-library-provider
 
   "Minimum time in seconds for which a template must remain stale (e.g. not expire,
    before reloading from its source")
 
+(defvar *package-template-folder* "templates"
+  "The name of the folder within a package's folder structure where template 
+   files are located")
+
 ;;;------------------------------------------------------------------------------------
 ;;; Conditions
 ;;;------------------------------------------------------------------------------------
 ;;  templates in individual files from any of those locations
 ;;
 
-(defclass asdf-system-provider (file-based-template-provider)
-  ((system :initform nil :initarg :system :accessor system-of)))
+(defclass asdf-system-provider (folder-template-provider)
+  ((folder :initform *package-template-folder*) 
+   (system :initform nil :initarg :system :accessor system-of)))
 
 (defmethod template-provider-base-directory ( (provider asdf-system-provider) )
-  (asdf:system-relative-pathname (system-of provider) (make-pathname :directory `(:relative "templates")) ))
+  (asdf:system-relative-pathname (system-of provider) (make-pathname :directory `(:relative ,(folder-of provider))) ))
 
-(defun create-asdf-system-template-provider (system)
-  (make-instance 'asdf-system-provider :system system))
+(defun create-asdf-system-template-provider (system &key ((:folder folder) *package-template-folder*))
+  (make-instance 'asdf-system-provider :system system :folder folder))
 
 ; -- Implementation of base template-provider functions
 
 (defmacro deftemplates (&key
 			((:tag-library-packages tag-library-packages) nil)
 			((:template-packages template-packages) nil)
-			((:templates templates) nil))
+			((:templates templates) nil)
+			((:folder default-folder) '*package-template-folder*))
   (let ((template-provider-registry (local-template-provider-registry-symbol) )
 	(tag-library-provider-registry (local-tag-library-provider-registry-symbol) ))
     `(progn
        (defparameter ,template-provider-registry
-	 (list ,@(append (mapcar (lambda (template-package)
-				   `(create-asdf-system-template-provider (quote ,template-package)))
+	 (list ,@(append (mapcar (lambda (template-package-spec)
+				   (destructuring-bind (template-package template-directory)
+					   (if (listp template-package-spec)
+					       template-package-spec
+					       (list template-package-spec default-folder))
+					 `(create-asdf-system-template-provider (quote ,template-package) :folder ,template-directory)))
 				 template-packages)
 			 ;; always here by default
 			 (list `(create-asdf-system-template-provider 'hh-web-tags)))))

templates/wt_package_docs_index.lisp

-;; Copyright (c) 2011 Phil Hargett
-
-;; Permission is hereby granted, free of charge, to any person obtaining a copy
-;; of this software and associated documentation files (the "Software"), to deal
-;; in the Software without restriction, including without limitation the rights
-;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-;; copies of the Software, and to permit persons to whom the Software is
-;; furnished to do so, subject to the following conditions:
-
-;; The above copyright notice and this permission notice shall be included in
-;; all copies or substantial portions of the Software.
-
-;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-;; THE SOFTWARE.
-
-(+tag-library :html)
-(+tag-library :script)
-
-(page 
- (+title "Documentation for hh-web-tags")
- (p "Documentation forthcoming"))