(defpackage #:emptydocs (:use :cl)
- (:export #:no-doc-func))
+ (:export #:no-doc-condition #:no-doc-func))
(in-package #:emptydocs)
+(define-condition no-doc-condition nil nil)
+
(defun no-doc-func (path x) path)
This is should all get pulled in and the markdown.md should be equal
to success1.md.")
(:export
+ #:test-condition
#:func-that-does-stuff #:noargs #:result-list #:has-no-examples
#:values-result #:has-optional #:has-keywords #:has-rest))
(in-package #:success1)
+(define-condition test-condition nil nil
+ (:documentation
+ "Simple documentation.
+
+For a simple condition."))
+
(defun func-that-does-stuff (path x)
"FUNC-THAT-DOES-STUFF PATH X => RESULT
NOARGS runs all the things against a file and returns as soon as the first func error is found.
+## Condition TEST-CONDITION
+
+Simple documentation.
+
+For a simple condition.
+
## Function **VALUES-RESULT**
#### 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 "pkg") (:file "docgen")))
+ :components ((:file "package") (:file "func") (:file "pkg") (:file "struc") (:file "docgen")))
(asdf:defsystem docgen
:name "Documentation Generator"
(defun get-symb-type (symb)
(cond
;((documentation symb 'variable) :variable)
- ;((documentation symb 'structure) :structure)
+ ((documentation symb 'structure) :structure)
((documentation symb 'function) :function)))
(defun validate-package (pkg)
(with-success-check
(case (get-symb-type symb)
(:function (docgen-func:doc->ast symb))
+ (:structure (docgen-struc:doc->ast symb))
(t (error (make-condition 'validation-failure :msg (format nil "Symbol ~A has no documentation" symb)))))))
symbs))))))
(format str "~{~A~^~%~}"
(mapcar
(lambda (symb)
+ (format t "HAHAHAH ~A ~A~%" symb (get-symb-type symb))
(case (get-symb-type symb)
- (:function (docgen-func:ast->md (docgen-func:doc->ast symb)))))
+ (:function (docgen-func:ast->md (docgen-func:doc->ast symb)))
+ (:structure (docgen-struc:ast->md (docgen-struc:doc->ast symb)))))
symbs)))))
(defpackage #:docgen-pkg (:use :cl)
(:export #:doc->ast #:ast->md))
+
+(defpackage #:docgen-struc (:use :cl)
+ (:export #:doc->ast #:ast->md))
--- /dev/null
+(in-package #:docgen-struc)
+
+(defun fire-error (msg) (error (make-instance 'docgen:validation-failure :msg msg)))
+
+(defun doc->ast (struc)
+ (labels
+ ((validate (strs)
+ (mapcar
+ (lambda (str)
+ (cond
+ ((< 120 (length str)) (fire-error (format nil "Structure description longer than 120 characters: ~A" str)))
+ ((cl-ppcre:scan "^ " str) (fire-error (format nil "Structure description line started with space: ~A" str)))
+ ((cl-ppcre:scan " $" str) (fire-error (format nil "Structure 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 struc 'structure))))
+ (validate lines)
+ (let
+ ((paragraphs (combine lines)))
+ (when (find "" paragraphs :test #'string=) (fire-error "Structure description has two empty lines in it"))
+ (cons
+ (cond
+ ((typep (make-instance struc) 'condition) :condition)
+ (t :struct))
+ (cons struc paragraphs))))))
+
+(defun ast->md (ast)
+ (format nil "## ~@(~A~) ~A~%~%~{~A~%~^~%~}"
+ (first ast)
+ (second ast)
+ (cddr ast)))
(defsuccesstest :success1 "resources/success1.lisp" "resources/success1.md")
(deffailuretest :emptydocs "resources/emptydocs.lisp"
'((:failure "Package EMPTYDOCS has no documentation")
+ (:failure "Symbol NO-DOC-CONDITION has no documentation")
(:failure "Symbol NO-DOC-FUNC has no documentation")))