]> git.eshelyaron.com Git - emacs.git/commitdiff
syncdoc-type-hierarchy.el: Sort and remove `comp` dependency
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 10 Mar 2024 19:12:00 +0000 (15:12 -0400)
committerEshel Yaron <me@eshelyaron.com>
Mon, 11 Mar 2024 09:27:12 +0000 (10:27 +0100)
* 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.

(cherry picked from commit c17ecd2dcd27b73d673df51ce66f4b188afff6db)

admin/syncdoc-type-hierarchy.el
doc/lispref/elisp_type_hierarchy.jpg
doc/lispref/elisp_type_hierarchy.txt

index e14d7fb54e13cb2931895d759b06bb4562ace640..bfbbbc45aa4f1200ade3a36c1b9838cb9950231b 100644 (file)
@@ -35,7 +35,6 @@
 ;;; Code:
 
 (require 'cl-lib)
-(require 'org-table)
 
 (defconst syncdoc-file (or (macroexp-file-name) buffer-file-name))
 
                 (when (cl-find-class type)
                   (push type res)))
               obarray)
-    res)
+    (nreverse
+     (merge-ordered-lists
+      (sort
+       (mapcar (lambda (type) (cl--class-allparents (cl-find-class type)))
+               res)
+       (lambda (ts1 ts2) (> (length ts1) (length ts2)))))))
   "List of all types.")
 
-(declare-function 'comp--direct-supertypes "comp-cstr.el")
-
 (defconst syncdoc-hierarchy
   (progn
     ;; Require it here so we don't load it before `syncdoc-all-types' is
     ;; computed.
-    (require 'comp-cstr)
     (cl-loop
-     with comp-ctxt = (make-comp-cstr-ctxt)
      with h = (make-hash-table :test #'eq)
      for type in syncdoc-all-types
-     do (puthash type (comp--direct-supertypes type) h)
+     do (puthash type (mapcar #'cl--class-name
+                       (cl--class-parents (cl-find-class type)))
+         h)
      finally return h)))
 
 (defun syncdoc-insert-dot-content (rankdir)
                  (dolist (parent parents)
                    (push type (alist-get parent subtypes))))
                syncdoc-hierarchy)
-      (cl-loop for (type . children) in (reverse subtypes)
+      (sort subtypes
+            (lambda (x1 x2)
+              (< (length (memq (car x2) syncdoc-all-types))
+                 (length (memq (car x1) syncdoc-all-types)))))
+      (cl-loop for (type . children) in subtypes
                do (insert "|" (symbol-name type) " |")
                do (cl-loop with x = 0
-                           for child in (reverse children)
+                           for child in children
                            for child-len = (length (symbol-name child))
                            when (> (+ x child-len 2) 60)
                            do (progn
                            do (insert (symbol-name child) " ")
                            do (cl-incf x (1+ child-len)) )
                do (insert "\n")))
+    (require 'org-table)
+    (declare-function 'org-table-align "org")
     (org-table-align)))
 
 (defun syncdoc-update-type-hierarchy0 ()
index a2e14490dfa39d70473f9624c68b69aad5528297..386954e100774279844414c488498f89eb28941a 100644 (file)
Binary files a/doc/lispref/elisp_type_hierarchy.jpg and b/doc/lispref/elisp_type_hierarchy.jpg differ
index d1be8f56c727e65fd7ecbde480c814d648c1d53e..bb93cd831b951d12953d9c4445773ae0d02e326e 100644 (file)
@@ -1,33 +1,33 @@
-| Type                | Derived Types                                              |
-|---------------------+------------------------------------------------------------|
-| atom                | mutex record font-spec frame number-or-marker              |
-|                     | tree-sitter-compiled-query tree-sitter-node font-entity    |
-|                     | tree-sitter-parser hash-table window-configuration         |
-|                     | function user-ptr overlay array process font-object symbol |
-|                     | obarray condvar buffer terminal thread window              |
-|                     | native-comp-unit                                           |
-| cl-structure-object | xref-elisp-location org-cite-processor cl--generic-method  |
-|                     | cl--random-state register-preview-info cl--generic         |
-|                     | cl--class cl-slot-descriptor uniquify-item registerv       |
-|                     | isearch--state cl--generic-generalizer lisp-indent-state   |
-| t                   | sequence atom                                              |
-| compiled-function   | subr byte-code-function                                    |
-| integer             | fixnum bignum                                              |
-| symbol              | symbol-with-pos keyword boolean                            |
-| accessor            | oclosure-accessor                                          |
-| oclosure            | advice cconv--interactive-helper advice--forward accessor  |
-|                     | save-some-buffers-function cl--generic-nnm                 |
-| cons                | ppss decoded-time                                          |
-| cl--class           | cl-structure-class oclosure--class built-in-class          |
-| subr                | subr-primitive subr-native-elisp                           |
-| array               | string vector bool-vector char-table                       |
-| number              | float integer                                              |
-| number-or-marker    | integer-or-marker number                                   |
-| function            | oclosure compiled-function interpreted-function            |
-|                     | module-function                                            |
-| sequence            | list array                                                 |
-| integer-or-marker   | integer marker                                             |
-| boolean             | null                                                       |
-| list                | null cons                                                  |
-| record              | cl-structure-object                                        |
-| vector              | timer                                                      |
+| Type                | Derived Types                                             |
+|---------------------+-----------------------------------------------------------|
+| t                   | sequence atom                                             |
+| atom                | number-or-marker array record symbol function             |
+|                     | window-configuration font-object font-entity mutex        |
+|                     | tree-sitter-node buffer overlay tree-sitter-parser thread |
+|                     | font-spec native-comp-unit tree-sitter-compiled-query     |
+|                     | terminal window frame hash-table user-ptr obarray condvar |
+|                     | process                                                   |
+| sequence            | array list                                                |
+| list                | null cons                                                 |
+| function            | oclosure compiled-function module-function                |
+|                     | interpreted-function                                      |
+| symbol              | boolean symbol-with-pos keyword                           |
+| compiled-function   | subr byte-code-function                                   |
+| oclosure            | accessor advice--forward cconv--interactive-helper        |
+|                     | cl--generic-nnm advice save-some-buffers-function         |
+| record              | cl-structure-object                                       |
+| cl-structure-object | cl--class lisp-indent-state cl--random-state registerv    |
+|                     | xref-elisp-location isearch--state cl-slot-descriptor     |
+|                     | cl--generic-generalizer uniquify-item cl--generic-method  |
+|                     | register-preview-info cl--generic                         |
+| cons                | ppss decoded-time                                         |
+| array               | vector string char-table bool-vector                      |
+| number-or-marker    | number integer-or-marker                                  |
+| integer-or-marker   | integer marker                                            |
+| number              | integer float                                             |
+| cl--class           | built-in-class cl-structure-class oclosure--class         |
+| subr                | subr-native-elisp subr-primitive                          |
+| accessor            | oclosure-accessor                                         |
+| vector              | timer                                                     |
+| boolean             | null                                                      |
+| integer             | fixnum bignum                                             |