From 52c9166a7abe947662fe03d1051e2d05e64f4f18 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Tue, 9 Sep 2008 21:55:54 +0000 Subject: uvldoc: Added preliminary section support, optimized menu generating --- libs/uvldoc/luasrc/uvldoc/proto/xhtml/footer.xml | 2 +- libs/uvldoc/luasrc/uvldoc/proto/xhtml/menu.xml | 17 +++++++++++-- libs/uvldoc/luasrc/uvldoc/proto/xhtml/section.xml | 2 ++ libs/uvldoc/luasrc/uvldoc/renderer.lua | 29 +++++++++++++++++++++-- 4 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 libs/uvldoc/luasrc/uvldoc/proto/xhtml/section.xml (limited to 'libs/uvldoc') 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 @@
-generated on <%=os.date("%c")%> with LuCI UVLDoc - written by Steven Barth and Jo-Philipp Wich +generated on <%=require "os".date("%c")%> with LuCI UVLDoc - written by Steven Barth and Jo-Philipp Wich
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 @@

LuCI UVLDoc

\ 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 -- cgit v1.2.3