浏览代码

fix: schema.org classes missing from tree

also fix typos
Gabriel Horner 2 年之前
父节点
当前提交
22d1cb54c5
共有 2 个文件被更改,包括 14 次插入2 次删除
  1. 13 1
      scripts/src/logseq/tasks/db_graph/create_graph_with_schema_org.cljs
  2. 1 1
      typos.toml

+ 13 - 1
scripts/src/logseq/tasks/db_graph/create_graph_with_schema_org.cljs

@@ -37,7 +37,15 @@
                        (vector? parent-class*)
                        (do (when verbose
                              (println "Picked first class for multi-parent class" (pr-str (class-m "@id"))))
-                           (get (first parent-class*) "@id")))
+                           (get (first parent-class*) "@id"))
+                       ;; DataTypes are weird in that they are subclassed from
+                       ;; rdfs:class but that info is omitted. It seems schema
+                       ;; does this on purpose to display it as a separate tree but
+                       ;; we want all classes under one tree
+                       (contains? (set (as-> (class-m "@type") type'
+                                         (if (string? type') [type'] type')))
+                                  "schema:DataType")
+                       "schema:DataType")
         properties (sort (class-properties (class-m "@id")))]
     (cond-> {:block/original-name (string/replace-first (class-m "@id") "schema:" "")
              :block/type "class"
@@ -166,6 +174,10 @@
         pages (mapv #(hash-map :page
                                (->class-page % class-db-ids class-uuids class-to-properties property-uuids options))
                     select-classes)]
+    (assert (= ["Thing"] (keep #(when-not (:block/namespace (:page %))
+                                  (:block/original-name (:page %)))
+                               pages))
+            "Thing is the only class that doesn't have a parent class")
     pages))
 
 (defn- generate-properties

+ 1 - 1
typos.toml

@@ -14,4 +14,4 @@ aks = "aks"
 Mannor = "Mannor"
 nd = "nd"
 [files]
-extend-exclude = ["resources/*", "src/resources/*"]
+extend-exclude = ["resources/*", "src/resources/*", "scripts/resources/*"]