From ca3f41851753598d90c31255c453a1268962d0e0 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Fri, 12 Aug 2016 13:51:39 +0100 Subject: [PATCH] docs: theme string retrieval for doctree classes --- src/scripts/elua/apps/docgen/doctree.lua | 23 +++++++++++++++-------- src/scripts/elua/apps/gendoc.lua | 9 +-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua index c489b63de9..f3428eb299 100644 --- a/src/scripts/elua/apps/docgen/doctree.lua +++ b/src/scripts/elua/apps/docgen/doctree.lua @@ -119,13 +119,6 @@ M.Doc = Node:clone { end } -local classt_to_str = { - [eolian.class_type.REGULAR] = "class", - [eolian.class_type.ABSTRACT] = "class", - [eolian.class_type.MIXIN] = "mixin", - [eolian.class_type.INTERFACE] = "interface" -} - M.Class = Node:clone { -- class types UNKNOWN = eolian.class_type.UNKNOWN, @@ -156,7 +149,21 @@ M.Class = Node:clone { end, type_str_get = function(self) - return classt_to_str[self:type_get()] + return ({ + [eolian.class_type.REGULAR] = "class", + [eolian.class_type.ABSTRACT] = "class", + [eolian.class_type.MIXIN] = "mixin", + [eolian.class_type.INTERFACE] = "interface" + })[self:type_get()] + end, + + theme_str_get = function(self) + return ({ + [eolian.class_type.REGULAR] = "regular", + [eolian.class_type.ABSTRACT] = "abstract", + [eolian.class_type.MIXIN] = "mixin", + [eolian.class_type.INTERFACE] = "interface" + })[self:type_get()] end, doc_get = function(self) diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua index 042d4a57aa..9833bcd4ac 100644 --- a/src/scripts/elua/apps/gendoc.lua +++ b/src/scripts/elua/apps/gendoc.lua @@ -667,20 +667,13 @@ local set_theme = function(tname) end end -local classt_to_theme = { - [dtree.Class.REGULAR] = "regular", - [dtree.Class.ABSTRACT] = "abstract", - [dtree.Class.MIXIN] = "mixin", - [dtree.Class.INTERFACE] = "interface" -} - local class_to_node = function(cl, main) local ret = {} ret.label = cl:full_name_get() ret.name = ret.label:lower():gsub("%.", "_") - local clr = classt_to_theme[cl:type_get()] + local clr = cl:theme_str_get() ret.style = current_theme.classes[clr].style ret.color = current_theme.classes[clr][main and "primary_color" or "color"]