aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2024-03-10 15:12:00 -0400
committerStefan Monnier2024-03-10 15:12:00 -0400
commitc17ecd2dcd27b73d673df51ce66f4b188afff6db (patch)
treea9b07861656d159b100cb1b26c3770dd7f146429
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.
-rw-r--r--admin/syncdoc-type-hierarchy.el26
-rw-r--r--doc/lispref/elisp_type_hierarchy.jpgbin345570 -> 288444 bytes
-rw-r--r--doc/lispref/elisp_type_hierarchy.txt66
3 files changed, 50 insertions, 42 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 ()
diff --git a/doc/lispref/elisp_type_hierarchy.jpg b/doc/lispref/elisp_type_hierarchy.jpg
index a2e14490dfa..386954e1007 100644
--- a/doc/lispref/elisp_type_hierarchy.jpg
+++ b/doc/lispref/elisp_type_hierarchy.jpg
Binary files differ
diff --git a/doc/lispref/elisp_type_hierarchy.txt b/doc/lispref/elisp_type_hierarchy.txt
index d1be8f56c72..bb93cd831b9 100644
--- a/doc/lispref/elisp_type_hierarchy.txt
+++ b/doc/lispref/elisp_type_hierarchy.txt
@@ -1,33 +1,33 @@
1| Type | Derived Types | 1| Type | Derived Types |
2|---------------------+------------------------------------------------------------| 2|---------------------+-----------------------------------------------------------|
3| atom | mutex record font-spec frame number-or-marker | 3| t | sequence atom |
4| | tree-sitter-compiled-query tree-sitter-node font-entity | 4| atom | number-or-marker array record symbol function |
5| | tree-sitter-parser hash-table window-configuration | 5| | window-configuration font-object font-entity mutex |
6| | function user-ptr overlay array process font-object symbol | 6| | tree-sitter-node buffer overlay tree-sitter-parser thread |
7| | obarray condvar buffer terminal thread window | 7| | font-spec native-comp-unit tree-sitter-compiled-query |
8| | native-comp-unit | 8| | terminal window frame hash-table user-ptr obarray condvar |
9| cl-structure-object | xref-elisp-location org-cite-processor cl--generic-method | 9| | process |
10| | cl--random-state register-preview-info cl--generic | 10| sequence | array list |
11| | cl--class cl-slot-descriptor uniquify-item registerv | 11| list | null cons |
12| | isearch--state cl--generic-generalizer lisp-indent-state | 12| function | oclosure compiled-function module-function |
13| t | sequence atom | 13| | interpreted-function |
14| compiled-function | subr byte-code-function | 14| symbol | boolean symbol-with-pos keyword |
15| integer | fixnum bignum | 15| compiled-function | subr byte-code-function |
16| symbol | symbol-with-pos keyword boolean | 16| oclosure | accessor advice--forward cconv--interactive-helper |
17| accessor | oclosure-accessor | 17| | cl--generic-nnm advice save-some-buffers-function |
18| oclosure | advice cconv--interactive-helper advice--forward accessor | 18| record | cl-structure-object |
19| | save-some-buffers-function cl--generic-nnm | 19| cl-structure-object | cl--class lisp-indent-state cl--random-state registerv |
20| cons | ppss decoded-time | 20| | xref-elisp-location isearch--state cl-slot-descriptor |
21| cl--class | cl-structure-class oclosure--class built-in-class | 21| | cl--generic-generalizer uniquify-item cl--generic-method |
22| subr | subr-primitive subr-native-elisp | 22| | register-preview-info cl--generic |
23| array | string vector bool-vector char-table | 23| cons | ppss decoded-time |
24| number | float integer | 24| array | vector string char-table bool-vector |
25| number-or-marker | integer-or-marker number | 25| number-or-marker | number integer-or-marker |
26| function | oclosure compiled-function interpreted-function | 26| integer-or-marker | integer marker |
27| | module-function | 27| number | integer float |
28| sequence | list array | 28| cl--class | built-in-class cl-structure-class oclosure--class |
29| integer-or-marker | integer marker | 29| subr | subr-native-elisp subr-primitive |
30| boolean | null | 30| accessor | oclosure-accessor |
31| list | null cons | 31| vector | timer |
32| record | cl-structure-object | 32| boolean | null |
33| vector | timer | 33| integer | fixnum bignum |