docs: initial Function in doctree

This commit is contained in:
Daniel Kolesa 2016-08-12 14:09:50 +01:00
parent ca3f418517
commit e0c0b12a94
3 changed files with 113 additions and 22 deletions

View File

@ -183,11 +183,15 @@ M.Class = Node:clone {
end, end,
functions_get = function(self, ft) functions_get = function(self, ft)
return self.class:functions_get(ft):to_array() local ret = {}
for fn in self.class:functions_get(ft) do
ret[#ret + 1] = M.Function(fn)
end
return ret
end, end,
function_get_by_name = function(self, fn, ft) function_get_by_name = function(self, fn, ft)
return self.class:function_get_by_name(fn, ft) return M.Function(self.class:function_get_by_name(fn, ft))
end, end,
events_get = function(self) events_get = function(self)
@ -238,6 +242,93 @@ M.Class = Node:clone {
end end
} }
M.Function = Node:clone {
__ctor = function(self, fn)
self.func = fn
assert(self.func)
end,
name_get = function(self)
return self.func:name_get()
end,
type_get = function(self)
return self.func:type_get()
end,
scope_get = function(self, ft)
return self.func:scope_get(ft)
end,
full_c_name_get = function(self, ft, legacy)
return self.func:full_c_name_get(ft, legacy)
end,
legacy_get = function(self, ft)
return self.func:legacy_get(ft)
end,
doc_get = function(self, ft)
return M.Doc(self.func:documentation_get(ft))
end,
is_virtual_pure = function(self, ft)
return self.func:is_virtual_pure(ft)
end,
is_auto = function(self, ft)
return self.func:is_auto(ft)
end,
is_empty = function(self, ft)
return self.func:is_empty(ft)
end,
is_legacy_only = function(self, ft)
return self.func:is_legacy_only(ft)
end,
is_class = function(self)
return self.func:is_class()
end,
is_c_only = function(self)
return self.func:is_c_only()
end,
property_keys_get = function(self, ft)
return self.func:property_keys_get(ft)
end,
property_values_get = function(self, ft)
return self.func:property_values_get(ft)
end,
parameters_get = function(self)
return self.func:parameters_get()
end,
return_type_get = function(self, ft)
return self.func:return_type_get(ft)
end,
return_default_value_get = function(self, ft)
return self.func:return_default_value_get(ft)
end,
return_doc_get = function(self, ft)
return M.Doc(self.func:return_documentation_get(ft))
end,
return_is_warn_unused = function(self, ft)
return self.func:return_is_warn_unused(ft)
end,
is_const = function(self)
return self.func:is_const()
end
}
M.Event = Node:clone { M.Event = Node:clone {
__ctor = function(self, ev) __ctor = function(self, ev)
self.event = ev self.event = ev

View File

@ -142,14 +142,14 @@ M.check_method = function(fn, cl)
local fts = eolian.function_type local fts = eolian.function_type
local fulln = cl:full_name_get() .. "." .. fn:name_get() local fulln = cl:full_name_get() .. "." .. fn:name_get()
if fn:return_type_get(fts.METHOD) then if fn:return_type_get(fts.METHOD) then
if not fn:return_documentation_get(fts.METHOD) then if not fn:return_doc_get(fts.METHOD):exists() then
print_missing(fulln, "method return") print_missing(fulln, "method return")
stat_incr("mret", true) stat_incr("mret", true)
else else
stat_incr("mret", false) stat_incr("mret", false)
end end
end end
if not fn:documentation_get(fts.METHOD) then if not fn:doc_get(fts.METHOD):exists() then
print_missing(fulln, "method") print_missing(fulln, "method")
stat_incr("method", true) stat_incr("method", true)
else else
@ -176,7 +176,7 @@ M.check_property = function(fn, cl, ft)
local fulln = cl:full_name_get() .. "." .. fn:name_get() local fulln = cl:full_name_get() .. "." .. fn:name_get()
if fn:return_type_get(ft) then if fn:return_type_get(ft) then
if not fn:return_documentation_get(ft) then if not fn:return_doc_get(ft):exists() then
print_missing(fulln, pfx .. "etter return") print_missing(fulln, pfx .. "etter return")
stat_incr(pfx .. "ret", true) stat_incr(pfx .. "ret", true)
else else
@ -184,7 +184,7 @@ M.check_property = function(fn, cl, ft)
end end
end end
if not fn:documentation_get(fts.PROPERTY) and not fn:documentation_get(ft) then if not fn:doc_get(fts.PROPERTY):exists() and not fn:doc_get(ft):exists() then
print_missing(fulln, pfx .. "etter") print_missing(fulln, pfx .. "etter")
stat_incr(pfx .. "etter", true) stat_incr(pfx .. "etter", true)
else else

View File

@ -22,18 +22,18 @@ local get_fallback_fdoc = function(f, ftype)
end end
end end
if ftype then if ftype then
return dtree.Doc(f:documentation_get(ftype)) return f:doc_get(ftype)
end end
return nil return nil
end end
local get_brief_fdoc = function(f, ftype) local get_brief_fdoc = function(f, ftype)
return dtree.Doc(f:documentation_get(eolian.function_type.METHOD)) return f:doc_get(eolian.function_type.METHOD)
:brief_get(get_fallback_fdoc(f, ftype)) :brief_get(get_fallback_fdoc(f, ftype))
end end
local get_full_fdoc = function(f, ftype) local get_full_fdoc = function(f, ftype)
return dtree.Doc(f:documentation_get(eolian.function_type.METHOD)) return f:doc_get(eolian.function_type.METHOD)
:full_get(get_fallback_fdoc(f, ftype)) :full_get(get_fallback_fdoc(f, ftype))
end end
@ -431,7 +431,7 @@ local build_ref = function()
end end
local write_full_fdoc = function(f, fn, ftype) local write_full_fdoc = function(f, fn, ftype)
f:write_raw(dtree.Doc(fn:documentation_get(eolian.function_type.METHOD)) f:write_raw(fn:doc_get(eolian.function_type.METHOD)
:full_get(get_fallback_fdoc(fn, ftype), true)) :full_get(get_fallback_fdoc(fn, ftype), true))
end end
@ -959,7 +959,7 @@ build_method = function(fn, cl)
end end
f:write_h("Description", 3) f:write_h("Description", 3)
f:write_raw(dtree.Doc(fn:documentation_get(eolian.function_type.METHOD)):full_get(nil, true)) f:write_raw(fn:doc_get(eolian.function_type.METHOD):full_get(nil, true))
f:write_nl() f:write_nl()
f:finish() f:finish()
@ -976,9 +976,9 @@ build_property = function(fn, cl)
if isget then stats.check_property(fn, cl, fts.PROP_GET) end if isget then stats.check_property(fn, cl, fts.PROP_GET) end
if isset then stats.check_property(fn, cl, fts.PROP_SET) end if isset then stats.check_property(fn, cl, fts.PROP_SET) end
local doc = fn:documentation_get(fts.PROPERTY) local doc = fn:doc_get(fts.PROPERTY)
local gdoc = fn:documentation_get(fts.PROP_GET) local gdoc = fn:doc_get(fts.PROP_GET)
local sdoc = fn:documentation_get(fts.PROP_SET) local sdoc = fn:doc_get(fts.PROP_SET)
f:write_h(cl:full_name_get() .. "." .. fn:name_get(), 2) f:write_h(cl:full_name_get() .. "." .. fn:name_get(), 2)
@ -1007,33 +1007,33 @@ build_property = function(fn, cl)
if isget and isset then if isget and isset then
f:write_h("Description", 3) f:write_h("Description", 3)
if doc or (not gdoc and not sdoc) then if doc:exists() or (not gdoc:exists() and not sdoc:exists()) then
f:write_raw(dtree.Doc(doc):full_get(nil, true)) f:write_raw(doc:full_get(nil, true))
end end
if (isget and gdoc) or (isset and sdoc) then if (isget and gdoc:exists()) or (isset and sdoc:exists()) then
f:write_nl(2) f:write_nl(2)
end end
end end
if isget and gdoc then if isget and gdoc:exists() then
if isset then if isset then
f:write_h("Getter", 4) f:write_h("Getter", 4)
else else
f:write_h("Description", 3) f:write_h("Description", 3)
end end
f:write_raw(dtree.Doc(gdoc):full_get(nil, true)) f:write_raw(gdoc:full_get(nil, true))
if isset and sdoc then if isset and sdoc:exists() then
f:write_nl(2) f:write_nl(2)
end end
end end
if isset and sdoc then if isset and sdoc:exists() then
if isget then if isget then
f:write_h("Setter", 4) f:write_h("Setter", 4)
else else
f:write_h("Description", 3) f:write_h("Description", 3)
end end
f:write_raw(dtree.Doc(sdoc):full_get(nil, true)) f:write_raw(sdoc:full_get(nil, true))
end end
f:write_nl() f:write_nl()