From aaa1e2b0ec58370d9ffaef0002e5f68c65185e30 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Tue, 10 May 2016 18:11:24 +0100 Subject: [PATCH] docgen: basic doc generation for types --- gendoc.lua | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/gendoc.lua b/gendoc.lua index db201e8..4abb298 100644 --- a/gendoc.lua +++ b/gendoc.lua @@ -812,7 +812,7 @@ local get_typedecl_str = function(tp) local tpt = tp:type_get() if tpt == tps.UNKNOWN then error("unknown typedecl: " .. tp:full_name_get()) - elseif tpt == tps.STRUCT or tpt == tps.STURCT_OPAQUE then + elseif tpt == tps.STRUCT or tpt == tps.STRUCT_OPAQUE then local buf = { "struct " } add_typedecl_attrs(tp, buf) buf[#buf + 1] = tp:full_name_get() @@ -848,8 +848,11 @@ local get_typedecl_str = function(tp) for i, fld in ipairs(fields) do buf[#buf + 1] = " " buf[#buf + 1] = fld:name_get() - buf[#buf + 1] = ": " - buf[#buf + 1] = fld:value_get():serialize() + local val = fld:value_get() + if val then + buf[#buf + 1] = ": " + buf[#buf + 1] = val:serialize() + end if i == #fields then buf[#buf + 1] = "\n" else @@ -1479,10 +1482,24 @@ local build_classes = function() end end +local write_tsigs = function(f, tp) + f:write_h(tp:full_name_get(), 2) + + f:write_h("Signature", 3) + f:write_code(get_typedecl_str(tp)) + f:write_nl() + + f:write_h("C signature", 3) + f:write_code(tp:c_type_get() .. ";") + f:write_nl() +end + local build_alias = function(tp) local f = Writer(gen_nsp_eo(tp, "alias")) check_alias(tp) + write_tsigs(f, tp) + f:finish() end @@ -1490,6 +1507,8 @@ local build_struct = function(tp) local f = Writer(gen_nsp_eo(tp, "struct")) check_struct(tp) + write_tsigs(f, tp) + f:finish() end @@ -1497,6 +1516,8 @@ local build_enum = function(tp) local f = Writer(gen_nsp_eo(tp, "enum")) check_enum(tp) + write_tsigs(f, tp) + f:finish() end -- 2.7.4