docs: theme string retrieval for doctree classes

This commit is contained in:
Daniel Kolesa 2016-08-12 13:51:39 +01:00
parent 79935e1ab3
commit ca3f418517
2 changed files with 16 additions and 16 deletions

View File

@ -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)

View File

@ -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"]