summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-09-06 20:18:00 +0000
committerSteven Barth <steven@midlink.org>2008-09-06 20:18:00 +0000
commita9875adb29da9f42da5e6e8839917a0b76d5c19d (patch)
tree6fb8bf8b3c4626bd109a0e58494a60fbe7f1cc6e /libs
parent72927597bc3c5a5817225dcb20cfe406e1c1bac5 (diff)
Merge branch 'uvldoc'
Diffstat (limited to 'libs')
-rw-r--r--libs/uvldoc/Makefile2
-rw-r--r--libs/uvldoc/luasrc/uvldoc/proto/xhtml/footer.xml9
-rw-r--r--libs/uvldoc/luasrc/uvldoc/proto/xhtml/header.xml15
-rw-r--r--libs/uvldoc/luasrc/uvldoc/proto/xhtml/index.xml11
-rw-r--r--libs/uvldoc/luasrc/uvldoc/proto/xhtml/menu.xml7
-rw-r--r--libs/uvldoc/luasrc/uvldoc/proto/xhtml/scheme.xml2
-rw-r--r--libs/uvldoc/luasrc/uvldoc/renderer.lua87
7 files changed, 133 insertions, 0 deletions
diff --git a/libs/uvldoc/Makefile b/libs/uvldoc/Makefile
new file mode 100644
index 000000000..81a96f6a8
--- /dev/null
+++ b/libs/uvldoc/Makefile
@@ -0,0 +1,2 @@
+include ../../build/config.mk
+include ../../build/module.mk \ No newline at end of file
diff --git a/libs/uvldoc/luasrc/uvldoc/proto/xhtml/footer.xml b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/footer.xml
new file mode 100644
index 000000000..5f8c0b9b4
--- /dev/null
+++ b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/footer.xml
@@ -0,0 +1,9 @@
+
+</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
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/libs/uvldoc/luasrc/uvldoc/proto/xhtml/header.xml b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/header.xml
new file mode 100644
index 000000000..9f18ad379
--- /dev/null
+++ b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/header.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <link rel="stylesheet" type="text/css" href="uvldoc.css" />
+ <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
+ <title>LuCI UVLDoc</title>
+</head>
+<body>
+
+<div id="menu">
+<%+menu.xml%>
+</div>
+
+<div id="content">
diff --git a/libs/uvldoc/luasrc/uvldoc/proto/xhtml/index.xml b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/index.xml
new file mode 100644
index 000000000..6fbfa374d
--- /dev/null
+++ b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/index.xml
@@ -0,0 +1,11 @@
+<%+header.xml%>
+<h1>UCI Documentation</h1>
+<table>
+<% for k, v in luci.util.kspairs(self.schemes) do %>
+<tr>
+ <td><a href="<%=self:_scheme_filename(k)%>"><%=k%></a></td>
+ <td><%=self.schemes[k].title%></td>
+</tr>
+<% end %>
+</table>
+<%+footer.xml%> \ No newline at end of file
diff --git a/libs/uvldoc/luasrc/uvldoc/proto/xhtml/menu.xml b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/menu.xml
new file mode 100644
index 000000000..402e6388e
--- /dev/null
+++ b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/menu.xml
@@ -0,0 +1,7 @@
+<h2>LuCI UVLDoc</h2>
+<ul>
+<li><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>
+<% end %>
+</ul> \ No newline at end of file
diff --git a/libs/uvldoc/luasrc/uvldoc/proto/xhtml/scheme.xml b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/scheme.xml
new file mode 100644
index 000000000..985809e77
--- /dev/null
+++ b/libs/uvldoc/luasrc/uvldoc/proto/xhtml/scheme.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
new file mode 100644
index 000000000..5fce5ec51
--- /dev/null
+++ b/libs/uvldoc/luasrc/uvldoc/renderer.lua
@@ -0,0 +1,87 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+local io = require "io"
+local fs = require "luci.fs"
+local uvl = require "luci.uvl"
+local util = require "luci.util"
+local ltn12 = require "luci.ltn12"
+local template = require "luci.template"
+
+local ipairs = ipairs
+
+module "luci.uvldoc.renderer"
+
+
+Generator = util.class()
+
+function Generator.__init__(self, schemes, output)
+ self.names = schemes
+ self.output = output or "doc"
+ self.schemes = {}
+ self.uvl = uvl.UVL()
+
+ self.extension = ".xml"
+ self.additionals = {"uvldoc.css"}
+ self.sourcedir = util.libpath() .. "/uvldoc/proto/xhtml/"
+end
+
+
+function Generator.make(self)
+ for i, scheme in ipairs(self.names) do
+ self.schemes[scheme] = self.uvl:get_scheme(scheme)
+ end
+
+ fs.mkdir(self.output)
+
+ for i, file in ipairs(self.additionals) do
+ fs.copy(self.sourcedir .. file, self.output)
+ end
+
+ template.compiler_mode = "memory"
+ template.viewdir = self.sourcedir
+
+ self:_make_index()
+
+ for scheme, file in util.kspairs(self.schemes) do
+ self:_make_package(scheme)
+ end
+end
+
+function Generator._make_index(self)
+ local t = template.Template("index.xml")
+ local sink = ltn12.sink.file(
+ io.open(self.output .. "/" .. self:_index_filename(), "w")
+ )
+ t:render({self = self, write = sink})
+ sink()
+end
+
+function Generator._make_package(self, scheme)
+ local t = template.Template("scheme.xml")
+ local sink = ltn12.sink.file(
+ io.open(self.output .. "/" .. self:_scheme_filename(scheme), "w")
+ )
+ t:render({self = self, package = self.schemes[scheme], scheme = scheme, 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