to success1.md.")
(:export
#:func-that-does-stuff #:noargs #:result-list #:has-no-examples
- #:values-result #:has-optional #:has-keywords #:has-rest
- ))
+ #:values-result #:has-optional #:has-keywords #:has-rest))
(in-package #:success1)
+# Package SUCCESS1
+
+This defines a simple successful package.
+
+This is should all get pulled in and the markdown.md should be equal to success1.md.
+
## Function **FUNC-THAT-DOES-STUFF**
#### Syntax:
; There's probably a better way, but I don't know it
(asdf:defsystem docgen.internal
:serial t
- :components ((:file "package") (:file "func") (:file "docgen")))
+ :components ((:file "package") (:file "func") (:file "pkg") (:file "docgen")))
(asdf:defsystem docgen
:name "Documentation Generator"
(define-condition validation-failure nil ((msg :initarg :msg :reader validation-failure-msg)))
(defun validate-package (pkg)
- (let
- ((symbs nil))
- (do-external-symbols (symb pkg) (push symb symbs))
- (setf symbs (sort symbs #'string< :key #'symbol-name))
- (remove :success
- (mapcar
- (lambda (symb)
- (handler-case
- (progn
- (docgen-func:doc->ast symb)
- :success)
- (validation-failure (v) (list :failure :msg (validation-failure-msg v)))))
- symbs))))
+ (macrolet
+ ((with-success-check (&rest f)
+ `(handler-case
+ (progn ,@f :success)
+ (validation-failure (v) (list :failure :msg (validation-failure-msg v))))))
+ (let
+ ((symbs nil))
+ (do-external-symbols (symb pkg) (push symb symbs))
+ (setf symbs (sort symbs #'string< :key #'symbol-name))
+ (remove :success
+ (append
+ (list (with-success-check (docgen-pkg:doc->ast pkg)))
+ (mapcar
+ (lambda (symb) (with-success-check (docgen-func:doc->ast symb)))
+ symbs))))))
(defun export-package (pkg)
(let
((symbs nil))
(do-external-symbols (symb pkg) (push symb symbs))
(setf symbs (sort symbs #'string< :key #'symbol-name))
- (format nil "~{~A~^~%~}" (mapcar (lambda (symb) (docgen-func:ast->md (docgen-func:doc->ast symb))) symbs))))
+ (with-output-to-string (str)
+ (format str "~A~%~%" (docgen-pkg:ast->md (docgen-pkg:doc->ast (find-package pkg))))
+ (format str "~{~A~^~%~}" (mapcar (lambda (symb) (docgen-func:ast->md (docgen-func:doc->ast symb))) symbs)))))
(defpackage #:docgen-func (:use :cl)
(:export #:doc->ast #:ast->md))
+
+(defpackage #:docgen-pkg (:use :cl)
+ (:export #:doc->ast #:ast->md))
--- /dev/null
+(in-package #:docgen-pkg)
+
+(defun fire-error (msg) (error (make-instance 'docgen:validation-failure :msg msg)))
+
+(defun doc->ast (pkg)
+ (labels
+ ((validate (strs)
+ (mapcar
+ (lambda (str)
+ (cond
+ ((< 120 (length str)) (fire-error (format nil "Package description longer than 120 characters: ~A" str)))
+ ((cl-ppcre:scan "^ " str) (fire-error (format nil "Package description line started with space: ~A" str)))
+ ((cl-ppcre:scan " $" str) (fire-error (format nil "Package description line ended with space: ~A" str)))))
+ strs))
+ (combine (strs)
+ (cond
+ ((not strs) (list ""))
+ ((string= "" (car strs)) (cons "" (combine (cdr strs))))
+ (t
+ (let
+ ((rest (combine (cdr strs))))
+ (cons (format nil "~A~A~A" (car strs) (if (string/= "" (car rest)) " " "") (car rest)) (cdr rest)))))))
+ (let
+ ((lines (cl-ppcre:split "\\n" (documentation pkg t))))
+ (validate lines)
+ (let
+ ((paragraphs (combine lines)))
+ (when (< 120 (length (first paragraphs))) (fire-error "First package paragraph is longer than 120 characters"))
+ (when (find "" paragraphs :test #'string=) (fire-error "Package description has two empty lines in it"))
+ (cons (package-name pkg) paragraphs)))))
+
+(defun ast->md (ast)
+ (format nil "# Package ~A~%~%~{~A~^~%~%~}"
+ (car ast)
+ (cdr ast)))
`(deftest
,source
(lambda ()
- (load ,source)
- (ignore-errors (string= (slurp-file ,target) (docgen:export-package ,pkg))))))
+ (handler-case
+ (progn
+ (load ,source)
+ (string= (slurp-file ,target) (docgen:export-package ,pkg)))
+ (docgen:validation-failure (vf)
+ (format t "Error gotten: ~A~%"
+ (funcall (symbol-function (find-symbol "VALIDATION-FAILURE-MSG" :docgen)) vf)))
+ (error (e) (format t "Error gotten: ~A~%" e))))))
(defmacro deffailure-func-test (name doc expected)
`(deftest
-Subproject commit ffe2711a19e5a213cfdf7b52e7ad7b4b25316a2b
+Subproject commit 1a8916ff9faac67cbb461da9cc939d8bee63bf25