« Module:Procédure » : différence entre les versions
Page créée avec « local Procedure = {} local p = {} function Procedure:new(title, script, description, level, sous_procedures) self.__index = self self.title = title self.script = script self.description = description if level ~= nil then self.level = level else self.level = 3 end if sous_procedure ~= nil then self.sous_procedures = sous_procedures else self.sous_procedures = {} end end function Procedure:bu... » |
Aucun résumé des modifications |
||
Ligne 2 : | Ligne 2 : | ||
local p = {} | local p = {} | ||
function Procedure:new(title, script, description, level, sous_procedures) | function Procedure:new(title, script, description, level, sous_procedures, arguments) | ||
self.__index = self | self.__index = self | ||
self.title = title | self.title = title | ||
Ligne 30 : | Ligne 30 : | ||
root:wikitext(string.rep("=", self.level) .. title .. string.rep("=", self.level)) | root:wikitext(string.rep("=", self.level) .. title .. string.rep("=", self.level)) | ||
if self.script ~= nil then | if self.script ~= nil then | ||
root:wikitext(self.script:build()) | root:wikitext(self.script:build(self.arguments)) | ||
end | end | ||
if self.description ~= nil then | if self.description ~= nil then | ||
Ligne 40 : | Ligne 40 : | ||
function p:main(frame) | function p:main(frame) | ||
local procedure = Procedure:new(frame.args[1], frame.args[2], frame.args[3], frame.args[4], frame.args[5]) | local procedure = Procedure:new(frame.args[1], frame.args[2], frame.args[3], frame.args[4], frame.args[5], frame.args[6]) | ||
return procedure:build() | return procedure:build() | ||
end | end | ||
return p | return p |
Dernière version du 4 mars 2025 à 02:39
La documentation pour ce module peut être créée à Module:Procédure/doc
local Procedure = {}
local p = {}
function Procedure:new(title, script, description, level, sous_procedures, arguments)
self.__index = self
self.title = title
self.script = script
self.description = description
if level ~= nil then
self.level = level
else
self.level = 3
end
if sous_procedure ~= nil then
self.sous_procedures = sous_procedures
else
self.sous_procedures = {}
end
end
function Procedure:build_sous_procedures()
local root = mw.html.create()
for _, sous_procedure in ipairs(self.sous_procedures) do
root:wikitext(sous_procedure:build())
end
end
function Procedure:build()
local root = mw.html.create()
root:wikitext(string.rep("=", self.level) .. title .. string.rep("=", self.level))
if self.script ~= nil then
root:wikitext(self.script:build(self.arguments))
end
if self.description ~= nil then
root:wikitext(self.description)
end
root:wikitext(self:build_sous_procedures())
return tostring(root)
end
function p:main(frame)
local procedure = Procedure:new(frame.args[1], frame.args[2], frame.args[3], frame.args[4], frame.args[5], frame.args[6])
return procedure:build()
end
return p