Coverage report: /home/ellis/comp/core/lib/doc/system.lisp
Kind | Covered | All | % |
expression | 5 | 136 | 3.7 |
branch | 0 | 18 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; lib/doc/system.lisp --- System Documentation
3
;; Documentation support for a Lisp System
8
(defclass system-documentation ()
9
((system :initarg :system :type system :accessor doc-system)))
11
(defmethod name ((self system-documentation))
12
(asdf:component-name (doc-system self)))
14
(defun system-documentation (system)
15
"Return the SYSTEM-DOCUMENTATION for a specified SYSTEM."
16
(let ((s (find-system system)))
17
(make-instance 'system-documentation
20
(defmethod print-object ((self system-documentation) stream)
21
(with-slots (system) self
22
(print-unreadable-object (self stream :type t)
23
(format stream "~A" (component-name system)))))
25
(defmethod doc-files ((self system-documentation))
26
"Return a list of source file components from SELF."
27
(flet ((%rec (s) (if (typep s 'asdf:module)
29
(component-pathname s))))
30
(flatten (mapcar #'%rec (component-children (doc-system self))))))
32
(defmethod doc-files ((self asdf:module))
33
(flet ((%rec (s) (if (typep s 'asdf:module)
35
(component-pathname s))))
36
(mapcar #'%rec (component-children self))))
38
;; TODO: to do this correctly we need to also check if SELF is a
39
;; prefix of a different system name. e.g. "DOC" and "DOC-UTILS"
41
;; TODO: system separator handling and optimizations
42
(defmethod doc-packages ((self system-documentation))
43
"Return a list of packages which can be traced back to SELF. This
44
method will only return packages that are prefixed with the name of
46
;; (asdf:component-loaded-p
47
(let ((s (component-name (doc-system self))))
49
#'package-documentation
53
(when (and (packagep p)
59
(concatenate 'string (string-upcase s) "-")
62
(concatenate 'string (string-upcase s) "/")
65
(list-all-packages))))))
67
;; TODO 2025-03-02: handle (:feature :foo :sysname) in system-depends-on results
68
(defmethod doc-dependencies ((self system-documentation))
71
(if (eql (pop x) :feature)
72
(when (sb-int:featurep (pop x))
73
(system-documentation (pop x))))
74
(system-documentation x)))
75
(system-depends-on (doc-system self))))
77
(defun find-system-dependents (system)
78
"Return a list of systems which depend on SYSTEM by iterating over ASDF:REGISTER-SYSTEMS."
80
(dolist (s (asdf:registered-systems))
81
(setf s (find-system s))
82
(when (and s (member (component-name system)
86
(string-downcase (format nil "~A" dep))))
87
(asdf:system-depends-on s))
92
(defmethod doc-dependents ((self system-documentation))
93
(mapcar #'system-documentation (find-system-dependents (doc-system self))))