« Module:Documentation » : différence entre les versions
m Retouche texte selon DIPP de Oliv0 le 1 août 2013 à 16:58 (CEST) |
documentation demandé par Zebulon84 |
||
| Ligne 113 : | Ligne 113 : | ||
table.insert(notice, args.notice) | table.insert(notice, args.notice) | ||
else | else | ||
table.insert(notice, 'La [[Aide: | table.insert(notice, 'La [[Aide:Documentation de modèle|documentation]] de ce ') | ||
table.insert(notice, '[[Aide:Modèle|modèle]] est directement [[Aide:Inclusion|incluse]] ') | table.insert(notice, '[[Aide:Modèle|modèle]] est directement [[Aide:Inclusion|incluse]] ') | ||
table.insert(notice, 'dans le corps de ce dernier.<br />Si cette page est protégée, ') | table.insert(notice, 'dans le corps de ce dernier.<br />Si cette page est protégée, ') | ||
Version du 6 septembre 2013 à 19:18
--Ce module implémente le modèle Modèle:Méta documentation de modèle.
local p = {}
function p.corps(frame)
args = frame:getParent().args
local page = mw.title.getCurrentTitle()
doc = p.docname(page)
local corps = {}
--Bandeau pour les sous-pages /Bac à sable if page.subpageText == 'Bac à sable' then
table.insert(corps, '
table.insert(corps, frame:preprocess('Modèle:Sous-page de bac à sable'))
end
--Génération de la documentation table.insert(corps, p.entete(page)) table.insert(corps, p.contenu(frame, page)) table.insert(corps, p.notice(page))
--Code HTML brut
if args.raw then
return frame:preprocess('' .. table.concat(corps) .. '\n:' .. os.clock())
end
return table.concat(corps)
end
function p.docname(page)
--On n'est pas dans une sous-page if not page.isSubpage then return page.subjectNsText .. ":" .. page.text .. "/Documentation" end
--On est dans une sous-page
if page.subpageText == 'Documentation'
or page.subpageText == 'Bac à sable'
or page.subpageText == 'Test' then
return page.subjectNsText .. ":" .. page.baseText .. "/Documentation"
else
return page.subjectNsText .. ":" .. page.text .. "/Documentation"
end
end
function p.ifexist(page)
if not page then return false end if mw.title.new(page).exists then return true end return false
end
function p.entete(page)
local entete = {'table.insert(entete, '') table.insert(entete, ' ')
if args.titre then table.insert(entete, args.titre) else table.insert(entete, 'Documentation') end table.insert(entete, '')
if not args.contenu then
table.insert(entete, '[[')
local arg = mw.title.new(args[1] or doc)
if args[1] and p.ifexist(args[1]) or p.ifexist(doc) then
table.insert(entete, arg:fullUrl('action=edit') .. ' modifier]')
table.insert(entete, '] [[')
table.insert(entete, page:fullUrl('action=purge') .. ' purger]')
else
table.insert(entete, arg:fullUrl({["action"]="edit", ["preload"]="Modèle:Documentation/Preload"}))
table.insert(entete, ' créer]')
end
table.insert(entete, ']')
end
table.insert(entete, 'return table.concat(entete)
end
function p.contenu(frame, page)
local contenu = {}
local arg = args[1] or doc
if args.contenu then
table.insert(contenu, '\n')
table.insert(contenu, args.contenu)
else
table.insert(contenu, frame:preprocess(''))
table.insert(contenu, '\n')
if args[1] and p.ifexist(args[1]) or p.ifexist(doc) then
table.insert(contenu, frame:preprocess('Modèle:' .. arg .. ''))
end
end
table.insert(contenu, '\n')
table.insert(contenu, frame:preprocess(''))
table.insert(contenu, 'return table.concat(contenu)
end
function p.notice(page)
local notice = {}
local arg = mw.title.new(args[1] or doc)
if args.contenu thentable.insert(notice, '
\n')
if args.notice then
table.insert(notice, args.notice)
else
table.insert(notice, 'La documentation de ce ')
table.insert(notice, 'modèle est directement incluse ')
table.insert(notice, 'dans le corps de ce dernier.
Si cette page est protégée, ')
table.insert(notice, 'veuillez transférer le contenu de la documentation vers sa [')
table.insert(notice, arg:fullUrl({["action"]="edit", ["preload"]="Modèle:Documentation/Preload"}))
table.insert(notice, ' sous-page dédiée].')
end
else
if args[1] and p.ifexist(args[1]) or p.ifexist(doc) then
table.insert(notice, '
')
table.insert(notice, 'La documentation de ce ')
table.insert(notice, 'modèle est incluse depuis sa [[')
table.insert(notice, tostring(arg) .. '|sous-page de documentation]]')
table.insert(notice, ' ([')
table.insert(notice, arg:fullUrl('action=edit'))
table.insert(notice, ' modifier] | [')
table.insert(notice, arg:fullUrl('action=history') .. ' historique]).
')
else
table.insert(notice, '
')
end
table.insert(notice, 'Les éditeurs peuvent travailler dans le ')
local bacasable = arg.subjectNsText .. ":" .. arg.baseText .. "/Bac à sable"
local argbacasable = mw.title.new(bacasable)
if p.ifexist(bacasable) then
table.insert(notice, 'bac à sable')
table.insert(notice, ' ([')
table.insert(notice, argbacasable:fullUrl('action=edit'))
table.insert(notice, ' modifier])')
else
table.insert(notice, 'bac à sable ([')
table.insert(notice, argbacasable:fullUrl({["action"]="edit", ["preload"]="Modèle:Documentation/Preload2"}))
table.insert(notice, ' créer])')
end
table.insert(notice, ' et la page de ')
local test = arg.subjectNsText .. ":" .. arg.baseText .. "/Test"
local argtest = mw.title.new(test)
if p.ifexist(test) then
table.insert(notice, 'test')
table.insert(notice, ' ([')
table.insert(notice, argtest:fullUrl('action=edit'))
table.insert(notice, ' modifier])')
else
table.insert(notice, 'test ([')
table.insert(notice, argtest:fullUrl({["action"]="edit", ["preload"]="Modèle:Documentation/Preload3"}))
table.insert(notice, ' créer])')
end
table.insert(notice, '.
Veuillez placer les catégories dans la sous-page ')
table.insert(notice, '[')
if args[1] and p.ifexist(args[1]) or p.ifexist(doc) then
table.insert(notice, arg:fullUrl('action=edit'))
else
table.insert(notice, arg:fullUrl({["action"]="edit", ["preload"]="Modèle:Documentation/Preload"}))
end
table.insert(notice, ' /Documentation].')
end
table.insert(notice, '
return table.concat(notice)
end
return p