uvldoc: Added preliminary section support, optimized menu generating
This commit is contained in:
parent
a4a77446e9
commit
52c9166a7a
4 changed files with 45 additions and 5 deletions
|
@ -2,7 +2,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="copy">
|
<div id="copy">
|
||||||
generated on <%=os.date("%c")%> with <a href="http://luci.freifunk-halle.net"><abbr title="Lua Configuration Interface">LuCI</abbr> UVLDoc</a> - written by Steven Barth and Jo-Philipp Wich
|
generated on <%=require "os".date("%c")%> with <a href="http://luci.freifunk-halle.net"><abbr title="Lua Configuration Interface">LuCI</abbr> UVLDoc</a> - written by Steven Barth and Jo-Philipp Wich
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1,7 +1,20 @@
|
||||||
<h2>LuCI UVLDoc</h2>
|
<h2>LuCI UVLDoc</h2>
|
||||||
<ul>
|
<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 %>
|
<% 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 %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
2
libs/uvldoc/luasrc/uvldoc/proto/xhtml/section.xml
Normal file
2
libs/uvldoc/luasrc/uvldoc/proto/xhtml/section.xml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<%+header.xml%>
|
||||||
|
<%+footer.xml%>
|
|
@ -20,7 +20,8 @@ local util = require "luci.util"
|
||||||
local ltn12 = require "luci.ltn12"
|
local ltn12 = require "luci.ltn12"
|
||||||
local template = require "luci.template"
|
local template = require "luci.template"
|
||||||
|
|
||||||
local ipairs = ipairs
|
local ipairs, getfenv, pairs, require = ipairs, getfenv, pairs, require
|
||||||
|
local luci = luci
|
||||||
|
|
||||||
module "luci.uvldoc.renderer"
|
module "luci.uvldoc.renderer"
|
||||||
|
|
||||||
|
@ -52,11 +53,19 @@ function Generator.make(self)
|
||||||
|
|
||||||
template.compiler_mode = "memory"
|
template.compiler_mode = "memory"
|
||||||
template.viewdir = self.sourcedir
|
template.viewdir = self.sourcedir
|
||||||
|
template.context.viewns = {
|
||||||
|
include = function(name) template.Template(name):render(getfenv(2)) end,
|
||||||
|
luci = luci,
|
||||||
|
require = require
|
||||||
|
}
|
||||||
|
|
||||||
self:_make_index()
|
self:_make_index()
|
||||||
|
|
||||||
for scheme, file in util.kspairs(self.schemes) do
|
for scheme, package in pairs(self.schemes) do
|
||||||
self:_make_package(scheme)
|
self:_make_package(scheme)
|
||||||
|
for type, section in pairs(package.sections) do
|
||||||
|
self:_make_section(scheme, type)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -78,6 +87,18 @@ function Generator._make_package(self, scheme)
|
||||||
sink()
|
sink()
|
||||||
end
|
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)
|
function Generator._index_filename(self)
|
||||||
return "index%s" % self.extension
|
return "index%s" % self.extension
|
||||||
end
|
end
|
||||||
|
@ -85,3 +106,7 @@ end
|
||||||
function Generator._scheme_filename(self, scheme)
|
function Generator._scheme_filename(self, scheme)
|
||||||
return "scheme.%s%s" % {scheme, self.extension}
|
return "scheme.%s%s" % {scheme, self.extension}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Generator._section_filename(self, scheme, section)
|
||||||
|
return "section.%s.%s%s" % {scheme, section, self.extension}
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue