Repository navigation
Expand file tree
/
Copy pathexports.lisp
More file actions
84 lines (75 loc) · 2.91 KB
/
Copy pathexports.lisp
File metadata and controls
84 lines (75 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
;; exports.lisp
(in-package :dc-eclectic)
(defun check-exports ()
(let* ((public (public-symbols))
(exported (exported-symbols))
(docs (doc-symbols))
(missing-in-exports (set-difference public exported))
(stale-exports (set-difference exported public))
(missing-in-docs (set-difference public docs))
(stale-docs (set-difference docs public)))
(list
:missing-in-exports missing-in-exports
:stale-exports stale-exports
:missing-in-docs missing-in-docs
:stale-docs stale-docs)))
(defun sort-symbols (list)
(safe-sort list
:predicate (lambda (a b)
(string< (format nil "~a" a) (format nil "~b" b)))))
(defun exported-symbols ()
"Returns list of symbols exported from DC-ECLECTIC."
(let (result)
(do-external-symbols (s (find-package 'dc-eclectic) result) (push s result))
(sort-symbols result)))
(defun symbol-documentation (s)
"Returns the documentation string for symbol S."
(or
(documentation s 'variable)
(documentation s 'function)))
(defun documented-symbols ()
"Returns a list of documented symbols in DC-ECLECTIC."
(let (result)
(do-symbols (s (find-package 'dc-eclectic) result)
(let ((doc (symbol-documentation s)))
(when (and
doc
(or (boundp s) (find-class s nil) (fboundp s))
(re:scan "^(\\[public\\]|\\[private\\]) " doc))
(push s result))))
(sort-symbols result)))
(defun public-symbols ()
"Returns a list of the symbols in this package with a documentation string
that starts with '[public] '."
(remove-if-not
(lambda (s) (re:scan "^\\[public\\] " (symbol-documentation s)))
(documented-symbols)))
(defun private-symbols ()
"Returns a list of the symbols in this package with a documentation string
that starts with '[private] '."
(remove-if-not
(lambda (s) (re:scan "^\\[private\\] " (symbol-documentation s)))
(documented-symbols)))
(defun doc-symbols ()
(let ((lines (re:split
"\\n"
(slurp (join-paths
(asdf:system-relative-pathname :dc-eclectic #P"")
"docs.lisp")))))
(loop for line in lines
for symbol-line = (re:scan
(format nil "~{~a~^|~}"
(list
" function\\)"
" variable\\)"
" macro\\)"))
line)
for symbol-string = (when symbol-line
(car
(remove-if
(lambda (s) (zerop (length s)))
(re:split "[ ()]+" line))))
for symbol = (when symbol-string
(find-symbol (string-upcase symbol-string)))
when symbol collect symbol into symbols
finally (return (sort-symbols symbols)))))