forked from enlightenment/efl
docs: generate reference pages for codelink
This commit is contained in:
parent
feafdb85a4
commit
4d701bca2e
|
@ -1008,7 +1008,7 @@ M.Typedecl = Node:clone {
|
||||||
error("unhandled typedecl type: " .. tpt)
|
error("unhandled typedecl type: " .. tpt)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
serialize_c = function(self)
|
serialize_c = function(self, ns)
|
||||||
local tpt = self:type_get()
|
local tpt = self:type_get()
|
||||||
if tpt == self.UNKNOWN then
|
if tpt == self.UNKNOWN then
|
||||||
error("unknown typedecl: " .. self:full_name_get())
|
error("unknown typedecl: " .. self:full_name_get())
|
||||||
|
@ -1016,7 +1016,7 @@ M.Typedecl = Node:clone {
|
||||||
tpt == self.STRUCT_OPAQUE then
|
tpt == self.STRUCT_OPAQUE then
|
||||||
local buf = { "typedef struct " }
|
local buf = { "typedef struct " }
|
||||||
local fulln = self:full_name_get():gsub("%.", "_");
|
local fulln = self:full_name_get():gsub("%.", "_");
|
||||||
keyref.add(fulln, "c")
|
keyref.add(fulln, ns, "c")
|
||||||
buf[#buf + 1] = "_" .. fulln;
|
buf[#buf + 1] = "_" .. fulln;
|
||||||
if tpt == self.STRUCT_OPAQUE then
|
if tpt == self.STRUCT_OPAQUE then
|
||||||
buf[#buf + 1] = " " .. fulln .. ";"
|
buf[#buf + 1] = " " .. fulln .. ";"
|
||||||
|
@ -1038,7 +1038,7 @@ M.Typedecl = Node:clone {
|
||||||
elseif tpt == self.ENUM then
|
elseif tpt == self.ENUM then
|
||||||
local buf = { "typedef enum" }
|
local buf = { "typedef enum" }
|
||||||
local fulln = self:full_name_get():gsub("%.", "_");
|
local fulln = self:full_name_get():gsub("%.", "_");
|
||||||
keyref.add(fulln, "c")
|
keyref.add(fulln, ns, "c")
|
||||||
local fields = self:enum_fields_get()
|
local fields = self:enum_fields_get()
|
||||||
if #fields == 0 then
|
if #fields == 0 then
|
||||||
buf[#buf + 1] = " {} " .. fulln .. ";"
|
buf[#buf + 1] = " {} " .. fulln .. ";"
|
||||||
|
@ -1049,7 +1049,7 @@ M.Typedecl = Node:clone {
|
||||||
buf[#buf + 1] = " "
|
buf[#buf + 1] = " "
|
||||||
local cn = fld:c_name_get()
|
local cn = fld:c_name_get()
|
||||||
buf[#buf + 1] = cn
|
buf[#buf + 1] = cn
|
||||||
keyref.add(cn, "c")
|
keyref.add(cn, ns, "c")
|
||||||
local val = fld:value_get()
|
local val = fld:value_get()
|
||||||
if val then
|
if val then
|
||||||
buf[#buf + 1] = " = "
|
buf[#buf + 1] = " = "
|
||||||
|
@ -1071,7 +1071,7 @@ M.Typedecl = Node:clone {
|
||||||
return table.concat(buf)
|
return table.concat(buf)
|
||||||
elseif tpt == self.ALIAS then
|
elseif tpt == self.ALIAS then
|
||||||
local fulln = self:full_name_get():gsub("%.", "_");
|
local fulln = self:full_name_get():gsub("%.", "_");
|
||||||
keyref.add(fulln, "c")
|
keyref.add(fulln, ns, "c")
|
||||||
return "typedef "
|
return "typedef "
|
||||||
.. M.type_cstr_get(self:base_type_get(), fulln) .. ";"
|
.. M.type_cstr_get(self:base_type_get(), fulln) .. ";"
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,13 +2,13 @@ local M = {}
|
||||||
|
|
||||||
local key_refs = {}
|
local key_refs = {}
|
||||||
|
|
||||||
M.add = function(key, lang)
|
M.add = function(key, link, lang)
|
||||||
local rfs = key_refs[lang]
|
local rfs = key_refs[lang]
|
||||||
if not rfs then
|
if not rfs then
|
||||||
key_refs[lang] = {}
|
key_refs[lang] = {}
|
||||||
rfs = key_refs[lang]
|
rfs = key_refs[lang]
|
||||||
end
|
end
|
||||||
rfs[key] = true
|
rfs[key] = link
|
||||||
end
|
end
|
||||||
|
|
||||||
M.build = function()
|
M.build = function()
|
||||||
|
@ -19,6 +19,9 @@ M.build = function()
|
||||||
local arr = {}
|
local arr = {}
|
||||||
for refn, v in pairs(rfs) do
|
for refn, v in pairs(rfs) do
|
||||||
arr[#arr + 1] = refn
|
arr[#arr + 1] = refn
|
||||||
|
local rf = writer.Writer({ "ref", lang, "key", refn })
|
||||||
|
v[#v + 1] = true
|
||||||
|
rf:write_include(rf.INCLUDE_PAGE, v)
|
||||||
end
|
end
|
||||||
table.sort(arr)
|
table.sort(arr)
|
||||||
f:write_raw(table.concat(arr, "\n"))
|
f:write_raw(table.concat(arr, "\n"))
|
||||||
|
@ -26,7 +29,8 @@ M.build = function()
|
||||||
f:finish()
|
f:finish()
|
||||||
local lf = writer.Writer({ "ref", lang, "keyword-link" })
|
local lf = writer.Writer({ "ref", lang, "keyword-link" })
|
||||||
lf:write_raw("/", dutil.path_join(
|
lf:write_raw("/", dutil.path_join(
|
||||||
dutil.get_root(), "ref", lang, "key", "{FNAME}"
|
dutil.nspace_to_path(dutil.get_root_ns()),
|
||||||
|
"ref", lang, "key", "{FNAME}"
|
||||||
))
|
))
|
||||||
lf:write_nl()
|
lf:write_nl()
|
||||||
lf:finish()
|
lf:finish()
|
||||||
|
|
|
@ -26,7 +26,7 @@ M.make_page = function(path)
|
||||||
return M.path_join(doc_root, path .. ".txt")
|
return M.path_join(doc_root, path .. ".txt")
|
||||||
end
|
end
|
||||||
|
|
||||||
M.get_root = function()
|
M.get_root_ns = function()
|
||||||
return root_ns
|
return root_ns
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ end
|
||||||
|
|
||||||
M.init = function(root, rns)
|
M.init = function(root, rns)
|
||||||
doc_root = root:gsub(rep_sep, path_sep)
|
doc_root = root:gsub(rep_sep, path_sep)
|
||||||
root_ns = rns:gsub(rep_sep, path_sep)
|
root_ns = rns
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -85,6 +85,15 @@ M.Writer = util.Object:clone {
|
||||||
[self.INCLUDE_NAMESPACE] = "namespace",
|
[self.INCLUDE_NAMESPACE] = "namespace",
|
||||||
[self.INCLUDE_TAG] = "tagtopic"
|
[self.INCLUDE_TAG] = "tagtopic"
|
||||||
}
|
}
|
||||||
|
if type(name) == "table" then
|
||||||
|
if name[#name] == true then
|
||||||
|
name[#name] = nil
|
||||||
|
name = ":" .. root_nspace .. ":"
|
||||||
|
.. table.concat(name, ":")
|
||||||
|
else
|
||||||
|
name = table.concat(name, ":")
|
||||||
|
end
|
||||||
|
end
|
||||||
self:write_raw("{{", it_to_tp[tp], ">", name);
|
self:write_raw("{{", it_to_tp[tp], ">", name);
|
||||||
if flags then
|
if flags then
|
||||||
if tp == self.INCLUDE_SECTION and flags.section then
|
if tp == self.INCLUDE_SECTION and flags.section then
|
||||||
|
|
|
@ -31,12 +31,12 @@ local get_func_csig_part = function(cn, tp)
|
||||||
return dtree.type_cstr_get(tp, cn)
|
return dtree.type_cstr_get(tp, cn)
|
||||||
end
|
end
|
||||||
|
|
||||||
local gen_func_csig = function(f, ftype)
|
local gen_func_csig = function(f, ns, ftype)
|
||||||
ftype = ftype or f.METHOD
|
ftype = ftype or f.METHOD
|
||||||
assert(ftype ~= f.PROPERTY)
|
assert(ftype ~= f.PROPERTY)
|
||||||
|
|
||||||
local cn = f:full_c_name_get(ftype)
|
local cn = f:full_c_name_get(ftype)
|
||||||
keyref.add(cn, "c")
|
keyref.add(cn, ns, "c")
|
||||||
local rtype = f:return_type_get(ftype)
|
local rtype = f:return_type_get(ftype)
|
||||||
|
|
||||||
local fparam = "Eo *obj"
|
local fparam = "Eo *obj"
|
||||||
|
@ -688,11 +688,12 @@ local build_igraph = function(cl)
|
||||||
end
|
end
|
||||||
|
|
||||||
local build_class = function(cl)
|
local build_class = function(cl)
|
||||||
local f = writer.Writer(cl:nspaces_get())
|
local cln = cl:nspaces_get()
|
||||||
|
local f = writer.Writer(cln)
|
||||||
stats.check_class(cl)
|
stats.check_class(cl)
|
||||||
|
|
||||||
f:write_h(cl:full_name_get(), 2)
|
f:write_h(cl:full_name_get(), 2)
|
||||||
keyref.add(cl:full_name_get():gsub("%.", "_"), "c")
|
keyref.add(cl:full_name_get():gsub("%.", "_"), cln, "c")
|
||||||
|
|
||||||
f:write_folded("Inheritance graph", function()
|
f:write_folded("Inheritance graph", function()
|
||||||
f:write_graph(build_igraph(cl))
|
f:write_graph(build_igraph(cl))
|
||||||
|
@ -743,7 +744,7 @@ local build_classes = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local write_tsigs = function(f, tp)
|
local write_tsigs = function(f, tp, ns)
|
||||||
f:write_h(tp:full_name_get(), 2)
|
f:write_h(tp:full_name_get(), 2)
|
||||||
|
|
||||||
f:write_h("Signature", 3)
|
f:write_h("Signature", 3)
|
||||||
|
@ -751,15 +752,16 @@ local write_tsigs = function(f, tp)
|
||||||
f:write_nl()
|
f:write_nl()
|
||||||
|
|
||||||
f:write_h("C signature", 3)
|
f:write_h("C signature", 3)
|
||||||
f:write_code(tp:serialize_c(), "c")
|
f:write_code(tp:serialize_c(ns), "c")
|
||||||
f:write_nl()
|
f:write_nl()
|
||||||
end
|
end
|
||||||
|
|
||||||
local build_alias = function(tp)
|
local build_alias = function(tp)
|
||||||
local f = writer.Writer(dtree.Node.nspaces_get(tp, "alias"))
|
local ns = dtree.Node.nspaces_get(tp, "alias")
|
||||||
|
local f = writer.Writer(ns)
|
||||||
stats.check_alias(tp)
|
stats.check_alias(tp)
|
||||||
|
|
||||||
write_tsigs(f, tp)
|
write_tsigs(f, tp, ns)
|
||||||
|
|
||||||
f:write_h("Description", 3)
|
f:write_h("Description", 3)
|
||||||
f:write_raw(tp:doc_get():full_get(nil, true))
|
f:write_raw(tp:doc_get():full_get(nil, true))
|
||||||
|
@ -769,10 +771,11 @@ local build_alias = function(tp)
|
||||||
end
|
end
|
||||||
|
|
||||||
local build_struct = function(tp)
|
local build_struct = function(tp)
|
||||||
local f = writer.Writer(dtree.Node.nspaces_get(tp, "struct"))
|
local ns = dtree.Node.nspaces_get(tp, "struct")
|
||||||
|
local f = writer.Writer(ns)
|
||||||
stats.check_struct(tp)
|
stats.check_struct(tp)
|
||||||
|
|
||||||
write_tsigs(f, tp)
|
write_tsigs(f, tp, ns)
|
||||||
|
|
||||||
f:write_h("Description", 3)
|
f:write_h("Description", 3)
|
||||||
f:write_raw(tp:doc_get():full_get(nil, true))
|
f:write_raw(tp:doc_get():full_get(nil, true))
|
||||||
|
@ -794,10 +797,11 @@ local build_struct = function(tp)
|
||||||
end
|
end
|
||||||
|
|
||||||
local build_enum = function(tp)
|
local build_enum = function(tp)
|
||||||
local f = writer.Writer(dtree.Node.nspaces_get(tp, "enum"))
|
local ns = dtree.Node.nspaces_get(tp, "enum")
|
||||||
|
local f = writer.Writer(ns)
|
||||||
stats.check_enum(tp)
|
stats.check_enum(tp)
|
||||||
|
|
||||||
write_tsigs(f, tp)
|
write_tsigs(f, tp, ns)
|
||||||
|
|
||||||
f:write_h("Description", 3)
|
f:write_h("Description", 3)
|
||||||
f:write_raw(tp:doc_get():full_get(nil, true))
|
f:write_raw(tp:doc_get():full_get(nil, true))
|
||||||
|
@ -897,7 +901,8 @@ local build_vallist = function(f, pg, ps, title)
|
||||||
end
|
end
|
||||||
|
|
||||||
build_method = function(fn, cl)
|
build_method = function(fn, cl)
|
||||||
local f = writer.Writer(fn:nspaces_get(cl))
|
local mns = fn:nspaces_get(cl)
|
||||||
|
local f = writer.Writer(mns)
|
||||||
stats.check_method(fn, cl)
|
stats.check_method(fn, cl)
|
||||||
|
|
||||||
f:write_h(cl:full_name_get() .. "." .. fn:name_get(), 2)
|
f:write_h(cl:full_name_get() .. "." .. fn:name_get(), 2)
|
||||||
|
@ -907,7 +912,7 @@ build_method = function(fn, cl)
|
||||||
f:write_nl()
|
f:write_nl()
|
||||||
|
|
||||||
f:write_h("C signature", 3)
|
f:write_h("C signature", 3)
|
||||||
f:write_code(gen_func_csig(fn), "c")
|
f:write_code(gen_func_csig(fn, mns), "c")
|
||||||
f:write_nl()
|
f:write_nl()
|
||||||
|
|
||||||
local pars = fn:parameters_get()
|
local pars = fn:parameters_get()
|
||||||
|
@ -925,7 +930,8 @@ build_method = function(fn, cl)
|
||||||
end
|
end
|
||||||
|
|
||||||
build_property = function(fn, cl)
|
build_property = function(fn, cl)
|
||||||
local f = writer.Writer(fn:nspaces_get(cl))
|
local pns = fn:nspaces_get(cl)
|
||||||
|
local f = writer.Writer(pns)
|
||||||
|
|
||||||
local ft = fn:type_get()
|
local ft = fn:type_get()
|
||||||
local isget = (ft == fn.PROP_GET or ft == fn.PROPERTY)
|
local isget = (ft == fn.PROP_GET or ft == fn.PROPERTY)
|
||||||
|
@ -947,10 +953,10 @@ build_property = function(fn, cl)
|
||||||
f:write_h("C signature", 3)
|
f:write_h("C signature", 3)
|
||||||
local codes = {}
|
local codes = {}
|
||||||
if isget then
|
if isget then
|
||||||
codes[#codes + 1] = gen_func_csig(fn, fn.PROP_GET)
|
codes[#codes + 1] = gen_func_csig(fn, pns, fn.PROP_GET)
|
||||||
end
|
end
|
||||||
if isset then
|
if isset then
|
||||||
codes[#codes + 1] = gen_func_csig(fn, fn.PROP_SET)
|
codes[#codes + 1] = gen_func_csig(fn, pns, fn.PROP_SET)
|
||||||
end
|
end
|
||||||
f:write_code(table.concat(codes, "\n"), "c")
|
f:write_code(table.concat(codes, "\n"), "c")
|
||||||
f:write_nl()
|
f:write_nl()
|
||||||
|
@ -999,7 +1005,8 @@ build_property = function(fn, cl)
|
||||||
end
|
end
|
||||||
|
|
||||||
build_event = function(ev, cl)
|
build_event = function(ev, cl)
|
||||||
local f = writer.Writer(ev:nspaces_get(cl))
|
local evn = ev:nspaces_get(cl)
|
||||||
|
local f = writer.Writer(evn)
|
||||||
|
|
||||||
f:write_h(cl:full_name_get() .. ": " .. ev:name_get(), 2)
|
f:write_h(cl:full_name_get() .. ": " .. ev:name_get(), 2)
|
||||||
|
|
||||||
|
@ -1034,7 +1041,7 @@ build_event = function(ev, cl)
|
||||||
|
|
||||||
f:write_h("C signature", 3)
|
f:write_h("C signature", 3)
|
||||||
local cn = ev:c_name_get()
|
local cn = ev:c_name_get()
|
||||||
keyref.add(cn, "c")
|
keyref.add(cn, evn, "c")
|
||||||
f:write_code(dtree.type_cstr_get(etp, cn) .. ";", "c")
|
f:write_code(dtree.type_cstr_get(etp, cn) .. ";", "c")
|
||||||
f:write_nl()
|
f:write_nl()
|
||||||
|
|
||||||
|
@ -1085,9 +1092,8 @@ getopt.parse {
|
||||||
else
|
else
|
||||||
dr = opts["r"]
|
dr = opts["r"]
|
||||||
end
|
end
|
||||||
local pns = dutil.nspace_to_path(rootns)
|
dr = dutil.path_join(dr, dutil.nspace_to_path(rootns))
|
||||||
dr = dutil.path_join(dr, pns)
|
dutil.init(dr, rootns)
|
||||||
dutil.init(dr, pns)
|
|
||||||
if #args == 0 then
|
if #args == 0 then
|
||||||
dtree.scan_directory()
|
dtree.scan_directory()
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue