docs: initial Class in doctree

This commit is contained in:
Daniel Kolesa 2016-08-11 15:48:55 +01:00
parent aaf29b4dc4
commit d53c622795
3 changed files with 98 additions and 11 deletions

View File

@ -1,5 +1,7 @@
local util = require("util")
local eolian = require("eolian")
local dutil = require("docgen.util")
local writer = require("docgen.writer")
local eomap = require("docgen.mappings")
@ -103,6 +105,91 @@ M.Doc = Node:clone {
return add_since(gen_doc_refd(sum1 .. edoc), since)
end
return add_since(gen_doc_refd(sum1 .. "\n\n" .. desc1 .. edoc), since)
end,
exists = function(self)
return not not self.doc
end
}
M.Class = Node:clone {
__ctor = function(self, cl)
self.class = cl
assert(self.class)
end,
full_name_get = function(self)
return self.class:full_name_get()
end,
name_get = function(self)
return self.class:name_get()
end,
namespaces_get = function(self)
return self.class:namespaces_get()--:to_array()
end,
type_get = function(self)
return self.class:type_get()
end,
doc_get = function(self)
return M.Doc(self.class:documentation_get())
end,
legacy_prefix_get = function(self)
return self.class:legacy_prefix_get()
end,
eo_prefix_get = function(self)
return self.class:eo_prefix_get()
end,
inherits_get = function(self)
return self.class:inherits_get()--:to_array()
end,
functions_get = function(self, ft)
return self.class:functions_get(ft)--:to_array()
end,
function_get_by_name = function(self, fn, ft)
return self.class:function_get_by_name(fn, ft)
end,
events_get = function(self)
return self.class:events_get()--:to_array()
end,
c_get_function_name_get = function(self)
return self.class:c_get_function_name_get()
end,
-- static getters
by_name_get = function(name)
local v = eolian.class_get_by_name(name)
if not v then
return nil
end
return M.Class(v)
end,
by_file_get = function(name)
local v = eolian.class_get_by_file(name)
if not v then
return nil
end
return M.Class(v)
end,
all_get = function()
local ret = {}
for cl in eolian.all_classes_get() do
ret[#ret + 1] = M.Class(cl)
end
return ret
end
}

View File

@ -121,7 +121,7 @@ M.check_class = function(cl)
if not ct then
return
end
if not cl:documentation_get() then
if not cl:doc_get():exists() then
print_missing(cl:full_name_get(), ct)
stat_incr(ct, true)
else

View File

@ -338,7 +338,7 @@ end
local build_method, build_property, build_event
local build_reftable = function(f, title, ctitle, ctype, t)
local build_reftable = function(f, title, ctitle, ctype, t, iscl)
if not t or #t == 0 then
return
end
@ -348,7 +348,7 @@ local build_reftable = function(f, title, ctitle, ctype, t)
nt[#nt + 1] = {
writer.Buffer():write_link(eomap.gen_nsp_eo(v, ctype, true),
v:full_name_get()):finish(),
dtree.Doc(v:documentation_get()):brief_get()
(iscl and v:doc_get() or dtree.Doc(v:documentation_get())):brief_get()
}
end
table.sort(nt, function(v1, v2) return v1[1] < v2[1] end)
@ -395,7 +395,7 @@ local build_ref = function()
local clt = eolian.class_type
for cl in eolian.all_classes_get() do
for i, cl in ipairs(dtree.Class.all_get()) do
local tp = cl:type_get()
if tp == clt.REGULAR or tp == clt.ABSTRACT then
classes[#classes + 1] = cl
@ -408,9 +408,9 @@ local build_ref = function()
end
end
build_reftable(f, "Classes", "Class name", "class", classes)
build_reftable(f, "Interfaces", "Interface name", "interface", ifaces)
build_reftable(f, "Mixins", "Mixin name", "mixin", mixins)
build_reftable(f, "Classes", "Class name", "class", classes, true)
build_reftable(f, "Interfaces", "Interface name", "interface", ifaces, true)
build_reftable(f, "Mixins", "Mixin name", "mixin", mixins, true)
build_reftable(f, "Aliases", "Alias name", "alias",
eolian.typedecl_all_aliases_get():to_array())
@ -448,7 +448,7 @@ build_inherits = function(cl, t, lvl)
end
t[#t + 1] = { lvl, lbuf:finish() }
for cln in cl:inherits_get() do
local acl = eolian.class_get_by_name(cln)
local acl = dtree.Class.by_name_get(cln)
if not acl then
error("error retrieving inherited class " .. cln)
end
@ -701,7 +701,7 @@ local build_igraph_r
build_igraph_r = function(cl, nbuf, ibuf)
local sn = cl:full_name_get():lower():gsub("%.", "_")
for cln in cl:inherits_get() do
local acl = eolian.class_get_by_name(cln)
local acl = dtree.Class.by_name_get(cln)
if not acl then
error("error retrieving inherited class " .. cln)
end
@ -753,7 +753,7 @@ local build_class = function(cl)
f:write_nl()
f:write_h("Description", 3)
f:write_raw(dtree.Doc(cl:documentation_get()):full_get(nil, true))
f:write_raw(cl:doc_get():full_get(nil, true))
f:write_nl(2)
build_functable(f, "Methods", "Method name", cl, eolian.function_type.METHOD)
@ -783,7 +783,7 @@ local build_class = function(cl)
end
local build_classes = function()
for cl in eolian.all_classes_get() do
for i, cl in ipairs(dtree.Class.all_get()) do
local ct = cl:type_get()
if not eomap.classt_to_str[ct] then
error("unknown class: " .. cl:full_name_get())