aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorAndrea Corallo2024-03-06 15:41:37 +0100
committerAndrea Corallo2024-03-06 17:13:38 +0100
commit9526bd3cf8eb5e5ed78c7fb8eb03d9e7dac9b941 (patch)
treebf9906544faac95ed14a51e0596a52bdb5536c7b /admin
parent1a5850a3af0693f022bb0a62e36bb84f762287c7 (diff)
downloademacs-9526bd3cf8eb5e5ed78c7fb8eb03d9e7dac9b941.tar.gz
emacs-9526bd3cf8eb5e5ed78c7fb8eb03d9e7dac9b941.zip
* Update syncdoc to dump all preloaded type hierarchy
* admin/syncdoc-type-hierarchy.el (syncdoc-file) (syncdoc-emacs-repo-dir): New constants. (syncdoc-lispref-dir): Make use of. (syncdoc-all-types): New function. (comp--direct-supertypes): Declare. (syncdoc-hierarchy): Update. (syncdoc-update-type-hierarchy0): Rename from 'syncdoc-update-type-hierarchy' and make non interactive. (syncdoc-update-type-hierarchy): New function.
Diffstat (limited to 'admin')
-rw-r--r--admin/syncdoc-type-hierarchy.el74
1 files changed, 39 insertions, 35 deletions
diff --git a/admin/syncdoc-type-hierarchy.el b/admin/syncdoc-type-hierarchy.el
index 6448369625b..b8cd71fe84e 100644
--- a/admin/syncdoc-type-hierarchy.el
+++ b/admin/syncdoc-type-hierarchy.el
@@ -37,42 +37,40 @@
37(require 'cl-lib) 37(require 'cl-lib)
38(require 'org-table) 38(require 'org-table)
39 39
40(defconst syncdoc-file (or (macroexp-file-name) buffer-file-name))
41
42(defconst syncdoc-emacs-repo-dir
43 (expand-file-name "../" (file-name-directory syncdoc-file)))
44
40(defconst syncdoc-lispref-dir 45(defconst syncdoc-lispref-dir
41 (expand-file-name "../doc/lispref/" 46 (expand-file-name "doc/lispref/" syncdoc-emacs-repo-dir))
42 (file-name-directory 47
43 (or (macroexp-file-name) 48(defconst syncdoc-all-types
44 buffer-file-name)))) 49 (let (res)
50 (maphash (lambda (type _)
51 (push type res))
52 cl--direct-supertypes-of-type)
53
54 (mapatoms (lambda (type)
55 (when (cl-find-class type)
56 (push type res)))
57 obarray)
58 res)
59 "List of all types.")
60
61(declare-function 'comp--direct-supertypes "comp-cstr.el")
45 62
46(defconst syncdoc-hierarchy 63(defconst syncdoc-hierarchy
47 (let ((ht (copy-hash-table cl--direct-supertypes-of-type))) 64 (progn
48 ;; Include info about "representative" other structure types, 65 ;; Require it here so we don't load it before `syncdoc-all-types' is
49 ;; to illustrate how they fit. 66 ;; computed.
50 (mapc #'require '(kmacro eieio-base elisp-mode frameset transient)) 67 (require 'comp-cstr)
51 (let ((extra-types '(advice kmacro cl-structure-object cl-structure-class 68 (cl-loop
52 eieio-default-superclass eieio-named transient-infix 69 with comp-ctxt = (make-comp-cstr-ctxt)
53 xref-elisp-location frameset-register)) 70 with h = (make-hash-table :test #'eq)
54 (seen ())) 71 for type in syncdoc-all-types
55 (while extra-types 72 do (puthash type (comp--direct-supertypes type) h)
56 (let* ((type (pop extra-types)) 73 finally return h)))
57 (class (get type 'cl--class))
58 (parents (cl--class-parents class)))
59 (unless (member type seen)
60 (push type seen)
61 (push (type-of class) extra-types)
62 (puthash type (cond
63 (parents
64 (let ((ps (mapcar #'cl--class-name parents)))
65 (setq extra-types (append ps extra-types))
66 ps))
67 ;; EIEIO's parents don't mention the default.
68 ((and (eq (type-of class) 'eieio--class)
69 (not (eq type 'eieio-default-superclass)))
70 '(eieio-default-superclass))
71 ;; OClosures can still be lists :-(
72 ((eq 'oclosure type) '(function))
73 (t '(atom)))
74 ht)))))
75 ht))
76 74
77(defun syncdoc-insert-dot-content (rankdir) 75(defun syncdoc-insert-dot-content (rankdir)
78 (maphash (lambda (child parents) 76 (maphash (lambda (child parents)
@@ -110,9 +108,8 @@
110 do (insert "\n"))) 108 do (insert "\n")))
111 (org-table-align))) 109 (org-table-align)))
112 110
113(defun syncdoc-update-type-hierarchy () 111(defun syncdoc-update-type-hierarchy0 ()
114 "Update the type hierarchy representation used by the elisp manual." 112 "Update the type hierarchy representation used by the elisp manual."
115 (interactive)
116 (with-temp-buffer 113 (with-temp-buffer
117 (syncdoc-insert-dot-content "LR") 114 (syncdoc-insert-dot-content "LR")
118 (with-demoted-errors "%S" ;In case "dot" is not found! 115 (with-demoted-errors "%S" ;In case "dot" is not found!
@@ -122,4 +119,11 @@
122 (syncdoc-make-type-table (expand-file-name "type_hierarchy.txt" 119 (syncdoc-make-type-table (expand-file-name "type_hierarchy.txt"
123 syncdoc-lispref-dir))) 120 syncdoc-lispref-dir)))
124 121
122(defun syncdoc-update-type-hierarchy ()
123 "Update the type hierarchy representation used by the elisp manual."
124 (interactive)
125 (call-process (expand-file-name "src/emacs" syncdoc-emacs-repo-dir)
126 nil t t "-Q" "--batch" "-l" syncdoc-file
127 "-f" "syncdoc-update-type-hierarchy0"))
128
125;;; syncdoc-type-hierarchy.el ends here 129;;; syncdoc-type-hierarchy.el ends here