diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/uvldoc/luasrc/uvldoc/proto/xhtml/footer.xml | 2 | ||||
-rw-r--r-- | libs/uvldoc/luasrc/uvldoc/proto/xhtml/menu.xml | 17 | ||||
-rw-r--r-- | libs/uvldoc/luasrc/uvldoc/proto/xhtml/section.xml | 2 | ||||
-rw-r--r-- | libs/uvldoc/luasrc/uvldoc/renderer.lua | 29 |
4 files changed, 45 insertions, 5 deletions
diff --git a/libs/uvldoc/luasrc/uvldoc/proto/xhtml/footer.xml b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/footer.xml index 5f8c0b9b4..d353ced18 100644 --- a/libs/uvldoc/luasrc/uvldoc/proto/xhtml/footer.xml +++ b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/footer.xml @@ -2,7 +2,7 @@ </div> <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> </body> diff --git a/libs/uvldoc/luasrc/uvldoc/proto/xhtml/menu.xml b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/menu.xml index 402e6388e..7a0300269 100644 --- a/libs/uvldoc/luasrc/uvldoc/proto/xhtml/menu.xml +++ b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/menu.xml @@ -1,7 +1,20 @@ <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 diff --git a/libs/uvldoc/luasrc/uvldoc/proto/xhtml/section.xml b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/section.xml new file mode 100644 index 000000000..985809e77 --- /dev/null +++ b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/section.xml @@ -0,0 +1,2 @@ +<%+header.xml%> +<%+footer.xml%>
\ No newline at end of file diff --git a/libs/uvldoc/luasrc/uvldoc/renderer.lua b/libs/uvldoc/luasrc/uvldoc/renderer.lua index 5fce5ec51..f881032c2 100644 --- a/libs/uvldoc/luasrc/uvldoc/renderer.lua +++ b/libs/uvldoc/luasrc/uvldoc/renderer.lua @@ -20,7 +20,8 @@ local util = require "luci.util" 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" @@ -52,11 +53,19 @@ function Generator.make(self) 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 @@ -78,6 +87,18 @@ function Generator._make_package(self, scheme) 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 @@ -85,3 +106,7 @@ 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 |