]> git.eshelyaron.com Git - emacs.git/commitdiff
Make type hierarchy textual representation a table
authorAndrea Corallo <acorallo@gnu.org>
Mon, 19 Feb 2024 16:40:04 +0000 (17:40 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sat, 2 Mar 2024 06:29:23 +0000 (07:29 +0100)
* etc/syncdoc-type-hierarchy.el (syncdoc-make-type-table): New function.
(syncdoc-update-type-hierarchy): Make use of.
* doc/lispref/type_hierarchy.txt: Regenerate.

(cherry picked from commit 0393bfdc912912e3368b786d062894f3069d210b)

doc/lispref/type_hierarchy.txt
etc/syncdoc-type-hierarchy.el

index 2ffee0b6a851bc2ddad59c7841d956f8c414ba03..f68218b507a89f64a611a37d563d8963016212a8 100644 (file)
-                         +--------------------+
-                         |       bignum       |
-                         +--------------------+
-                           |
-                           |
-                           v
-     +-------------+     +--------------------+     +----------------------+     +--------+
-     |   fixnum    | --> |      integer       | --> |  integer-or-marker   | <-- | marker |
-     +-------------+     +--------------------+     +----------------------+     +--------+
-                           |                          |                            |
-                           |                          |                            |
-                           v                          |                            |
-     +-------------+     +--------------------+       |                            |
-     |    float    | --> |       number       |       |                            |
-     +-------------+     +--------------------+       |                            |
-                           |                          |                            |
-                           |                          |                            |
-                           v                          |                            |
-                         +--------------------+       |                            |            +------------------+          +--------------------+         +----------+           +--------+
-                         |  number-or-marker  | <-----+----------------------------+            | tree-sitter-node |          | tree-sitter-parser |         | user-ptr |           | window |
-                         +--------------------+       |                                         +------------------+          +--------------------+         +----------+           +--------+
-                           |                          |                                           |                             |                              |                      |
-                           |                          |                                           |                             |                              |                      |
-                           v                          v                                           v                             v                              v                      v
-     +-------------+     +-------------------------------------------------------------------------------------------------------------------------------------------------------------------+     +----------------------------+
-     | font-entity | --> |                                                                                                                                                                   | <-- |          overlay           |
-     +-------------+     |                                                                                                                                                                   |     +----------------------------+
-     +-------------+     |                                                                                                                                                                   |     +----------------------------+
-     | font-object | --> |                                                                                                                                                                   | <-- |          process           |
-     +-------------+     |                                                                                                                                                                   |     +----------------------------+
-     +-------------+     |                                                                                                                                                                   |     +----------------------------+
-     |  font-spec  | --> |                                                                                                                                                                   | <-- |         structure          |
-     +-------------+     |                                                                               atom                                                                                |     +----------------------------+
-     +-------------+     |                                                                                                                                                                   |     +----------------------------+
-     |    frame    | --> |                                                                                                                                                                   | <-- |          terminal          |
-     +-------------+     |                                                                                                                                                                   |     +----------------------------+
-     +-------------+     |                                                                                                                                                                   |     +----------------------------+
-     | hash-table  | --> |                                                                                                                                                                   | <-- |           thread           |
-     +-------------+     |                                                                                                                                                                   |     +----------------------------+
-     +-------------+     |                                                                                                                                                                   |     +----------------------------+
-     |    mutex    | --> |                                                                                                                                                                   | <-- | tree-sitter-compiled-query |
-     +-------------+     +-------------------------------------------------------------------------------------------------------------------------------------------------------------------+     +----------------------------+
-                           |                     ^    ^                       ^              ^                        ^                               ^                    ^
-                           |                     |    |                       |              |                        |                               |                    |
-                           v                     |    |                       |              |                        |                               |                    |
-                         +--------------------+  |  +----------------------+  |              |                      +--------+                      +-------+            +---------+
-  +--------------------> |         t          |  |  | window-configuration |  |              |                      | buffer |                      | class |            | condvar |
-  |                      +--------------------+  |  +----------------------+  |              |                      +--------+                      +-------+            +---------+
-  |                      +--------------------+  |                            |              |
-  |                      | byte-code-function |  |                            |              |
-  |                      +--------------------+  |                            |              |
-  |                        |                     |                            |              |
-  |                        |                     |                            |              |
-  |                        v                     |                            |              |
-  |                      +--------------------+  |                            |              |
-  |                      | compiled-function  |  |                            |              |
-  |                      +--------------------+  |                            |              |
-  |                        |                     |                            |              |
-  |                        |                     |                            |              |
-  |                        v                     |                            |              |
-  |                      +--------------------+  |                            |              |
-  |                   +> |      function      | -+                            |              |
-  |                   |  +--------------------+                               |              |
-  |                   |    ^                                                  |              |
-  |                   |    +--------------------------------------------------+--------------+------------------------+
-  |                   |                                                       |              |                        |
-  |                   |  +--------------------+                               |              |                        |
-  |                   |  |   subr-primitive   |                               |              |                        |
-  |                   |  +--------------------+                               |              |                        |
-  |                   |    |                                                  |              |                        |
-  |                   |    |                                                  |              |                        |
-  |                   |    v                                                  |              |                        |
-  |                   |  +--------------------+                               |              |                        |
-  |                   +- |        subr        | <-----------------------------+----+         |                        |
-  |                      +--------------------+                               |    |         |                        |
-  |                      +--------------------+                               |    |         |                        |
-  |                      |      keyword       | -+                            |    |         |                        |
-  |                      +--------------------+  |                            |    |         |                        |
-  |                        |                     |                            |    |         |                        |
-  |                        |                     |                            |    |         |                        |
-  |                        v                     |                            |    |         |                        |
-  |                      +--------------------+  |                            |    |         |                        |
-  |                      |  symbol-with-pos   |  |                            |    |         |                        |
-  |                      +--------------------+  |                            |    |         |                        |
-  |                        |                     |                            |    |         |                        |
-  |                        |                     +----+                       |    |         |                        |
-  |                        v                          |                       |    |         |                        |
-  |                      +--------------------+       |                       |    |         |                        |
-  |                   +> |       symbol       | ------+-----------------------+    |         |                        |
-  |                   |  +--------------------+       |                            |         |                        |
-  |                   |    ^                          |                            |         |                        |
-  |                   |    +--------------------------+                            |         |                        |
-  |                   |                                                            |         |                        |
-  |                   |  +--------------------+                                    |         |                        |
-  |                   |  |        null        | -+                                 |         |                        |
-  |                   |  +--------------------+  |                                 |         |                        |
-  |                   |    |                     |                                 |         |                        |
-  |                   |    |                     |                                 |         |                        |
-  |                   |    v                     |                                 |         |                        |
-  |                   |  +--------------------+  |                                 |         |                        |
-  |                   +- |      boolean       |  |                                 |         |                        |
-  |                      +--------------------+  |                                 |         |                        |
-  |                      +--------------------+  |                                 |         |                        |
-  |                      |        cons        |  |                                 |         |                        |
-  |                      +--------------------+  |                                 |         |                        |
-  |                        |                     |                                 |         |                        |
-  |                        |                     |                                 |         |                        |
-  |                        v                     |                                 |         |                        |
-  |                      +--------------------+  |                                 |         |                        |
-  |                      |        list        | <+                                 |         |                        |
-  |                      +--------------------+                                    |         |                        |
-  |                        |                                                       |         |                        |
-  |                        |                                                       |         |                        |
-  |                        v                                                       |         |                        |
-  |                      +--------------------+                                    |         |                        |
-  +--------------------- |      sequence      |                                    |         |                        |
-                         +--------------------+                                    |         |                        |
-                           ^                                                       |         |                        |
-  +------------------------+                                                       |         |                        |
-  |                                                                                |         |                        |
-  |                      +--------------------+                                    |         |                        |
-  |                      | subr-native-elisp  | -----------------------------------+         |                        |
-  |                      +--------------------+                                              |                        |
-  |                                                                                          |                        |
-  |                                              +-------------------------------------------+                        |
-  |                                              |                                                                    |
-  |                      +--------------------+  |                                                                    |
-  |                      |    bool-vector     |  |                                                                    |
-  |                      +--------------------+  |                                                                    |
-  |                        |                     |                                                                    |
-  |                        |                     |                                                                    |
-  |                        v                     |                                                                    |
-  |  +-------------+     +-------------------------------------------------+                                          |
-  |  |   string    | --> |                      array                      |                                          |
-  |  +-------------+     +-------------------------------------------------+                                          |
-  |                        ^                     |    ^                                                               |
-  |                        |                     |    |                                                               |
-  |                        |                     |    |                                                               |
-  |                      +--------------------+  |  +----------------------+                                          |
-  |                      |       vector       |  |  |      char-table      |                                          |
-  |                      +--------------------+  |  +----------------------+                                          |
-  |                                              |                                                                    |
-  +----------------------------------------------+                                                                    |
-                                                                                                                      |
-                         +--------------------+                                                                       |
-                         |  module-function   | ----------------------------------------------------------------------+
-                         +--------------------+
+| Type              | Derived Types                                            |
+|-------------------+----------------------------------------------------------|
+| t                 | sequence atom                                            |
+| sequence          | list array                                               |
+| atom              | class structure tree-sitter-compiled-query               |
+|                   | tree-sitter-node tree-sitter-parser user-ptr font-object |
+|                   | font-entity font-spec condvar mutex thread terminal      |
+|                   | hash-table frame buffer function window process          |
+|                   | window-configuration overlay integer-or-marker           |
+|                   | number-or-marker symbol array                            |
+| number            | float integer                                            |
+| number-or-marker  | marker number                                            |
+| integer           | bignum fixnum                                            |
+| symbol            | keyword boolean symbol-with-pos                          |
+| array             | vector bool-vector char-table string                     |
+| list              | null cons                                                |
+| integer-or-marker | integer marker                                           |
+| compiled-function | byte-code-function                                       |
+| function          | subr module-function compiled-function                   |
+| boolean           | null                                                     |
+| subr              | subr-native-elisp subr-primitive                         |
+| symbol-with-pos   | keyword                                                  |
index eebb092abaec2b7d43e0dc370723b10d72e3a51d..cd0cae2f95438df50a9587a3b4fa7f91c3694487 100644 (file)
@@ -35,6 +35,7 @@
 ;;; Code:
 
 (require 'cl-lib)
+(require 'org-table)
 
 (eval-and-compile
   (defconst syncdoc-lispref-dir (concat (file-name-directory
   (goto-char (point-max))
   (insert "}\n"))
 
+(defun syncdoc-make-type-table (file)
+  (with-temp-file file
+    (insert "|Type| Derived Types|\n|-\n")
+    (cl-loop for (type . children) in cl--type-hierarchy
+             do (insert "|" (symbol-name type) " |")
+             do (cl-loop with x = 0
+                         for child in children
+                         for child-len = (length (symbol-name child))
+                         when (> (+ x child-len 2) 60)
+                         do (progn
+                              (insert "|\n||")
+                              (setq x 0))
+                         do (insert (symbol-name child) " ")
+                         do (cl-incf x (1+ child-len)) )
+             do (insert "\n"))
+    (org-table-align)))
+
 (defun syncdoc-update-type-hierarchy ()
   "Update the type hierarchy representation used by the elisp manual."
   (interactive)
     (call-process-region nil nil "dot" t (current-buffer) nil "-Tjpg" "-o"
                          (expand-file-name "type_hierarchy.jpg"
                                            syncdoc-lispref-dir)))
-  (with-temp-buffer
-    (syncdoc-insert-dot-content "TB")
-    (call-process-region nil nil "graph-easy" t (current-buffer) nil "--output"
-                         (expand-file-name "type_hierarchy.txt"
-                                           syncdoc-lispref-dir))))
+  (syncdoc-make-type-table (expand-file-name "type_hierarchy.txt"
+                                             syncdoc-lispref-dir)))
 
 ;;; syncdoc-type-hierarchy.el ends here