aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorStefan Monnier2024-03-10 15:12:00 -0400
committerStefan Monnier2024-03-10 15:12:00 -0400
commitc17ecd2dcd27b73d673df51ce66f4b188afff6db (patch)
treea9b07861656d159b100cb1b26c3770dd7f146429 /admin
parent2fdb281a276af57c104008d68ae95c7f4b1c3da8 (diff)
downloademacs-c17ecd2dcd27b73d673df51ce66f4b188afff6db.tar.gz
emacs-c17ecd2dcd27b73d673df51ce66f4b188afff6db.zip
syncdoc-type-hierarchy.el: Sort and remove `comp` dependency
* admin/syncdoc-type-hierarchy.el: Delay loading `org-table` so as not to "pollute" the table with Org-specific types. (syncdoc-all-types): Sort the types topologically from the root. (syncdoc-hierarchy): Use `cl--class-parents` instead if `comp--direct-supertypes` so we don't depend on `comp-cstr`. (syncdoc-make-type-table): Sort the table so supertypes always come before their subtypes. (syncdoc-make-type-table): Require `org-table` here. * doc/lispref/elisp_type_hierarchy.jpg: * doc/lispref/elisp_type_hierarchy.txt: Refresh.
Diffstat (limited to 'admin')
-rw-r--r--admin/syncdoc-type-hierarchy.el26
1 files changed, 17 insertions, 9 deletions
diff --git a/admin/syncdoc-type-hierarchy.el b/admin/syncdoc-type-hierarchy.el
index e14d7fb54e1..bfbbbc45aa4 100644
--- a/admin/syncdoc-type-hierarchy.el
+++ b/admin/syncdoc-type-hierarchy.el
@@ -35,7 +35,6 @@
35;;; Code: 35;;; Code:
36 36
37(require 'cl-lib) 37(require 'cl-lib)
38(require 'org-table)
39 38
40(defconst syncdoc-file (or (macroexp-file-name) buffer-file-name)) 39(defconst syncdoc-file (or (macroexp-file-name) buffer-file-name))
41 40
@@ -51,21 +50,24 @@
51 (when (cl-find-class type) 50 (when (cl-find-class type)
52 (push type res))) 51 (push type res)))
53 obarray) 52 obarray)
54 res) 53 (nreverse
54 (merge-ordered-lists
55 (sort
56 (mapcar (lambda (type) (cl--class-allparents (cl-find-class type)))
57 res)
58 (lambda (ts1 ts2) (> (length ts1) (length ts2)))))))
55 "List of all types.") 59 "List of all types.")
56 60
57(declare-function 'comp--direct-supertypes "comp-cstr.el")
58
59(defconst syncdoc-hierarchy 61(defconst syncdoc-hierarchy
60 (progn 62 (progn
61 ;; Require it here so we don't load it before `syncdoc-all-types' is 63 ;; Require it here so we don't load it before `syncdoc-all-types' is
62 ;; computed. 64 ;; computed.
63 (require 'comp-cstr)
64 (cl-loop 65 (cl-loop
65 with comp-ctxt = (make-comp-cstr-ctxt)
66 with h = (make-hash-table :test #'eq) 66 with h = (make-hash-table :test #'eq)
67 for type in syncdoc-all-types 67 for type in syncdoc-all-types
68 do (puthash type (comp--direct-supertypes type) h) 68 do (puthash type (mapcar #'cl--class-name
69 (cl--class-parents (cl-find-class type)))
70 h)
69 finally return h))) 71 finally return h)))
70 72
71(defun syncdoc-insert-dot-content (rankdir) 73(defun syncdoc-insert-dot-content (rankdir)
@@ -90,10 +92,14 @@
90 (dolist (parent parents) 92 (dolist (parent parents)
91 (push type (alist-get parent subtypes)))) 93 (push type (alist-get parent subtypes))))
92 syncdoc-hierarchy) 94 syncdoc-hierarchy)
93 (cl-loop for (type . children) in (reverse subtypes) 95 (sort subtypes
96 (lambda (x1 x2)
97 (< (length (memq (car x2) syncdoc-all-types))
98 (length (memq (car x1) syncdoc-all-types)))))
99 (cl-loop for (type . children) in subtypes
94 do (insert "|" (symbol-name type) " |") 100 do (insert "|" (symbol-name type) " |")
95 do (cl-loop with x = 0 101 do (cl-loop with x = 0
96 for child in (reverse children) 102 for child in children
97 for child-len = (length (symbol-name child)) 103 for child-len = (length (symbol-name child))
98 when (> (+ x child-len 2) 60) 104 when (> (+ x child-len 2) 60)
99 do (progn 105 do (progn
@@ -102,6 +108,8 @@
102 do (insert (symbol-name child) " ") 108 do (insert (symbol-name child) " ")
103 do (cl-incf x (1+ child-len)) ) 109 do (cl-incf x (1+ child-len)) )
104 do (insert "\n"))) 110 do (insert "\n")))
111 (require 'org-table)
112 (declare-function 'org-table-align "org")
105 (org-table-align))) 113 (org-table-align)))
106 114
107(defun syncdoc-update-type-hierarchy0 () 115(defun syncdoc-update-type-hierarchy0 ()