docs: add writer support for include plugin

This commit is contained in:
Daniel Kolesa 2016-08-18 14:50:24 +01:00
parent 36d086ec42
commit 8ff134472e
1 changed files with 36 additions and 0 deletions

View File

@ -15,6 +15,11 @@ M.has_feature = function(fname)
end
M.Writer = util.Object:clone {
INCLUDE_PAGE = 0,
INCLUDE_SECTION = 1,
INCLUDE_NAMESPACE = 2,
INCLUDE_TAG = 3,
__ctor = function(self, path)
local subs
if type(path) == "table" then
@ -45,6 +50,37 @@ M.Writer = util.Object:clone {
return self
end,
write_include = function(self, tp, name, flags, nonl)
local it_to_tp = {
[self.INCLUDE_PAGE] = "page",
[self.INCLUDE_SECTION] = "section",
[self.INCLUDE_NAMESPACE] = "namespace",
[self.INCLUDE_TAG] = "tagtopic"
}
self:write_raw("{{", it_to_tp[tp], ">", name);
if flags then
if tp == self.INCLUDE_SECTION and flags.section then
self:write_raw("#", flags.section)
end
flags.section = nil
local flstr = {}
for k, v in ipairs(flags) do
if v then
flstr[#flstr + 1] = k
end
end
flstr = table.concat(flstr, "&")
if #flstr > 0 then
self:write_raw("&", flstr)
end
end
self:write_raw("}}")
if not nonl then
self:write_nl()
end
return self
end,
write_fmt = function(self, fmt1, fmt2, ...)
self:write_raw(fmt1, ...)
self:write_raw(fmt2)