summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-08-10 15:54:11 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-08-10 15:54:11 +0100
commit88edaa768c8a8221ff1b2cabe4f75151d94dcbfd (patch)
treedc061bd89f4b83add08b69a82bc5f33f04b662cb
parenta3945c9986c114de12d89513694031e25f598ceb (diff)
downloadefl-88edaa768c8a8221ff1b2cabe4f75151d94dcbfd.tar.gz
docs: unified feature testing in writer api
-rw-r--r--src/scripts/elua/apps/docgen/writer.lua27
-rw-r--r--src/scripts/elua/apps/gendoc.lua14
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 42f31b1f42..9683edff04 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 1d128d7d10..b778ab4284 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()