« Module:Documentation » : différence entre les versions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 111 : | Ligne 111 : | ||
elseif frame:preprocess('{{FULLPAGENAMEE}}') ~= frame:preprocess('{{FULLPAGENAMEE:' .. p.docname(frame) .. '}}') | elseif frame:preprocess('{{FULLPAGENAMEE}}') ~= frame:preprocess('{{FULLPAGENAMEE:' .. p.docname(frame) .. '}}') | ||
and p.ifexist(p.docname(frame), frame) then | and p.ifexist(p.docname(frame), frame) then | ||
table.insert(contenu, | table.insert(contenu, '{{' .. p.docname(frame) .. '}}') | ||
end | end | ||
end | end | ||
table.insert(contenu, '\n<nowiki /><div style="clear:both" />\n') | table.insert(contenu, frame:preprocess('\n<nowiki /><div style="clear:both" />\n')) | ||
return table.concat(contenu) | return table.concat(contenu) | ||
end | end | ||
Version du 11 juin 2013 à 12:53
--Ce module implemente le modèle Modèle:Méta documentation de modèle.
local p = {}
function p.corps(frame)
local args = frame:getParent().args
local corps = {}
--Bandeau pour les sous-pages /Bac à sable
if frame:preprocess('Documentation') == 'Bac à sable' then
table.insert(corps, '
table.insert(corps, 'Modèle:Sous-page de bac à sable') end
--Génération de la documentation
table.insert(corps, frame:preprocess(p.entete(frame, args)))
table.insert(corps, p.contenu(frame, args))
table.insert(corps, frame:preprocess(p.notice(frame, args)))
--Code HTML brute
if args.raw then
return frame:preprocess('' .. table.concat(corps) .. '')
end
return table.concat(corps)
end
function p.ifexist(page, frame)
if not page then return false end
if frame:preprocess() == '1' then return true end
return false
end
function p.docname(frame)
--On n'est pas dans une sous-page
if frame:preprocess('Documentation') == frame:preprocess('Documentation') then
return frame:preprocess('Module:Documentation/Documentation')
else
--On est dans une sous-page
nom = frame:preprocess('Documentation')
if nom == 'Documentation' or nom == 'Bac à sable' or nom == 'Test' then
return frame:preprocess('Documentation')
else
return frame:preprocess('Module:Documentation/Documentation')
end
end
end
function p.entete(frame, args)local entete = {'
if not args.contenu then
table.insert(entete, '[[')
table.insert(entete, '{{fullurl:')
if args[1] then
if p.ifexist(args[1], frame) then
table.insert(entete, args[1])
table.insert(entete, '|action=edit modifier}}]] [Modèle:Purger le cache')
else
table.insert(entete, args[1])
table.insert(entete, '|action=edit&preload=Modèle:Documentation/Preload créer}}]')
end
else
if p.ifexist(p.docname(frame), frame) then
table.insert(entete, p.docname(frame))
table.insert(entete, '|action=edit modifier}}]] [Modèle:Purger le cache')
else
table.insert(entete, p.docname(frame))
table.insert(entete, '|action=edit&preload=Modèle:Documentation/Preload créer}}]')
end
end
table.insert(entete, ']')
end
table.insert(entete, '') table.insert(entete, ' ')
if args.titre then
table.insert(entete, args.titre)
else
table.insert(entete, 'Documentation')
end
table.insert(entete, 'return table.concat(entete) end
function p.contenu(frame, args)
local contenu = {}
if args.contenu then
table.insert(contenu, '\n')
table.insert(contenu, args.contenu)
else
table.insert(contenu, '\n')
--Évite toute récursion
if args[1]
and frame:preprocess('Module:Documentation') ~= frame:preprocess()
and p.ifexist(args[1], frame) then
table.insert(contenu, '{{' .. args[1] .. '}}')
elseif frame:preprocess('Module:Documentation') ~= frame:preprocess('%27_.._p.docname(frame)_.._%27')
and p.ifexist(p.docname(frame), frame) then
table.insert(contenu, 'Modèle:' .. p.docname(frame) .. '')
end
end
table.insert(contenu, frame:preprocess('\n return table.concat(contenu)
end
function p.notice(frame, args)
local notice = {}
if args.contenu then
table.insert(notice, '\n')
if args.notice then
table.insert(notice, args.notice)
else
table.insert(notice, 'La documentation de ce modèle ')
table.insert(notice, 'est directement incluse dans le corps de ce dernier.
')
table.insert(notice, 'Si cette page est protégée, veuillez transférer le contenu de la documentation vers sa ')
table.insert(notice, '[{{fullurl:' .. p.docname(frame))
table.insert(notice, '|action=edit&preload=Modèle:Documentation/Preload sous-page dédiée}}].')
end
else
if args[1] and p.ifexist(args[1], frame) or p.ifexist(p.docname(frame), frame) then
table.insert(notice, '
')
table.insert(notice, 'La documentation de ce ')
table.insert(notice, 'modèle est incluse depuis sa ')
if args[1] then
table.insert(notice, '[[' .. args[1] .. '|sous-page de documentation]]')
else
table.insert(notice, 'sous-page de documentation')
end
table.insert(notice, ' (')
table.insert(notice, '[{{fullurl:')
if args[1] then
table.insert(notice, args[1] .. '|action=edit}} modifier]')
table.insert(notice, ' | [{{fullurl:')
table.insert(notice, args[1] .. '|action=history}} historique]')
else
table.insert(notice, p.docname(frame) .. '|action=edit}} modifier]')
table.insert(notice, ' | [{{fullurl:')
table.insert(notice, p.docname(frame) .. '|action=history}} historique]')
end
table.insert(notice, ').
')
else
table.insert(notice, '
')
end
table.insert(notice, 'Les éditeurs peuvent travailler dans le ')
if args[1] and p.ifexist(frame:preprocess('Bac à sable'), frame)
or p.ifexist(frame:preprocess('Bac à sable'), frame) then
table.insert(notice, 'bac à sable')
table.insert(notice, ' (')
table.insert(notice, 'modifier)')
else
table.insert(notice, 'bac à sable (')
table.insert(notice, 'créer')
table.insert(notice, ')')
end
table.insert(notice, ' et la page de ')
if args[1] and p.ifexist(frame:preprocess('Test'), frame)
or p.ifexist(frame:preprocess('Test'), frame) then
table.insert(notice, 'test')
table.insert(notice, ' (')
table.insert(notice, 'modifier)')
else
table.insert(notice, 'test (')
table.insert(notice, 'créer')
table.insert(notice, ')')
end
table.insert(notice, '.
Veuillez placer les catégories dans la sous-page ')
table.insert(notice, '[')
table.insert(notice, '{{fullurl:')
if args[1] and p.ifexist(args[1], frame) or p.ifexist(p.docname(frame), frame) then
if args[1] then
table.insert(notice, args[1])
else
table.insert(notice, p.docname(frame))
end
table.insert(notice, '|action=edit')
else
if args[1] then
table.insert(notice, args[1])
else
table.insert(notice, p.docname(frame))
end
table.insert(notice, '|action=edit&preload=Modèle:Documentation/Preload')
end
table.insert(notice, ' /Documentation}}].')
end
table.insert(notice, '
return table.concat(notice) end
return p