q66 pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=88edaa768c8a8221ff1b2cabe4f75151d94dcbfd
commit 88edaa768c8a8221ff1b2cabe4f75151d94dcbfd Author: Daniel Kolesa <d.kol...@osg.samsung.com> Date: Wed Aug 10 15:54:11 2016 +0100 docs: unified feature testing in writer api --- src/scripts/elua/apps/docgen/writer.lua | 27 ++++++++++++++------------- src/scripts/elua/apps/gendoc.lua | 14 +++++++------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/scripts/elua/apps/docgen/writer.lua b/src/scripts/elua/apps/docgen/writer.lua index 42f31b1..9683edf 100644 --- a/src/scripts/elua/apps/docgen/writer.lua +++ b/src/scripts/elua/apps/docgen/writer.lua @@ -5,7 +5,14 @@ local dutil = require("docgen.util") local M = {} -local root_nspace, use_notes, use_folds, use_dot +local root_nspace, features + +M.has_feature = function(fname) + if not features then + return false + end + return not not features[fname] +end M.Writer = util.Object:clone { __ctor = function(self, path) @@ -125,7 +132,7 @@ M.Writer = util.Object:clone { end, write_graph = function(self, tbl) - if not use_dot then + if not M.has_feature("dot") then return self end self:write_raw("<graphviz>\n") @@ -288,7 +295,7 @@ M.Writer = util.Object:clone { end, write_par = function(self, str) - local notetypes = use_notes and { + local notetypes = M.has_feature("notes") and { ["Note: "] = "<note>\n", ["Warning: "] = "<note warning>\n", ["Remark: "] = "<note tip>\n", @@ -313,11 +320,11 @@ M.Writer = util.Object:clone { end, write_folded = function(self, title, func) - if use_folds then + if M.has_feature("folds") then self:write_raw("++++ ", title, " |\n\n") end func(self) - if use_folds then + if M.has_feature("folds") then self:write_raw("\n\n++++") end return self @@ -347,15 +354,9 @@ M.Buffer = M.Writer:clone { end } -M.init = function(root_ns, notes, folds, dot) +M.init = function(root_ns, ftrs) root_nspace = root_ns - use_notes = notes - use_folds = folds - use_dot = dot -end - -M.has_dot = function() - return use_dot + features = ftrs end return M diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua index 1d128d7..b778ab4 100644 --- a/src/scripts/elua/apps/gendoc.lua +++ b/src/scripts/elua/apps/gendoc.lua @@ -744,7 +744,7 @@ local build_class = function(cl) f:write_folded("Inheritance graph", function() f:write_graph(build_igraph(cl)) end) - if writer.has_dot() then + if writer.has_feature("dot") then f:write_nl(2) end @@ -1154,12 +1154,12 @@ getopt.parse { error("failed parsing eo files") end stats.init(not not opts["v"]) - writer.init( - rootns, - not opts["disable-notes"], - not opts["disable-folded"], - not opts["disable-graphviz"] - ) + local wfeatures = { + notes = not opts["disable-notes"], + folds = not opts["disable-folded"], + dot = not opts["disable-graphviz"] + } + writer.init(rootns, wfeatures) dutil.rm_root() dutil.mkdir_r(nil) build_ref() --