« Module:Documentation » : différence entre les versions

De Lagny-sur-Marne Wiki
Aller à la navigation Aller à la recherche
0x010D (discussion | contributions)
utilisation de mw.title pour docname()
0x010D (discussion | contributions)
m retouche modif précédente
 
(58 versions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
--Ce module implemente le modèle {{Documentation}}.
--Ce module implémente le modèle {{Documentation}}.


local p = {}
local p = {}


function p.corps(frame)
local function existePage(page)
    local args = frame:getParent().args
return page and page.exists
    local corps = {}
end
       
 
    --Bandeau pour les sous-pages /Bac à sable
local function nomDocumentation(page)
    if frame:preprocess('{{SUBPAGENAME}}') == 'Bac à sable' then
--On n'est pas dans une sous-page
        table.insert(corps, '<div style="clear:both />')
if not page.isSubpage then
        table.insert(corps, frame:preprocess('{{Sous-page de bac à sable}}'))
return page.subjectNsText .. ':' .. page.text .. '/Documentation'
    end
end
--On est dans une sous-page
local sousPage = page.subpageText
if sousPage == 'Documentation'
or sousPage == 'Bac à sable'
or sousPage == 'Test' then
return page.subjectNsText .. ':' .. page.baseText .. '/Documentation'
else
return page.subjectNsText .. ':' .. page.text .. '/Documentation'
end
end
 
local function lienUrl(nomPage, titrePage, action, pagePreload)
local argument = {['action'] = action or 'edit'}
if pagePreload then
argument['preload'] = 'Modèle:Documentation/Preload' .. pagePreload
end
 
return mw.ustring.format('[%s %s]', nomPage:fullUrl(argument), titrePage)
end
 
local function entete(args, page, doc, existeDoc)
local res = mw.html.create('div')
 
res
:css('margin-bottom', '1ex')
:css('border-bottom', '1px solid #aaa')
:css('padding-bottom', '3px')
:wikitext('[[Fichier:Template-info.png|50px|alt=|link=]]')
:tag('span')
:css('font-weight', 'bold')
:css('font-size', '125%')
:css('vertical-align', 'middle')
:wikitext('&nbsp;')
:wikitext(args.titre or 'Documentation')
:done()
 
if not args.contenu then
local editionLien = res:tag('span')
:addClass('mw-editsection plainlinks')
:css('vertical-align', 'middle')
:wikitext('&#91;')


    --Génération de la documentation
if existeDoc then
    table.insert(corps, frame:preprocess(p.entete(frame, args)))
editionLien:wikitext(lienUrl(doc, 'modifier'))
    table.insert(corps, p.contenu(frame, args))
else
    table.insert(corps, frame:preprocess(p.notice(frame, args)))
if args.module then
editionLien:wikitext(lienUrl(doc, 'créer', 'edit', 'Module'))
else
editionLien:wikitext(lienUrl(doc, 'créer', 'edit', ''))
end
end


    --Code HTML brut
editionLien
    if args.raw then
:wikitext('&#93;&#32;&#91;')
        return frame:preprocess('<nowiki>' .. table.concat(corps) .. '</nowiki>')
:wikitext(lienUrl(page, 'purger', 'purge'))
    end
:wikitext('&#93;')
end


    return table.concat(corps)
return res
       
end
end


function p.ifexist(page)
local function protection(page, doc, existeDoc, message)
    if not page then return false end
-- Insertion automatique du modèle de protection.
    if mw.title.new(page).exists then return true end
local niveauProtection = page.protectionLevels.edit
    return false
 
if niveauProtection and niveauProtection[1] then
local tableProtection = {
autoconfirmed = {'semiProtection', '{{%s*[Ss]emi%-protection%s*l?o?n?g?u?e?[|}]'},
editextendedsemiprotected = {'semiProtectionEtendue', '{{%s*[Ss]emi%-protection étendue%s*[|}]'},
sysop = {'protection', '{{%s*[Pp]rotection%s*[|}]'},
}
local protection = tableProtection[niveauProtection[1]]
if existeDoc then
-- Vérification qu'il n'y a pas déjà un modèle de
-- protection dans la documentation du modèle.
local contenuDoc = doc:getContent()
if contenuDoc:match(protection[2]) then
protection = false
end
end
 
if protection then
if message == '' then
message = nil
end
return require('Module:Protection').main({message}, protection[1], page)
end
end
end
end


function p.docname(frame)
local function contenu(args, doc, existeDoc)
    local page = mw.title.getCurrentTitle()
local page = mw.title.getCurrentTitle()
local res = mw.html.create():newline()


    if not page.isSubpage then
if args.contenu then
        --On n'est pas dans une sous-page
res:wikitext(args.contenu)
        return page.subjectNsText .. ":" .. page.text .. "/Documentation"
elseif existeDoc then
    else
local frame = mw.getCurrentFrame()
        --On est dans une sous-page
if frame.args and frame.args['contenu sous-page'] then
        if page.subpageText == 'Documentation'
res:wikitext(frame.args['contenu sous-page'])
        or page.subpageText == 'Bac à sable'
else
        or page.subpageText == 'Test' then
res:wikitext(frame:expandTemplate{title = doc.prefixedText})
            return page.subjectNsText .. ":" .. page.baseText .. "/Documentation"
end
        else
elseif page.subpageText ~= 'Bac à sable' and page.subpageText ~= 'Test' then
            return page.subjectNsText .. ":" .. page.text .. "/Documentation"
local texteBandeau = '<b>Ce %s ne possède aucune [[Aide:Documentation de modèle|documentation]] '
        end
..'explicative en sous-page</b>, pas même une description succincte.<br> '
    end
..'Vous pouvez %s afin de documenter ce %s adéquatement.'
if args.module then
texteBandeau = texteBandeau:format(
'module',
lienUrl(doc, 'créer cette sous-page', 'edit', 'Module'),
'module'
)
else
texteBandeau = texteBandeau:format(
'modèle',
lienUrl(doc, 'créer cette sous-page', 'edit', ''),
'modèle'
)
end
if page.namespace == 10 then
texteBandeau = texteBandeau .. '[[Catégorie:Modèle sans documentation]]'
elseif page.namespace == 828 then
if page.baseText == 'Carte/données' or page.baseText == 'Country data' or page.text:sub(1, 12) == 'Utilisateur:' then
-- pas de catégorisation pour : modèles de données, pseudo-namespace "Module:Utilisateur:Toto/Nom du module"
else
texteBandeau = texteBandeau .. '[[Catégorie:Module sans documentation]]'
end
end
local param = {
['icône'] = 'Book-cover-A-Z.svg',
alt = 'domaine public',
style = 'width:80%;',
texte = texteBandeau,
}
res:wikitext(require('Module:Bandeau')._bandeau(param))
end
 
res
:newline()
:tag('div')
:css('clear', 'both')
return res
end
end


function p.entete(frame, args)
local function notice(args, page, doc, existeDoc)
    local entete = {'<div style="clear:both; margin:1em 0 0 0; border:1px solid #aaa; background:'}
local res = mw.html.create('div')
:css('border-top', '1px solid #aaa')
:css('margin', '1.5em 0 0')


    if not args.couleur then
local contenuParagraphe = res
        table.insert(entete, '#ecfcf4')
:tag('p')
    else
:addClass('plainlinks')
        table.insert(entete, args.couleur)
:css('margin-bottom', '0')
    end
:css('padding-left', '1em')
:css('font-style', 'italic')


    table.insert(entete, '; padding:1em 1em 0.8em;">')
if args.contenu then
    table.insert(entete, '<div style="margin-bottom:1ex; border-bottom:1px solid #aaa; padding-bottom:3px;">')
if args.notice then
    table.insert(entete, '[[Fichier:Template-info.png|50px|alt=Documentation du modèle|link=]]')
contenuParagraphe:wikitext(args.notice .. '<br />')
    table.insert(entete, '<span style="font-weight:bold; font-size:125%">&nbsp;')
else
contenuParagraphe
:wikitext('La [[Aide:Documentation de modèle|documentation]] ')
:wikitext('de ce [[Aide:Modèle|modèle]] est directement ')
:wikitext('[[Aide:Inclusion|incluse]] dans le corps de ce dernier. ')
:wikitext(lienUrl(page, 'Cliquez ici pour purger le cache', 'purge'))
:wikitext('.<br /> Si cette page est protégée, veuillez ')
:wikitext('transférer le contenu de la documentation vers sa ')
:wikitext(lienUrl(doc, 'sous-page dédiée', 'edit', ''))
:wikitext('.<br /> ')
end
else
if existeDoc then
local lienAide = '[[Aide:Modèle|modèle]]'
if args.module then
lienAide = '[[Aide:Module|module]]'
end
contenuParagraphe
:wikitext('La [[Aide:Documentation de modèle|documentation]] de ce ')
:wikitext(lienAide)
:wikitext(' est [[Aide:Inclusion|incluse]] depuis sa [[')
:wikitext(tostring(doc))
:wikitext('|sous-page de documentation]]&nbsp;')
:tag('span')
:css('font-size', '89%')
:css('font-style', 'normal')
:wikitext('(')
:wikitext(lienUrl(doc, 'modifier'))
:wikitext('&nbsp;|&nbsp;')
:wikitext(lienUrl(doc, 'historique', 'history'))
:wikitext(').<br /> ')
:done()
:wikitext('Veuillez placer les catégories dans la sous-page ')
:wikitext(lienUrl(doc, '/Documentation'))
:wikitext('.<br /> ')
end
end
contenuParagraphe:wikitext('Les éditeurs peuvent travailler dans le ')
local titrePageBacasable = nomDocumentation(page):gsub('/Documentation', '/Bac à sable')
local pageBacasable = mw.title.new(titrePageBacasable)


    if args.titre then
if existePage(pageBacasable) then
        table.insert(entete, args.titre)
contenuParagraphe
    else
:wikitext('[[' .. titrePageBacasable .. '|bac à sable]]&nbsp;')
        table.insert(entete, 'Documentation')
:tag('span')
    end
:css('font-size', '89%')
    table.insert(entete, '</span>')
:css('font-style', 'normal')
:wikitext('(')
:wikitext(lienUrl(pageBacasable, 'modifier'))
:wikitext(')')
else
local preLoad = '2'
if args.module then
preLoad = nil
end
contenuParagraphe
:wikitext('bac à sable&nbsp;')
:tag('span')
:css('font-size', '89%')
:css('font-style', 'normal')
:wikitext('(')
:wikitext(lienUrl(pageBacasable, 'créer', 'edit', preLoad))
:wikitext(')')
end
if not args.module then
contenuParagraphe:wikitext(' et la page de ')


    if not args.contenu then
local titrePageTest = nomDocumentation(page):gsub('/Documentation', '/Test')
        table.insert(entete, '<span id="doc_editlinks" class="mw-editsection plainlinks">&#91;[')
local pageTest = mw.title.new(titrePageTest)
        table.insert(entete, '{{fullurl:')
if existePage(pageTest) then
contenuParagraphe
:wikitext('[[' .. titrePageTest .. '|test]]&nbsp;')
:tag('span')
:css('font-size', '89%')
:css('font-style', 'normal')
:wikitext('(')
:wikitext(lienUrl(pageTest, 'modifier'))
:wikitext(')')
else
contenuParagraphe
:wikitext('test&nbsp;')
:tag('span')
:css('font-size', '89%')
:css('font-style', 'normal')
:wikitext('(')
:wikitext(lienUrl(pageTest, 'créer', 'edit', '3'))
:wikitext(')')
end
end
contenuParagraphe:wikitext('.')


        if args[1] then
return res
            if p.ifexist(args[1]) then
                table.insert(entete, args[1])
                table.insert(entete, '|action=edit modifier}}]&#93;&#32;&#91;{{Purger le cache|purger}}')
            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)) then
                table.insert(entete, p.docname(frame))
                table.insert(entete, '|action=edit modifier}}]&#93;&#32;&#91;{{Purger le cache|purger}}')
            else
                table.insert(entete, p.docname(frame))
                table.insert(entete, '|action=edit&preload=Modèle:Documentation/Preload créer}}]')
            end
        end
        table.insert(entete, '&#93;</span>')
    end
       
    table.insert(entete, '</div>')
    return table.concat(entete)
end
end


function p.contenu(frame, args)
function p._documentation(args)
    local contenu = {}
local page = mw.title.getCurrentTitle()
    if args.contenu then
local titreDoc = nomDocumentation(page)
        table.insert(contenu, '\n')
local doc = mw.title.new(args[1] or titreDoc)
        table.insert(contenu, args.contenu)
local existeDoc = existePage(doc)
    else
local res = mw.html.create()
        table.insert(contenu, frame:preprocess('<nowiki />\n'))
        --Évite toute récursion
--Bandeau pour les sous-pages /Bac à sable
        if args[1]
if page.subpageText == 'Bac à sable' then
        and frame:preprocess('{{FULLPAGENAMEE}}') ~= frame:preprocess('{{FULLPAGENAMEE:' .. args[1] .. '}}')
res
        and p.ifexist(args[1]) then
:tag('div')
            table.insert(contenu, frame:preprocess('{{' .. args[1] .. '}}'))
:css('clear', 'both')
        elseif frame:preprocess('{{FULLPAGENAMEE}}') ~= frame:preprocess('{{FULLPAGENAMEE:' .. p.docname(frame) .. '}}')
:done()
        and p.ifexist(p.docname(frame)) then
:wikitext(mw.getCurrentFrame():expandTemplate{title = 'Sous-page de bac à sable'})
            table.insert(contenu, frame:preprocess('{{' .. p.docname(frame) .. '}}'))
end
        end
 
    end
--Génération de la documentation
res
:tag('div')
:css('clear', 'both')
:css('margin', '1em 0 0 0')
:css('border', '1px solid #aaa')
:css('background', args.couleur or '#ecfcf4')
:css('padding', '1em 1em 0.8em')
:node(entete(args, page, doc, existeDoc))
:wikitext(protection(page, doc, existeDoc, args['message protection']))
:node(contenu(args, doc, existeDoc))
:node(notice(args, page, doc, existeDoc))
 
--Catégorisation des modules, en rangeant à part les modules de données
if page.namespace == 828 and page.subpageText ~= 'Bac à sable' and page.subpageText ~= 'Test' then
if page.isSubpage and page.baseText == 'Carte/données' then
res:wikitext("[[Catégorie:Module de paramétrage de carte]]")
elseif page.isSubpage and page.baseText == 'Country data' then
res:wikitext("[[Catégorie:Module d'informations pays]]")
else
res:wikitext("[[Catégorie:Module en langage Lua]]")
end
end
 
return tostring(res)
end
 
function p.documentation(frame)
local args = {}
local argsParent = frame:getParent().args
 
--Paramètres vides interprétés par Lua
for cle, val in pairs(argsParent) do
if val ~= '' then
args[cle] = mw.text.trim(val)
end
end


    table.insert(contenu, frame:preprocess('\n<nowiki /><div style="clear:both" />\n'))
return p._documentation(args)
   
    return table.concat(contenu)
end
end
   
function p.notice(frame, args)
    local notice = {}
       
    if args.contenu then
        table.insert(notice, '<div class="plainlinks" style="border-top:1px solid #aaa; margin: 1em 0 0;">')
        table.insert(notice, '<p style="margin-bottom:0; padding-left:1em; font-style:italic;">\n')
           
        if args.notice then
            table.insert(notice, args.notice)
        else
            table.insert(notice, 'La [[Aide:Comment documenter un modèle ?|documentation]] de ce [[Aide:Modèle|modèle]] ')
            table.insert(notice, 'est directement [[Aide:Inclusion|incluse]] dans le corps de ce dernier.<br />')
            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]) or p.ifexist(p.docname(frame)) then
            table.insert(notice, '<div class="plainlinks" style="border-top:1px solid #aaa; margin: 1em 0 0;">')
            table.insert(notice, '<p style="margin-bottom:0; padding-left:1em; font-style:italic;">')
            table.insert(notice, 'La [[Aide:Comment documenter un modèle ?|documentation]] de ce ')
            table.insert(notice, '[[Aide:Modèle|modèle]] est [[Aide:Inclusion|incluse]] depuis sa ')
               
            if args[1] then
                table.insert(notice, '[[' .. args[1] .. '|sous-page de documentation]]')
            else
                table.insert(notice, '[[' .. p.docname(frame) .. '|sous-page de documentation]]')
            end
               
            table.insert(notice, '&nbsp;<span style="font-size:89%; font-style:normal;">(')
            table.insert(notice, '[{{fullurl:')


            if args[1] then
function p.nomDocumentation(frame)
                table.insert(notice, args[1] .. '|action=edit}} modifier]')
if frame.args[1] and mw.text.trim(frame.args[1]) ~= '' then
                table.insert(notice, '&nbsp;|&nbsp;[{{fullurl:')
return frame.args[1]
                table.insert(notice, args[1] .. '|action=history}} historique]')
else
            else
local titreDoc = nomDocumentation(mw.title.getCurrentTitle())
                table.insert(notice, p.docname(frame) .. '|action=edit}} modifier]')
if mw.title.new(titreDoc).exists then
                table.insert(notice, '&nbsp;|&nbsp;[{{fullurl:')
return titreDoc
                table.insert(notice, p.docname(frame) .. '|action=history}} historique]')
end  
            end
end
            table.insert(notice, ')</span>.<br />')
        else
            table.insert(notice, '<div class="plainlinks">')
            table.insert(notice, '<p style="margin-bottom:0; padding-left:1em; font-style:italic;">')
        end
        table.insert(notice, 'Les éditeurs peuvent travailler dans le ')
           
        if args[1] and p.ifexist(frame:preprocess('{{#rel2abs:' .. args[1] .. '/../Bac à sable}}'))
        or p.ifexist(frame:preprocess('{{#rel2abs:' .. p.docname(frame) .. '/../Bac à sable}}')) then
            table.insert(notice, '[[{{#rel2abs:')
            if args[1] then
                table.insert(notice, args[1])
            else
                table.insert(notice, p.docname(frame))
            end
            table.insert(notice, '/../Bac à sable}}|bac à sable]]')
            table.insert(notice, '&nbsp;<span style="font-size:89%; font-style:normal;">(')
            table.insert(notice, '[{{fullurl:{{#rel2abs:')
            if args[1] then
                table.insert(notice, args[1])
            else
                table.insert(notice, p.docname(frame))
            end
            table.insert(notice, '/../Bac à sable}}|action=edit}} modifier])</span>')
        else
            table.insert(notice, 'bac à sable&nbsp;<span style="font-size:89%; font-style:normal;">(')
            table.insert(notice, '[{{fullurl:{{#rel2abs:')
            if args[1] then
                table.insert(notice, args[1])
            else
                table.insert(notice, p.docname(frame))
            end
            table.insert(notice, '/../Bac à sable}}|action=edit&preload=Modèle:Documentation/Preload2}} créer]')
            table.insert(notice, ')</span>')
        end
        table.insert(notice, ' et la page de ')
           
        if args[1] and p.ifexist(frame:preprocess('{{#rel2abs:' .. args[1] .. '/../Test}}'))
        or p.ifexist(frame:preprocess('{{#rel2abs:' .. p.docname(frame) .. '/../Test}}')) then
            table.insert(notice, '[[{{#rel2abs:')
            if args[1] then
                table.insert(notice, args[1])
            else
                table.insert(notice, p.docname(frame))
            end
            table.insert(notice, '/../Test}}|test]]')
            table.insert(notice, '&nbsp;<span style="font-size:89%; font-style:normal;">(')
            table.insert(notice, '[{{fullurl:{{#rel2abs:')
            if args[1] then
                table.insert(notice, args[1])
            else
                table.insert(notice, p.docname(frame))
            end
            table.insert(notice, '/../Test}}|action=edit}} modifier])</span>')
        else
            table.insert(notice, 'test&nbsp;<span style="font-size:89%; font-style:normal;">(')
            table.insert(notice, '[{{fullurl:{{#rel2abs:')
            if args[1] then
                table.insert(notice, args[1])
            else
                table.insert(notice, p.docname(frame))
            end
            table.insert(notice, '/../Test}}|action=edit&preload=Modèle:Documentation/Preload3}} créer]')
            table.insert(notice, ')</span>')
        end
        table.insert(notice, '.<br />Veuillez placer les catégories dans la sous-page ')
        table.insert(notice, '<span class="plainlinks">[')
        table.insert(notice, '{{fullurl:')
        if args[1] and p.ifexist(args[1]) or p.ifexist(p.docname(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, '</p></div></div>')
    return table.concat(notice)
end
end


return p
return p

Dernière version du 15 mai 2017 à 08:40

--Ce module implémente le modèle Modèle:Méta documentation de modèle.

local p = {}

local function existePage(page) return page and page.exists end

local function nomDocumentation(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 local sousPage = page.subpageText if sousPage == 'Documentation' or sousPage == 'Bac à sable' or sousPage == 'Test' then return page.subjectNsText .. ':' .. page.baseText .. '/Documentation' else return page.subjectNsText .. ':' .. page.text .. '/Documentation' end end

local function lienUrl(nomPage, titrePage, action, pagePreload) local argument = {['action'] = action or 'edit'}

if pagePreload then argument['preload'] = 'Modèle:Documentation/Preload' .. pagePreload end

return mw.ustring.format('[%s %s]', nomPage:fullUrl(argument), titrePage) end

local function entete(args, page, doc, existeDoc) local res = mw.html.create('div')

res :css('margin-bottom', '1ex') :css('border-bottom', '1px solid #aaa') :css('padding-bottom', '3px')

		:wikitext('')

:tag('span') :css('font-weight', 'bold') :css('font-size', '125%') :css('vertical-align', 'middle') :wikitext(' ') :wikitext(args.titre or 'Documentation') :done()

if not args.contenu then local editionLien = res:tag('span') :addClass('mw-editsection plainlinks') :css('vertical-align', 'middle') :wikitext('[')

if existeDoc then editionLien:wikitext(lienUrl(doc, 'modifier')) else if args.module then editionLien:wikitext(lienUrl(doc, 'créer', 'edit', 'Module')) else editionLien:wikitext(lienUrl(doc, 'créer', 'edit', )) end end

editionLien :wikitext('] [') :wikitext(lienUrl(page, 'purger', 'purge')) :wikitext(']') end

return res end

local function protection(page, doc, existeDoc, message) -- Insertion automatique du modèle de protection. local niveauProtection = page.protectionLevels.edit

if niveauProtection and niveauProtection[1] then local tableProtection = { autoconfirmed = {'semiProtection', '{{%s*[Ss]emi%-protection%s*l?o?n?g?u?e?[|}]'}, editextendedsemiprotected = {'semiProtectionEtendue', '{{%s*[Ss]emi%-protection étendue%s*[|}]'}, sysop = {'protection', '{{%s*[Pp]rotection%s*[|}]'}, } local protection = tableProtection[niveauProtection[1]] if existeDoc then -- Vérification qu'il n'y a pas déjà un modèle de -- protection dans la documentation du modèle. local contenuDoc = doc:getContent() if contenuDoc:match(protection[2]) then protection = false end end

if protection then if message == then message = nil end return require('Module:Protection').main({message}, protection[1], page) end end end

local function contenu(args, doc, existeDoc) local page = mw.title.getCurrentTitle() local res = mw.html.create():newline()

if args.contenu then res:wikitext(args.contenu) elseif existeDoc then local frame = mw.getCurrentFrame() if frame.args and frame.args['contenu sous-page'] then res:wikitext(frame.args['contenu sous-page']) else res:wikitext(frame:expandTemplate{title = doc.prefixedText}) end elseif page.subpageText ~= 'Bac à sable' and page.subpageText ~= 'Test' then local texteBandeau = 'Ce %s ne possède aucune documentation ' ..'explicative en sous-page, pas même une description succincte.
' ..'Vous pouvez %s afin de documenter ce %s adéquatement.' if args.module then texteBandeau = texteBandeau:format( 'module', lienUrl(doc, 'créer cette sous-page', 'edit', 'Module'), 'module' ) else texteBandeau = texteBandeau:format( 'modèle', lienUrl(doc, 'créer cette sous-page', 'edit', ), 'modèle' ) end if page.namespace == 10 then texteBandeau = texteBandeau .. elseif page.namespace == 828 then if page.baseText == 'Carte/données' or page.baseText == 'Country data' or page.text:sub(1, 12) == 'Utilisateur:' then -- pas de catégorisation pour : modèles de données, pseudo-namespace "Module:Utilisateur:Toto/Nom du module" else texteBandeau = texteBandeau .. end end local param = { ['icône'] = 'Book-cover-A-Z.svg', alt = 'domaine public', style = 'width:80%;', texte = texteBandeau, } res:wikitext(require('Module:Bandeau')._bandeau(param)) end

res :newline() :tag('div') :css('clear', 'both')

return res end

local function notice(args, page, doc, existeDoc) local res = mw.html.create('div') :css('border-top', '1px solid #aaa') :css('margin', '1.5em 0 0')

local contenuParagraphe = res :tag('p') :addClass('plainlinks') :css('margin-bottom', '0') :css('padding-left', '1em') :css('font-style', 'italic')

if args.contenu then if args.notice then contenuParagraphe:wikitext(args.notice .. '
') else contenuParagraphe :wikitext('La documentation ') :wikitext('de ce modèle est directement ') :wikitext('incluse dans le corps de ce dernier. ') :wikitext(lienUrl(page, 'Cliquez ici pour purger le cache', 'purge')) :wikitext('.
Si cette page est protégée, veuillez ') :wikitext('transférer le contenu de la documentation vers sa ') :wikitext(lienUrl(doc, 'sous-page dédiée', 'edit', )) :wikitext('.
') end else if existeDoc then local lienAide = 'modèle' if args.module then lienAide = 'module' end contenuParagraphe :wikitext('La documentation de ce ') :wikitext(lienAide) :wikitext(' est incluse depuis sa [[') :wikitext(tostring(doc)) :wikitext('|sous-page de documentation]] ') :tag('span') :css('font-size', '89%') :css('font-style', 'normal') :wikitext('(') :wikitext(lienUrl(doc, 'modifier')) :wikitext(' | ') :wikitext(lienUrl(doc, 'historique', 'history')) :wikitext(').
') :done() :wikitext('Veuillez placer les catégories dans la sous-page ') :wikitext(lienUrl(doc, '/Documentation')) :wikitext('.
') end end

contenuParagraphe:wikitext('Les éditeurs peuvent travailler dans le ')

local titrePageBacasable = nomDocumentation(page):gsub('/Documentation', '/Bac à sable') local pageBacasable = mw.title.new(titrePageBacasable)

if existePage(pageBacasable) then contenuParagraphe :wikitext('bac à sable ') :tag('span') :css('font-size', '89%') :css('font-style', 'normal') :wikitext('(') :wikitext(lienUrl(pageBacasable, 'modifier')) :wikitext(')') else local preLoad = '2' if args.module then preLoad = nil end contenuParagraphe :wikitext('bac à sable ') :tag('span') :css('font-size', '89%') :css('font-style', 'normal') :wikitext('(') :wikitext(lienUrl(pageBacasable, 'créer', 'edit', preLoad)) :wikitext(')') end

if not args.module then contenuParagraphe:wikitext(' et la page de ')

local titrePageTest = nomDocumentation(page):gsub('/Documentation', '/Test') local pageTest = mw.title.new(titrePageTest)

if existePage(pageTest) then contenuParagraphe :wikitext('test ') :tag('span') :css('font-size', '89%') :css('font-style', 'normal') :wikitext('(') :wikitext(lienUrl(pageTest, 'modifier')) :wikitext(')') else contenuParagraphe :wikitext('test ') :tag('span') :css('font-size', '89%') :css('font-style', 'normal') :wikitext('(') :wikitext(lienUrl(pageTest, 'créer', 'edit', '3')) :wikitext(')') end end contenuParagraphe:wikitext('.')

return res end

function p._documentation(args) local page = mw.title.getCurrentTitle() local titreDoc = nomDocumentation(page) local doc = mw.title.new(args[1] or titreDoc) local existeDoc = existePage(doc) local res = mw.html.create()

--Bandeau pour les sous-pages /Bac à sable if page.subpageText == 'Bac à sable' then res :tag('div') :css('clear', 'both') :done() :wikitext(mw.getCurrentFrame():expandTemplate{title = 'Sous-page de bac à sable'}) end

--Génération de la documentation res :tag('div') :css('clear', 'both') :css('margin', '1em 0 0 0') :css('border', '1px solid #aaa') :css('background', args.couleur or '#ecfcf4') :css('padding', '1em 1em 0.8em') :node(entete(args, page, doc, existeDoc)) :wikitext(protection(page, doc, existeDoc, args['message protection'])) :node(contenu(args, doc, existeDoc)) :node(notice(args, page, doc, existeDoc))

--Catégorisation des modules, en rangeant à part les modules de données if page.namespace == 828 and page.subpageText ~= 'Bac à sable' and page.subpageText ~= 'Test' then if page.isSubpage and page.baseText == 'Carte/données' then res:wikitext("") elseif page.isSubpage and page.baseText == 'Country data' then res:wikitext("") else res:wikitext("") end end

return tostring(res) end

function p.documentation(frame) local args = {} local argsParent = frame:getParent().args

--Paramètres vides interprétés par Lua for cle, val in pairs(argsParent) do if val ~= then args[cle] = mw.text.trim(val) end end

return p._documentation(args) end

function p.nomDocumentation(frame) if frame.args[1] and mw.text.trim(frame.args[1]) ~= then return frame.args[1] else local titreDoc = nomDocumentation(mw.title.getCurrentTitle()) if mw.title.new(titreDoc).exists then return titreDoc end end end

return p