Module:WikiProjectBanner/autodocs
MyWikiBiz, Author Your Legacy — Saturday December 21, 2024
Jump to navigationJump to searchDocumentation for this module may be created at Module:WikiProjectBanner/autodocs/doc
local export = {} function export.render_docs(frame) local m_doc = require('Module:Documentation') local banner_name, is_templ = frame:getParent():getTitle():gsub("^Template:", "") banner_name = banner_name:match("^(.*)/sandbox$") or banner_name if is_templ == 0 then error("This module must be invoked from within a template") end if mw.title.getCurrentTitle().fullText ~= frame:getParent():getTitle() then error("This function must be invoked only on the banner page.") end local success, banner_config = pcall(require, "Module:WikiProjectBanner/config/" .. banner_name) if not success then return m_doc._main { content = ('<p class="plainlinks">The banner configuration at [[Module:WikiProjectBanner/config/%s]] does not exist. Please [%s create it].</p>'):format( banner_name, frame:callParserFunction('fullurl', 'Module:WikiProjectBanner/config/' .. banner_name, 'action=edit&editintro=Template:WikiProjectBanner-editintro&preload=Module:WikiProjectBanner/config-preload' ) ) } end local out = { root = mw.html.create('') } out.root:wikitext(":''The following documentation is generated automatically from [[Module:WikiProjectBanner/config/" .. banner_name .. "]].''\n") out.root:wikitext(":''The hooks page for this banner is [[Module:WikiProjectBanner/config/" .. banner_name .. "/hooks]].''\n") local template_data = { params = {}; sets = {}; } template_data.description = { en = "Banner template for " .. (banner_config.project_name or ("WikiProject " .. banner_config.project)) } -- collects categories needed for the template to operate normally local categories = {} -- TODO: assessment scale args for _, tf_info in ipairs(banner_config.task_forces or {}) do -- TODO: generate documentation for task force args end for _, nt_info in ipairs(banner_config.notices or {}) do -- TODO: generate documentation for notice args end for _, cat in ipairs(categories) do -- check if cat exists, show message if not end local m_json = require("Module:microJSON") return m_doc._main { content = tostring(out.root) .. "\n== [[mw:Extension:TemplateData|TemplateData]] documentation ==\n" .. frame:extensionTag("templatedata", m_json.encode_object(template_data, { description = { [true] = true }; params = { [true] = { label = { [true] = true }; description = { [true] = true }; aliases = { [0] = true }; }; }; sets = { [0] = { label = { [true] = true }; params = { [0] = true }; }; }; })) } end return export