Module:Documentacion
Apparence
En francês : Ce module implémente le modèle {{Mèta documentacion de modèlo}}. Voir la page du modèle pour les instructions d'utilisation.
Fonctions exportables
documentation(frame)
– Fonction principale du module – à appeler avec#invoke
dans un modèle – renvoyant le code HTML de la documentation._documentation(args)
– Fonction subsidiaire du module – à appeler avecrequire()
dans un autre module – et renvoyant le code HTML de la documentation.
Autres fonctions
existePage(page)
– Teste si une page existe.nomSouspage(page, souspage)
– Renvoie le nom d'une sous-page, en tenant compte des cas où l'on se trouverait déjà dans une sous-page "/Documentation", "/Bac à sable" ou "/Test".lienUrl(nomPage, texteLien, action, pagePreload)
– Retourne un lien wikifié vers la page nomPage, affichant le texte texteLien, avec possibilité d'ajouter des query string (paramètre action) et un preload (paramètre pagePreload).entete(args, page, doc, existeDoc)
– Construit l'entête de la documentation contenant l'image de documentation, le titre, et les liens de création/modification/purge.protection(page, doc, existeDoc, message)
– Construit le bandeau indiquant la protection de la page le cas échéant.retireBalisesCategories(contenuDoc)
- Permet d'ignorer les balises de catégories lors de l'inclusion d'une page de doc pour les bacs à sables.contenu(args, titreDoc, existeDoc)
– Retourne la concaténation de la documentation en dur, sans cadre vert. C'est cette méthode qui génère la sous-page /Documentation rédigée par l'utilisateur.notice(args, page, doc, existeDoc)
– Retourne la notice de la documentation situé en bas de page.
Exemples et tests
- Pour des exemples, voir la page de test permettant de tester diverses modifications apportées.
- Module:Documentation/Bac à sable, {{Documentation/Bac à sable}} et {{Documentation/Test}} permettent de tester diverses modifications apportées dans une version bac à sable.
--Ceti modulo emplèmente lo modèlo {{Documentacion}}.
local p = {}
local TableBuilder = require('Module:TableBuilder')
function p.corp(frame)
args = frame:getParent().args
local page = mw.title.getCurrentTitle()
doc = p.docname(page)
tab = TableBuilder.new()
--Benda por les sot-pâges /Bouèta de sabla
if page.subpageText == 'Bouèta de sabla' then
tab.insert('<div style="clear:both />')
.insert(frame:preprocess('{{Sot-pâge de bouèta de sabla}}'))
end
--G·ènèracion de la documentacion
p.enteta(page)
p.contegnu(frame, page)
p.notice(page)
return tab.concat()
end
function p.docname(page)
--Sont pas dedens na sot-pâge
if not page.isSubpage then return page.subjectNsText .. ":" .. page.text .. "/Documentacion" end
--Sont dedens na sot-pâge
if page.subpageText == 'Documentacion'
or page.subpageText == 'Bouèta de sabla'
or page.subpageText == 'Èprôva' then
return page.subjectNsText .. ":" .. page.baseText .. "/Documentacion"
else
return page.subjectNsText .. ":" .. page.text .. "/Documentacion"
end
end
function p.ifexist(page)
if not page or not mw.title.new(page).exists then return false end
return true
end
function p.enteta(page)
tab.insert('<div style="clear:both; margin:1em 0 0 0; border:1px solid #aaa; background:')
if not args.color then tab.insert('#ecfcf4')
else tab.insert(args.color) end
tab.insert('; padding:1em 1em 0.8em;">')
.insert('<div style="margin-bottom:1ex; border-bottom:1px solid #aaa; padding-bottom:3px;">')
.insert('[[Fichiér:Template-info.png|50px|alt=Documentacion du modèlo|link=]]')
.insert('<span style="font-weight:bold; font-size:125%"> ')
if args.titro then tab.insert(args.titro)
else tab.insert('Documentacion') end
tab.insert('</span>')
if not args.contegnu then
local arg = mw.title.new(args[1] or doc)
tab.insert('<span class="mw-editsection plainlinks">[[')
if args[1] and p.ifexist(args[1]) or p.ifexist(doc) then
tab.insert(arg:fullUrl('action=edit'))
.insert(' changiér')
else
tab.insert(arg:fullUrl({["action"]="edit", ["preload"]="Modèlo:Documentacion/Preload"}))
.insert(' fâre')
end
tab.insert(']] [[')
tab.insert(page:fullUrl('action=purge') .. ' purgiér]')
.insert(']</span>')
end
tab.insert('</div>')
return tab.concat()
end
function p.contegnu(frame, page)
local arg = args[1] or doc
if args.contegnu then
tab.insert('\n')
.insert(args.contegnu)
else
tab.insert(frame:preprocess('<nowiki />'))
.insert('\n')
if args[1] and p.ifexist(args[1]) or p.ifexist(doc) then
tab.insert(frame:preprocess('{{' .. arg .. '}}'))
end
end
tab.insert('\n')
.insert(frame:preprocess('<nowiki />'))
.insert('<div style="clear:both" />\n')
return tab.concat()
end
function p.notice(page)
local arg = mw.title.new(args[1] or doc)
if args.contegnu then
tab.insert('<div class="plainlinks" style="border-top:1px solid #aaa; margin: 1em 0 0;">')
.insert('<p style="margin-bottom:0; padding-left:1em; font-style:italic;">\n')
if args.notice then
tab.insert(args.notice)
else
tab.insert('La [[Éde:Documentacion de modèlo|documentacion]] de ceti ')
.insert('[[Éde:Modèlo|modèlo]] est [[Éde:Entrebetâ|entrebetâye]] tot drêt ')
.insert('dedens lo sin côrp. [')
.insert(page:fullUrl('action=purge'))
.insert(' Clicâd ique por purgiér lo cacho].')
.insert('<br />Se ceta pâge est protègiêe, ')
.insert('se vos plét transferâd lo contegnu de la documentacion vers la sina [')
.insert(arg:fullUrl({["action"]="edit", ["preload"]="Modèlo:Documentacion/Preload"}))
.insert(' sot-pâge consacrâye].')
end
else
if args[1] and p.ifexist(args[1]) or p.ifexist(doc) then
tab.insert('<div class="plainlinks" style="border-top:1px solid #aaa; margin: 1em 0 0;">')
.insert('<p style="margin-bottom:0; padding-left:1em; font-style:italic;">')
.insert('La [[Éde:Documentacion de modèlo|documentacion]] de ceti ')
.insert('[[Éde:Modèlo|modèlo]] est [[Éde:Entrebetâ|entrebetâye]] dês la sina [[')
.insert(tostring(arg) .. '|sot-pâge de documentacion]]')
.insert(' <span style="font-size:89%; font-style:normal;">([')
.insert(arg:fullUrl('action=edit'))
.insert(' changiér] | [')
.insert(arg:fullUrl('action=history') .. ' historico])</span>.<br />')
else
tab.insert('<div class="plainlinks">')
.insert('<p style="margin-bottom:0; padding-left:1em; font-style:italic;">')
end
tab.insert('Los changiors pôvont travalyér dedens la ')
local bouetadesabla = arg.subjectNsText .. ":" .. arg.baseText .. "/Bouèta de sabla"
local argbouetadesabla = mw.title.new(bouetadesabla)
if p.ifexist(bouetadesabla) then
tab.insert('[[' .. bouetadesabla .. '|bouèta de sabla]]')
.insert(' <span style="font-size:89%; font-style:normal;">([')
.insert(argbouetadesabla:fullUrl('action=edit'))
.insert(' changiér])</span>')
else
tab.insert('bouèta de sabla <span style="font-size:89%; font-style:normal;">([')
.insert(argbouetadesabla:fullUrl({["action"]="edit", ["preload"]="Modèlo:Documentacion/Preload2"}))
.insert(' fâre])</span>')
end
tab.insert(' et la pâge d’ ')
local eprova = arg.subjectNsText .. ":" .. arg.baseText .. "/Èprôva"
local argeprova = mw.title.new(eprova)
if p.ifexist(eprova) then
tab.insert('[[' .. eprova .. '|èprôva]]')
.insert(' <span style="font-size:89%; font-style:normal;">([')
.insert(argtest:fullUrl('action=edit'))
.insert(' changiér])</span>')
else
tab.insert('èprôva <span style="font-size:89%; font-style:normal;">([')
.insert(argeprova:fullUrl({["action"]="edit", ["preload"]="Modèlo:Documentacion/Preload3"}))
.insert(' fâre])</span>')
end
tab.insert('.<br />Se vos plét, betâd les catègories dedens la sot-pâge ')
.insert('<span class="plainlinks">[')
if args[1] and p.ifexist(args[1]) or p.ifexist(doc) then
tab.insert(arg:fullUrl('action=edit'))
else
tab.insert(arg:fullUrl({["action"]="edit", ["preload"]="Modèlo:Documentacion/Preload"}))
end
tab.insert(' /Documentacion].')
end
tab.insert('</p></div></div>')
return tab.concat()
end
return p