PhantomCaleb (talk | contribs) mNo edit summary |
PhantomCaleb (talk | contribs) m (Protected "Module:UtilsPackage": Critical wiki page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
local utilsTable = require("Module:UtilsTable") |
local utilsTable = require("Module:UtilsTable") |
||
− | function p.submodules(submodules) |
+ | function p.submodules(submodules, sectionHeadings) |
local module = {} |
local module = {} |
||
local moduleDoc = {} |
local moduleDoc = {} |
||
− | for |
+ | for i, submodulePage in ipairs(submodules) do |
local submodule = require(submodulePage) |
local submodule = require(submodulePage) |
||
for exportKey, export in pairs(submodule) do |
for exportKey, export in pairs(submodule) do |
||
− | if exportKey == "Schemas" then |
+ | if module[exportKey] and exportKey ~= "Documentation" and exportKey ~= "Schemas" then |
− | module.Schema = utilsTable.merge({}, module.Schema, submodule.Schema) |
||
− | elseif module[exportKey] and exportKey ~= "Documentation" then |
||
mw.addWarning(string.format("Module conflict: <code>%s</code> is exported by more than one submodule.", exportKey)) |
mw.addWarning(string.format("Module conflict: <code>%s</code> is exported by more than one submodule.", exportKey)) |
||
end |
end |
||
module[exportKey] = export |
module[exportKey] = export |
||
end |
end |
||
− | moduleDoc[ |
+ | moduleDoc[i] = { |
+ | heading = sectionHeadings and sectionHeadings[i], |
||
+ | section = submodulePage, |
||
+ | } |
||
end |
end |
||
− | module.Documentation = moduleDoc |
+ | module.Documentation = { sections = moduleDoc } |
return module |
return module |
||
end |
end |
Revision as of 18:31, 4 August 2020
Documentation for this module may be created at Module:UtilsPackage/Documentation
local p = {}
local utilsTable = require("Module:UtilsTable")
function p.submodules(submodules, sectionHeadings)
local module = {}
local moduleDoc = {}
for i, submodulePage in ipairs(submodules) do
local submodule = require(submodulePage)
for exportKey, export in pairs(submodule) do
if module[exportKey] and exportKey ~= "Documentation" and exportKey ~= "Schemas" then
mw.addWarning(string.format("Module conflict: <code>%s</code> is exported by more than one submodule.", exportKey))
end
module[exportKey] = export
end
moduleDoc[i] = {
heading = sectionHeadings and sectionHeadings[i],
section = submodulePage,
}
end
module.Documentation = { sections = moduleDoc }
return module
end
return p