Modjoul:Dokimantasyon : Diférans ant vèrsyon

Di Wikipédja
Contenu supprimé Contenu ajouté
FanmDjok (kozman | kontribisyon)
Page créée avec « -- Sa modjoul ka adapté modèl-a {{Méta dokimantasyon di modèl}}. local p = {} local function existePage(paj) return page and page.exists end local function nonSibp… »
(Pyès diférans)

Vèrsyon di 4 janvyé 2020 à 16:18

-- Sa modjoul ka adapté modèl-a Erreur de script : la fonction « dokimantasyon » n’existe pas..

local p = {}

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

local function nonSibpaj(paj, sibpaj) --Nou pa annan roun sibpaj if not page.isSubpage then return page.subjectNsText .. ':' .. page.text .. '/' .. sibpaj end

--Nou pa annan roun sibpaj local sibPaj = page.subpageText if sibPaj == 'Dokimantasyon' or sibPaj == 'Batché sab' or sibPaj == 'Tès' then return page.subjectNsText .. ':' .. page.baseText .. '/' .. sibpaj else return page.subjectNsText .. ':' .. page.text .. '/' .. sibpaj end end

local function yannajUrl(nonPaj, titPaj, agsyon, pagePreload) local argument = {['action'] = action or 'edit'}

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

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

local function lantet(arg, paj, dok, 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 'Dokimantasyon') :done()

local ledisyonYannaj = res:tag('span') :addClass('mw-editsection plainlinks') :css('vertical-align', 'middle')

if not arg.kontni then ledisyonYannaj:wikitext('[') if existeDoc then ledisyonYannaj:wikitext(yannajUrl(dok, 'modifyé')) else if page.namespace == 828 then ledisyonYannaj:wikitext(yannajUrl(dok, 'kréyé', 'edit', 'Modjoul')) else ledisyonYannaj:wikitext(yannajUrl(dok, 'kréyé', 'edit', )) end end ledisyonYannaj:wikitext('] ') end

ledisyonYannaj :wikitext('[') :wikitext(yannajUrl(paj, 'prijé', 'prij')) :wikitext(']')

return res end

local function protegsyon(paj, dok, existeDoc, mesaj) -- Lensersyon otonmatik di modèl di protegsyon. local nivelProtegsyon = page.protectionLevels.edit

if nivelProtegsyon and nivelProtegsyon[1] then local tabProtegsyon = { autoconfirmed = {'simiProtegsyon', '{{%s*[Ss]imi%-protegsyon%s*[|}]', '{{%s*[Ss]imi%-protegsyon +lonng%s*[|}]'}, editextendedsemiprotected = {'simiProtegsyonLarj', '{{%s*[Ss]imi%-protegsyon +larj%s*[|}]'}, sysop = {'protegsyon', '{{%s*[Pp]rotegsyon%s*[|}]'}, } local protegsyon = tabProtegsyon[nivelProtegsyon[1]] if not protegsyon then return end

local alreadyShown = false if existeDoc then -- Vérifikasyon ki pa gen kaba roun modèl di -- protègsyon annan dokimantasyon-an di modèl. local kontniDok = doc:getContent() if kontniDok:match(protegsyon[2]) or (protegsyon[3] and kontniDok:match(protegsyon[3])) then alreadyShown = true end end

if not alreadyShown then if mesaj == then mesaj = nil end return require('Modjoul:Protegsyon').main({mesaj}, protegsyon[1], paj) end end end

-- pou batché sab-a, nou ka anlvé baliz-ya di katégori -- ki abitchwèlman sitchwé an "includeonly" an finisman di dokimantasyon-an local function anlveBalizKategori(kontniDok) local count repeat kontniDok, count = mw.ustring.gsub(kontniDok, '%[%[Katégori:[^%]]+%]%][\t\r\n\f ]*$', ) until count == 0

kontniDok, count = mw.ustring.gsub(kontniDok, '[\t\r\n\f ]*$', )

return contenuDoc end

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

if args['contenu auto haut'] then res:wikitext(args['contenu auto haut']) :newline() end

if args.contenu then res:newline() :wikitext(args.contenu) :newline()

elseif existeDoc then local contenuDoc = mw.getCurrentFrame():expandTemplate{title = doc.prefixedText} if page.subpageText == 'Bac à sable' or page.subpageText == 'Test' then contenuDoc = retireBalisesCategories(contenuDoc) end res:newline() :wikitext(contenuDoc) :newline()

elseif page.subpageText ~= 'Bac à sable' and page.subpageText ~= 'Test' and args['contenu facultatif'] == nil 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 page.namespace == 828 then -- Module texteBandeau = texteBandeau:format( 'module', lienUrl(doc, 'créer cette sous-page', 'edit', 'Module'), 'module' ) else -- Modèle texteBandeau = texteBandeau:format( 'modèle', lienUrl(doc, 'créer cette sous-page', 'edit', ), 'modèle' ) end if page.namespace == 10 then -- Modèle texteBandeau = texteBandeau .. 'Catégorie:Modèle sans documentation' elseif page.namespace == 828 then -- Module if page.text:sub(1, 12) == 'Utilisateur:' then -- Pas de catégorisation pour le pseudo-namespace "Module:Utilisateur:Toto/Nom du module" elseif existeDoc == false then texteBandeau = texteBandeau .. 'Catégorie:Module sans documentation' end end local param = { ['icône'] = 'OOjs_UI_icon_book-ltr.svg', alt = 'MIT', style = 'width:80%;', texte = texteBandeau, } res:wikitext(require('Module:Bandeau')._bandeau(param)) end

if args['contenu auto bas'] then res:newline() :wikitext(args['contenu auto bas']) end

res :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['nom modèle'] then local lienAide = 'modèle' if page.namespace == 828 then lienAide = 'module' end

contenuParagraphe :wikitext('La documentation de ce ') :wikitext(lienAide) :wikitext(' est générée par le modèle ') :wikitext(mw.getCurrentFrame():expandTemplate{title = 'm', args = {args['nom modèle']} }) :wikitext('.
') else contenuParagraphe :tag('span') :addClass('error') :wikitext('Erreur : le paramètre nom modèle n\'est pas renseigné.
') end

if args.contenu then contenuParagraphe :wikitext('Elle est directement incluse dans l\'appel de ce dernier. ') :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('.
') elseif existeDoc then contenuParagraphe :wikitext('Elle est incluse depuis ')

if args['page doc'] then contenuParagraphe :wikitext('la page [[') :wikitext(tostring(doc)) :wikitext(']]. ') else contenuParagraphe :wikitext('sa [[') :wikitext(tostring(doc)) :wikitext('|sous-page de documentation]] ') end

contenuParagraphe :tag('span') :css('font-size', '89%') :css('font-style', 'normal') :wikitext('(') :wikitext(lienUrl(doc, 'historique', 'history')) :wikitext(').') :done()

contenuParagraphe :wikitext('Veuillez placer les catégories sur cette page là.
') end

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

local titrePageBacasable = nomSouspage(page, '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 page.namespace == 828 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 page.namespace ~= 828 then contenuParagraphe:wikitext(' et la page de ')

local titrePageTest = nomSouspage(page, '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 titrePageDoc = args['page doc'] or nomSouspage(page, 'Documentation') local doc = mw.title.new(titrePageDoc) 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 local couleur = '#ecfcf4' if page.namespace == 828 then couleur = '#ecf0fc' end

res :tag('div') :css('clear', 'both') :css('margin', '1em 0 0 0') :css('border', '1px solid #aaa') :css('background', couleur) :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 par défaut pour les modules sans documentation if page.namespace == 828 and page.subpageText ~= 'Bac à sable' and page.subpageText ~= 'Test' then if existeDoc == false then 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 val = mw.text.trim(val) if val ~= then args[cle] = val end end

return p._documentation(args) end

return p


-- Sa modjoul ka adapté modèl-a {{Méta dokimantasyon di modèl}}.

local p = {}

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

local function nonSibpaj(paj, sibpaj)
	--Nou pa annan roun sibpaj
	if not page.isSubpage then
		return page.subjectNsText .. ':' .. page.text .. '/' .. sibpaj
	end

	--Nou pa annan roun sibpaj
	local sibPaj = page.subpageText
	if sibPaj == 'Dokimantasyon'
	or sibPaj == 'Batché sab'
	or sibPaj == 'Tès' then
		return page.subjectNsText .. ':' .. page.baseText .. '/' .. sibpaj
	else
		return page.subjectNsText .. ':' .. page.text .. '/' .. sibpaj
	end
end

local function yannajUrl(nonPaj, titPaj, agsyon, pagePreload)
	local argument = {['action'] = action or 'edit'}

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

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

local function lantet(arg, paj, dok, existeDoc)
	local res = mw.html.create('div')

	res
		:css('margin-bottom', '1ex')
		:css('border-bottom', '1px solid #aaa')
		:css('padding-bottom', '3px')
 		:wikitext('[[Fiché:Test Template Info-Icon.svg|50px|alt=|link=]]')
	 	:tag('span')
	 		:css('font-weight', 'bold')
	 		:css('font-size', '125%')
	 		:css('vertical-align', 'middle')
	 		:wikitext(' ')
	 		:wikitext(args.titre or 'Dokimantasyon')
	 		:done()

	local ledisyonYannaj = res:tag('span')
		:addClass('mw-editsection plainlinks')
		:css('vertical-align', 'middle')

	if not arg.kontni then
		ledisyonYannaj:wikitext('[')
		if existeDoc then
			ledisyonYannaj:wikitext(yannajUrl(dok, 'modifyé'))
		else
			if page.namespace == 828 then
				ledisyonYannaj:wikitext(yannajUrl(dok, 'kréyé', 'edit', 'Modjoul'))
			else
				ledisyonYannaj:wikitext(yannajUrl(dok, 'kréyé', 'edit', ''))
			end
		end
		ledisyonYannaj:wikitext('] ')
	end
	
	ledisyonYannaj
		:wikitext('[')
		:wikitext(yannajUrl(paj, 'prijé', 'prij'))
		:wikitext(']')

	return res
end

local function protegsyon(paj, dok, existeDoc, mesaj)
	-- Lensersyon otonmatik di modèl di protegsyon.
	local nivelProtegsyon = page.protectionLevels.edit

	if nivelProtegsyon and nivelProtegsyon[1] then
		local tabProtegsyon = {
			autoconfirmed = {'simiProtegsyon', '{{%s*[Ss]imi%-protegsyon%s*[|}]', '{{%s*[Ss]imi%-protegsyon +lonng%s*[|}]'},
			editextendedsemiprotected = {'simiProtegsyonLarj', '{{%s*[Ss]imi%-protegsyon +larj%s*[|}]'},
			sysop = {'protegsyon', '{{%s*[Pp]rotegsyon%s*[|}]'},
		}
		local protegsyon = tabProtegsyon[nivelProtegsyon[1]]
		if not protegsyon then
			return ''
		end

		local alreadyShown = false
		if existeDoc then
			-- Vérifikasyon ki pa gen kaba roun modèl di
			-- protègsyon annan dokimantasyon-an di modèl.
			local kontniDok = doc:getContent()
			if kontniDok:match(protegsyon[2]) or (protegsyon[3] and kontniDok:match(protegsyon[3])) then
				alreadyShown = true
			end
		end

		if not alreadyShown then
			if mesaj == '' then
				mesaj = nil
			end
			return require('Modjoul:Protegsyon').main({mesaj}, protegsyon[1], paj)
		end
	end
end

-- pou batché sab-a, nou ka anlvé baliz-ya di katégori
-- ki abitchwèlman sitchwé an "includeonly" an finisman di dokimantasyon-an
local function anlveBalizKategori(kontniDok)
	local count
	repeat
		kontniDok, count = mw.ustring.gsub(kontniDok, '%[%[Katégori:[^%]]+%]%][\t\r\n\f ]*$', '')
	until count == 0

	kontniDok, count = mw.ustring.gsub(kontniDok, '[\t\r\n\f ]*$', '')

	return contenuDoc
end

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

	if args['contenu auto haut'] then
		res:wikitext(args['contenu auto haut'])
		   :newline()
	end

	if args.contenu then
		res:newline()
		   :wikitext(args.contenu)
		   :newline()

	elseif existeDoc then
		local contenuDoc = mw.getCurrentFrame():expandTemplate{title = doc.prefixedText}
		if page.subpageText == 'Bac à sable' or page.subpageText == 'Test' then
			contenuDoc = retireBalisesCategories(contenuDoc)
		end
		res:newline()
		   :wikitext(contenuDoc)
		   :newline()

	elseif page.subpageText ~= 'Bac à sable' and page.subpageText ~= 'Test' and args['contenu facultatif'] == nil then
	
		local texteBandeau = '<b>Ce %s ne possède aucune [[Aide:Documentation de modèle|documentation]] '
			..'explicative en sous-page</b>, pas même une description succincte.<br> '
			..'Vous pouvez %s afin de documenter ce %s adéquatement.'
		if page.namespace == 828 then -- Module
			texteBandeau = texteBandeau:format(
				'module',
				lienUrl(doc, 'créer cette sous-page', 'edit', 'Module'),
				'module'
			)
		else -- Modèle
			texteBandeau = texteBandeau:format(
				'modèle',
				lienUrl(doc, 'créer cette sous-page', 'edit', ''),
				'modèle'
			)
		end
		if page.namespace == 10 then -- Modèle
			texteBandeau = texteBandeau .. '[[Catégorie:Modèle sans documentation]]'
		elseif page.namespace == 828 then -- Module
			if page.text:sub(1, 12) == 'Utilisateur:' then
				-- Pas de catégorisation pour le pseudo-namespace "Module:Utilisateur:Toto/Nom du module"
			elseif existeDoc == false then
				texteBandeau = texteBandeau .. '[[Catégorie:Module sans documentation]]'
			end
		end
		local param = {
			['icône'] = 'OOjs_UI_icon_book-ltr.svg',
			alt = 'MIT',
			style = 'width:80%;',
			texte = texteBandeau,
		}
		res:wikitext(require('Module:Bandeau')._bandeau(param))
	end

	if args['contenu auto bas'] then
		res:newline()
		   :wikitext(args['contenu auto bas'])
	end

	res
		: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['nom modèle'] then
		local lienAide = '[[Aide:Modèle|modèle]]'
		if page.namespace == 828 then
			lienAide = '[[Aide:Module|module]]'
		end

		contenuParagraphe
			:wikitext('La [[Aide:Documentation de modèle|documentation]] de ce ')
			:wikitext(lienAide)
			:wikitext(' est générée par le modèle ')
			:wikitext(mw.getCurrentFrame():expandTemplate{title = 'm', args = {args['nom modèle']} })
			:wikitext('.<br>')
	else 
		contenuParagraphe
		:tag('span')
			:addClass('error')
			:wikitext('Erreur : le paramètre <code>nom modèle</code> n\'est pas renseigné.<br>')
	end

	if args.contenu then
		contenuParagraphe
			:wikitext('Elle est directement [[Aide:Inclusion|incluse]] dans l\'appel de ce dernier. ')
			: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('.<br>')
	elseif existeDoc then
		contenuParagraphe
			:wikitext('Elle est [[Aide:Inclusion|incluse]] depuis ')
		
		if args['page doc'] then
			contenuParagraphe
				:wikitext('la page [[')
				:wikitext(tostring(doc))
				:wikitext(']]. ')
		else
			contenuParagraphe
				:wikitext('sa [[')
				:wikitext(tostring(doc))
				:wikitext('|sous-page de documentation]] ')
		end

		contenuParagraphe
			:tag('span')
				:css('font-size', '89%')
				:css('font-style', 'normal')
				:wikitext('(')
				:wikitext(lienUrl(doc, 'historique', 'history'))
				:wikitext(').')
				:done()

		contenuParagraphe
			:wikitext('Veuillez placer les catégories sur cette page là.<br>')
	end

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

	local titrePageBacasable = nomSouspage(page, 'Bac à sable')
	local pageBacasable = mw.title.new(titrePageBacasable)

	if existePage(pageBacasable) then
		contenuParagraphe
			:wikitext('[[' .. titrePageBacasable .. '|bac à sable]]&nbsp;')
			:tag('span')
				:css('font-size', '89%')
				:css('font-style', 'normal')
				:wikitext('(')
				:wikitext(lienUrl(pageBacasable, 'modifier'))
				:wikitext(')')
	else
		local preLoad = '2'
		if page.namespace == 828 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 page.namespace ~= 828 then
		contenuParagraphe:wikitext(' et la page de ')

		local titrePageTest = nomSouspage(page, 'Test')
		local pageTest = mw.title.new(titrePageTest)

		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('.')

	return res
end

function p._documentation(args)
	local page = mw.title.getCurrentTitle()
	local titrePageDoc = args['page doc'] or nomSouspage(page, 'Documentation')
	local doc = mw.title.new(titrePageDoc)
	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
	local couleur = '#ecfcf4'
	if page.namespace == 828 then
		couleur = '#ecf0fc'
	end
	
	res
		:tag('div')
			:css('clear', 'both')
			:css('margin', '1em 0 0 0')
			:css('border', '1px solid #aaa')
			:css('background', couleur)
			: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 par défaut pour les modules sans documentation
	if page.namespace == 828 and page.subpageText ~= 'Bac à sable' and page.subpageText ~= 'Test' then
		if existeDoc == false then
			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
		val = mw.text.trim(val)
		if val ~= '' then
			args[cle] = val
		end
	end

	return p._documentation(args)
end

return p