From c8a25492c30af967bbfef5f078a8424698df2375 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Thu, 7 Apr 2016 14:41:27 +0100 Subject: [PATCH] docgen: cleaner code block generation --- gendoc.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gendoc.lua b/gendoc.lua index a18f474..51cfa41 100644 --- a/gendoc.lua +++ b/gendoc.lua @@ -118,6 +118,11 @@ local Writer = util.Object:clone { return self end, + write_code = function(self, str, lang) + lang = lang and (" " .. lang) or "" + self:write_raw("\n", str, "\n") + end, + write_link = function(self, target, title) if not title then self:write_raw("[[", target:lower(), "|", target, "]]") @@ -547,7 +552,7 @@ build_method = function(fn, cl) f:write_h(fn:name_get(), 2) f:write_h("C signature", 3) - f:write_raw("\n", gen_func_csig(fn), "\n\n") + f:write_code(gen_func_csig(fn), "c") f:write_h("Description", 3) write_full_doc(f, fn:documentation_get(eolian.function_type.METHOD)) @@ -572,14 +577,14 @@ build_property = function(fn, cl) f:write_h(fn:name_get(), 2) f:write_h("C signature", 3) - f:write_raw("\n") + local codes = {} if isget then - f:write_raw(gen_func_csig(fn, fts.PROP_GET), "\n") + codes[#codes + 1] = gen_func_csig(fn, fts.PROP_GET) end if isset then - f:write_raw(gen_func_csig(fn, fts.PROP_SET), "\n") + codes[#codes + 1] = gen_func_csig(fn, fts.PROP_SET) end - f:write_raw("\n") + f:write_code(table.concat(codes, "\n"), "c") if isget and isset then f:write_h("Description", 3) -- 2.7.4