q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=79935e1ab3b0839caeeeb6e0f7e5dec2ee468880

commit 79935e1ab3b0839caeeeb6e0f7e5dec2ee468880
Author: Daniel Kolesa <d.kol...@osg.samsung.com>
Date:   Fri Aug 12 13:35:57 2016 +0100

    docs: abstract away class types within doctree
---
 src/scripts/elua/apps/docgen/doctree.lua  | 23 +++++++++++++++++++++--
 src/scripts/elua/apps/docgen/mappings.lua | 10 ++--------
 src/scripts/elua/apps/docgen/stats.lua    |  2 +-
 src/scripts/elua/apps/gendoc.lua          | 21 +++++++++------------
 4 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/src/scripts/elua/apps/docgen/doctree.lua 
b/src/scripts/elua/apps/docgen/doctree.lua
index 8b90f59..c489b63 100644
--- a/src/scripts/elua/apps/docgen/doctree.lua
+++ b/src/scripts/elua/apps/docgen/doctree.lua
@@ -3,7 +3,9 @@ local util = require("util")
 local eolian = require("eolian")
 
 local dutil = require("docgen.util")
-local writer = require("docgen.writer")
+
+-- writer has to be loaded late to prevent cycles
+local writer
 
 local M = {}
 
@@ -11,6 +13,9 @@ local Node = util.Object:clone {
 }
 
 local gen_doc_refd = function(str)
+    if not writer then
+        writer = require("docgen.writer")
+    end
     if not str then
         return nil
     end
@@ -22,6 +27,9 @@ local gen_doc_refd = function(str)
 end
 
 local add_since = function(str, since)
+    if not writer then
+        writer = require("docgen.writer")
+    end
     if not since then
         return str
     end
@@ -119,6 +127,13 @@ local classt_to_str = {
 }
 
 M.Class = Node:clone {
+    -- class types
+    UNKNOWN = eolian.class_type.UNKNOWN,
+    REGULAR = eolian.class_type.REGULAR,
+    ABSTRACT = eolian.class_type.ABSTRACT,
+    MIXIN = eolian.class_type.MIXIN,
+    INTERFACE = eolian.class_type.INTERFACE,
+
     __ctor = function(self, cl)
         self.class = cl
         assert(self.class)
@@ -140,6 +155,10 @@ M.Class = Node:clone {
         return self.class:type_get()
     end,
 
+    type_str_get = function(self)
+        return classt_to_str[self:type_get()]
+    end,
+
     doc_get = function(self)
         return M.Doc(self.class:documentation_get())
     end,
@@ -177,7 +196,7 @@ M.Class = Node:clone {
         for i = 1, #tbl do
             tbl[i] = tbl[i]:lower()
         end
-        table.insert(tbl, 1, classt_to_str[self.class:type_get()])
+        table.insert(tbl, 1, self:type_str_get())
         tbl[#tbl + 1] = self:name_get():lower()
         if root then
             tbl[#tbl + 1] = true
diff --git a/src/scripts/elua/apps/docgen/mappings.lua 
b/src/scripts/elua/apps/docgen/mappings.lua
index 9f56b6f..66648ae 100644
--- a/src/scripts/elua/apps/docgen/mappings.lua
+++ b/src/scripts/elua/apps/docgen/mappings.lua
@@ -1,14 +1,8 @@
 local eolian = require("eolian")
+local dtree = require("docgen.doctree")
 
 local M = {}
 
-M.classt_to_str = {
-    [eolian.class_type.REGULAR] = "class",
-    [eolian.class_type.ABSTRACT] = "class",
-    [eolian.class_type.MIXIN] = "mixin",
-    [eolian.class_type.INTERFACE] = "interface"
-}
-
 M.funct_to_str = {
     [eolian.function_type.PROPERTY] = "property",
     [eolian.function_type.PROP_GET] = "property",
@@ -40,7 +34,7 @@ local decl_to_nspace = function(decl)
     if ns then
         return ns
     elseif decl:type_get() == dt.CLASS then
-        local ret = M.classt_to_str[decl:class_get():type_get()]
+        local ret = dtree.Class(decl:class_get()):type_str_get()
         if not ret then
             error("unknown class type for class '" .. decl:name_get() .. "'")
         end
diff --git a/src/scripts/elua/apps/docgen/stats.lua 
b/src/scripts/elua/apps/docgen/stats.lua
index 323add2..f9d6fb6 100644
--- a/src/scripts/elua/apps/docgen/stats.lua
+++ b/src/scripts/elua/apps/docgen/stats.lua
@@ -117,7 +117,7 @@ local print_missing = function(name, tp)
 end
 
 M.check_class = function(cl)
-    local ct = eomap.classt_to_str[cl:type_get()]
+    local ct = cl:type_str_get()
     if not ct then
         return
     end
diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua
index 1a275b7..042d4a5 100644
--- a/src/scripts/elua/apps/gendoc.lua
+++ b/src/scripts/elua/apps/gendoc.lua
@@ -395,15 +395,13 @@ local build_ref = function()
     local ifaces = {}
     local mixins = {}
 
-    local clt = eolian.class_type
-
     for i, cl in ipairs(dtree.Class.all_get()) do
         local tp = cl:type_get()
-        if tp == clt.REGULAR or tp == clt.ABSTRACT then
+        if tp == dtree.Class.REGULAR or tp == dtree.Class.ABSTRACT then
             classes[#classes + 1] = cl
-        elseif tp == clt.MIXIN then
+        elseif tp == dtree.Class.MIXIN then
             mixins[#mixins + 1] = cl
-        elseif tp == clt.INTERFACE then
+        elseif tp == dtree.Class.INTERFACE then
             ifaces[#ifaces + 1] = cl
         else
             error("unknown class: " .. cl:full_name_get())
@@ -444,7 +442,7 @@ build_inherits = function(cl, t, lvl)
     local lbuf = writer.Buffer()
     lbuf:write_link(cl:nspaces_get(true), cl:full_name_get())
     lbuf:write_raw(" ")
-    lbuf:write_i("(" .. eomap.classt_to_str[cl:type_get()] .. ")")
+    lbuf:write_i("(" .. cl:type_str_get() .. ")")
     if lvl == 0 then
         lbuf:write_b(lbuf:finish())
     end
@@ -670,10 +668,10 @@ local set_theme = function(tname)
 end
 
 local classt_to_theme = {
-    [eolian.class_type.REGULAR] = "regular",
-    [eolian.class_type.ABSTRACT] = "abstract",
-    [eolian.class_type.MIXIN] = "mixin",
-    [eolian.class_type.INTERFACE] = "interface"
+    [dtree.Class.REGULAR] = "regular",
+    [dtree.Class.ABSTRACT] = "abstract",
+    [dtree.Class.MIXIN] = "mixin",
+    [dtree.Class.INTERFACE] = "interface"
 }
 
 local class_to_node = function(cl, main)
@@ -786,8 +784,7 @@ end
 
 local build_classes = function()
     for i, cl in ipairs(dtree.Class.all_get()) do
-        local ct = cl:type_get()
-        if not eomap.classt_to_str[ct] then
+        if not cl:type_str_get() then
             error("unknown class: " .. cl:full_name_get())
         end
         build_class(cl)

-- 


Reply via email to