<h2>LuCI UVLDoc</h2>
<ul>
-<li><a href="<%=self:_index_filename()%>">Index</a></li>
+<li<%-if not scheme then%> class="menu-active"<%-end-%>>
+ <a href="<%=self:_index_filename()%>">Index</a>
+</li>
<% for k, v in luci.util.kspairs(self.schemes) do %>
-<li><a href="<%=self:_scheme_filename(k)%>"><%=k%></a></li>
+<li<%-if scheme == k then%> class="menu-active"<%-end-%>>
+ <a href="<%=self:_scheme_filename(k)%>"><%=k%></a>
+ <%-if scheme == k then-%>
+ <ul>
+ <%-for k2, v2 in luci.util.kspairs(v.sections) do-%>
+ <li>
+ <a href="<%=self:_section_filename(k, k2)%>"><%=k2%></a>
+ </li>
+ <%-end-%>
+ </ul>
+ <%-end-%>
+</li>
<% end %>
</ul>
\ No newline at end of file
local ltn12 = require "luci.ltn12"
local template = require "luci.template"
-local ipairs = ipairs
+local ipairs, getfenv, pairs, require = ipairs, getfenv, pairs, require
+local luci = luci
module "luci.uvldoc.renderer"
template.compiler_mode = "memory"
template.viewdir = self.sourcedir
+ template.context.viewns = {
+ include = function(name) template.Template(name):render(getfenv(2)) end,
+ luci = luci,
+ require = require
+ }
self:_make_index()
- for scheme, file in util.kspairs(self.schemes) do
+ for scheme, package in pairs(self.schemes) do
self:_make_package(scheme)
+ for type, section in pairs(package.sections) do
+ self:_make_section(scheme, type)
+ end
end
end
sink()
end
+function Generator._make_section(self, scheme, section)
+ local t = template.Template("section.xml")
+ local sink = ltn12.sink.file(
+ io.open(self.output .. "/" .. self:_section_filename(scheme, section), "w")
+ )
+ local pkg = self.schemes[scheme]
+ t:render({self = self, package = pkg,
+ scheme = scheme, type=section, section=pkg.sections[section],
+ write = sink})
+ sink()
+end
+
function Generator._index_filename(self)
return "index%s" % self.extension
end
function Generator._scheme_filename(self, scheme)
return "scheme.%s%s" % {scheme, self.extension}
end
+
+function Generator._section_filename(self, scheme, section)
+ return "section.%s.%s%s" % {scheme, section, self.extension}
+end