forked from enlightenment/efl
docs: abstract away class types within doctree
This commit is contained in:
parent
452b6557aa
commit
79935e1ab3
|
@ -3,7 +3,9 @@ local util = require("util")
|
||||||
local eolian = require("eolian")
|
local eolian = require("eolian")
|
||||||
|
|
||||||
local dutil = require("docgen.util")
|
local dutil = require("docgen.util")
|
||||||
local writer = require("docgen.writer")
|
|
||||||
|
-- writer has to be loaded late to prevent cycles
|
||||||
|
local writer
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
@ -11,6 +13,9 @@ local Node = util.Object:clone {
|
||||||
}
|
}
|
||||||
|
|
||||||
local gen_doc_refd = function(str)
|
local gen_doc_refd = function(str)
|
||||||
|
if not writer then
|
||||||
|
writer = require("docgen.writer")
|
||||||
|
end
|
||||||
if not str then
|
if not str then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
@ -22,6 +27,9 @@ local gen_doc_refd = function(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
local add_since = function(str, since)
|
local add_since = function(str, since)
|
||||||
|
if not writer then
|
||||||
|
writer = require("docgen.writer")
|
||||||
|
end
|
||||||
if not since then
|
if not since then
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
@ -119,6 +127,13 @@ local classt_to_str = {
|
||||||
}
|
}
|
||||||
|
|
||||||
M.Class = Node:clone {
|
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)
|
__ctor = function(self, cl)
|
||||||
self.class = cl
|
self.class = cl
|
||||||
assert(self.class)
|
assert(self.class)
|
||||||
|
@ -140,6 +155,10 @@ M.Class = Node:clone {
|
||||||
return self.class:type_get()
|
return self.class:type_get()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
type_str_get = function(self)
|
||||||
|
return classt_to_str[self:type_get()]
|
||||||
|
end,
|
||||||
|
|
||||||
doc_get = function(self)
|
doc_get = function(self)
|
||||||
return M.Doc(self.class:documentation_get())
|
return M.Doc(self.class:documentation_get())
|
||||||
end,
|
end,
|
||||||
|
@ -177,7 +196,7 @@ M.Class = Node:clone {
|
||||||
for i = 1, #tbl do
|
for i = 1, #tbl do
|
||||||
tbl[i] = tbl[i]:lower()
|
tbl[i] = tbl[i]:lower()
|
||||||
end
|
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()
|
tbl[#tbl + 1] = self:name_get():lower()
|
||||||
if root then
|
if root then
|
||||||
tbl[#tbl + 1] = true
|
tbl[#tbl + 1] = true
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
local eolian = require("eolian")
|
local eolian = require("eolian")
|
||||||
|
local dtree = require("docgen.doctree")
|
||||||
|
|
||||||
local M = {}
|
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 = {
|
M.funct_to_str = {
|
||||||
[eolian.function_type.PROPERTY] = "property",
|
[eolian.function_type.PROPERTY] = "property",
|
||||||
[eolian.function_type.PROP_GET] = "property",
|
[eolian.function_type.PROP_GET] = "property",
|
||||||
|
@ -40,7 +34,7 @@ local decl_to_nspace = function(decl)
|
||||||
if ns then
|
if ns then
|
||||||
return ns
|
return ns
|
||||||
elseif decl:type_get() == dt.CLASS then
|
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
|
if not ret then
|
||||||
error("unknown class type for class '" .. decl:name_get() .. "'")
|
error("unknown class type for class '" .. decl:name_get() .. "'")
|
||||||
end
|
end
|
||||||
|
|
|
@ -117,7 +117,7 @@ local print_missing = function(name, tp)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.check_class = function(cl)
|
M.check_class = function(cl)
|
||||||
local ct = eomap.classt_to_str[cl:type_get()]
|
local ct = cl:type_str_get()
|
||||||
if not ct then
|
if not ct then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -395,15 +395,13 @@ local build_ref = function()
|
||||||
local ifaces = {}
|
local ifaces = {}
|
||||||
local mixins = {}
|
local mixins = {}
|
||||||
|
|
||||||
local clt = eolian.class_type
|
|
||||||
|
|
||||||
for i, cl in ipairs(dtree.Class.all_get()) do
|
for i, cl in ipairs(dtree.Class.all_get()) do
|
||||||
local tp = cl:type_get()
|
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
|
classes[#classes + 1] = cl
|
||||||
elseif tp == clt.MIXIN then
|
elseif tp == dtree.Class.MIXIN then
|
||||||
mixins[#mixins + 1] = cl
|
mixins[#mixins + 1] = cl
|
||||||
elseif tp == clt.INTERFACE then
|
elseif tp == dtree.Class.INTERFACE then
|
||||||
ifaces[#ifaces + 1] = cl
|
ifaces[#ifaces + 1] = cl
|
||||||
else
|
else
|
||||||
error("unknown class: " .. cl:full_name_get())
|
error("unknown class: " .. cl:full_name_get())
|
||||||
|
@ -444,7 +442,7 @@ build_inherits = function(cl, t, lvl)
|
||||||
local lbuf = writer.Buffer()
|
local lbuf = writer.Buffer()
|
||||||
lbuf:write_link(cl:nspaces_get(true), cl:full_name_get())
|
lbuf:write_link(cl:nspaces_get(true), cl:full_name_get())
|
||||||
lbuf:write_raw(" ")
|
lbuf:write_raw(" ")
|
||||||
lbuf:write_i("(" .. eomap.classt_to_str[cl:type_get()] .. ")")
|
lbuf:write_i("(" .. cl:type_str_get() .. ")")
|
||||||
if lvl == 0 then
|
if lvl == 0 then
|
||||||
lbuf:write_b(lbuf:finish())
|
lbuf:write_b(lbuf:finish())
|
||||||
end
|
end
|
||||||
|
@ -670,10 +668,10 @@ local set_theme = function(tname)
|
||||||
end
|
end
|
||||||
|
|
||||||
local classt_to_theme = {
|
local classt_to_theme = {
|
||||||
[eolian.class_type.REGULAR] = "regular",
|
[dtree.Class.REGULAR] = "regular",
|
||||||
[eolian.class_type.ABSTRACT] = "abstract",
|
[dtree.Class.ABSTRACT] = "abstract",
|
||||||
[eolian.class_type.MIXIN] = "mixin",
|
[dtree.Class.MIXIN] = "mixin",
|
||||||
[eolian.class_type.INTERFACE] = "interface"
|
[dtree.Class.INTERFACE] = "interface"
|
||||||
}
|
}
|
||||||
|
|
||||||
local class_to_node = function(cl, main)
|
local class_to_node = function(cl, main)
|
||||||
|
@ -786,8 +784,7 @@ end
|
||||||
|
|
||||||
local build_classes = function()
|
local build_classes = function()
|
||||||
for i, cl in ipairs(dtree.Class.all_get()) do
|
for i, cl in ipairs(dtree.Class.all_get()) do
|
||||||
local ct = cl:type_get()
|
if not cl:type_str_get() then
|
||||||
if not eomap.classt_to_str[ct] then
|
|
||||||
error("unknown class: " .. cl:full_name_get())
|
error("unknown class: " .. cl:full_name_get())
|
||||||
end
|
end
|
||||||
build_class(cl)
|
build_class(cl)
|
||||||
|
|
Loading…
Reference in New Issue