1 ; Copyright 2022 Frank Duncan (frank@consxy.com) under AGPL3. See distributed LICENSE.txt.
2 (in-package #:sheep-struc)
4 (defun fire-error (msg) (error (make-instance 'sheep:validation-failure :msg msg)))
6 (defun doc->ast (struc)
12 ((< 120 (length str)) (fire-error (format nil "Structure description longer than 120 characters: ~A" str)))
13 ((cl-ppcre:scan "^ " str) (fire-error (format nil "Structure description line started with space: ~A" str)))
14 ((cl-ppcre:scan " $" str) (fire-error (format nil "Structure description line ended with space: ~A" str)))))
18 ((not strs) (list ""))
19 ((string= "" (car strs)) (cons "" (combine (cdr strs))))
22 ((rest (combine (cdr strs))))
23 (cons (format nil "~A~A~A" (car strs) (if (string/= "" (car rest)) " " "") (car rest)) (cdr rest)))))))
25 ((lines (cl-ppcre:split "\\n" (documentation struc 'structure))))
28 ((paragraphs (combine lines)))
29 (when (find "" paragraphs :test #'string=) (fire-error "Structure description has two empty lines in it"))
32 ((typep (make-instance struc) 'condition) :condition)
34 (cons struc paragraphs))))))
37 (format nil "## ~@(~A~) ~A~%~%~{~A~%~^~%~}"
42 (defun ast->category-name (ast)
44 (:condition "condition")
47 (defun ast->short-name (ast)
48 (format nil "~(~A~)" (second ast)))
50 (defun ast->link (ast)
51 (format nil "~(~A-~A~)" (first ast) (second ast)))
53 (defun ast->short-desc (ast)