يمكن إنشاء صفحة توثيق الوحدة في وحدة:shortcut box/شرح

local export = {}

function export.show(frame)
	local output = {}
	local args = frame:getParent().args
	local demo = false

	local FULLPAGENAME = mw.title.getCurrentTitle().fullText
	local BASEPAGENAME, SUBPAGENAME = FULLPAGENAME:match("^(.-)/([^/]-)$")
	-- BASEPAGENAME = BASEPAGENAME or FULLPAGENAME
	
	if FULLPAGENAME == frame:getParent():getTitle() then
		demo = true
	end
	output[#output + 1] = '<div class="noprint plainlinks shortcut-box">'

	if args.temp then
		output[#output + 1] = "Temporary [[ويكاموس:اختصار|اختصار" .. (args[2] and 's' or '') .. "]]:<br/>"
	else
		output[#output + 1] = "[[ويكاموس:اختصار|اختصار" .. (args[2] and 's' or '') .. "]]:<br/>"
	end
	
	local attn = false

	for i, shcut in ipairs(args) do
		local title = mw.title.new(shcut)
		
		if not title then
			output[#output + 1] = '<span class="attentionseeking">(<code>' .. mw.text.nowiki(shcut) .. '</code>)</span><br/>'
			attn = true
		else
			local iattn = false

			local item = '[' .. tostring(mw.uri.fullUrl(shcut, 'redirect=no')) .. ' ' .. shcut .. ']'
			if title.namespace == 10 then
				item = '<code>{{[' .. tostring(mw.uri.fullUrl(shcut, 'redirect=no')) .. ' ' .. title.text .. ']}}</code>'
			end

			if not title.exists then
				attn = true
				local query = 'action=edit&redlink=1&preloadtext=' .. mw.uri.encode('#REDIRECT [[' .. FULLPAGENAME .. ']]')
				if title.namespace == 10 then
					item = '<code>{{[' .. tostring(mw.uri.fullUrl(shcut, query)) .. ' <span style="color:#c20;">' .. title.text .. '</span>]}}</code>'
				else
					item = '[' .. tostring(mw.uri.fullUrl(shcut, query)) .. ' <span style="color:#c20;">' .. shcut .. '</span>]'
				end
			elseif not demo then
				local content = title:getContent()
				local target = content:match("^#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[%s*:?%s*(.-)[#%]]")
				if not target then
					iattn = true
				else
					target = target:gsub("_", " ")
					local tns, tpg = target:match("%s*(.-)%s*:%s*(.*)%s*")
					if mw.site.namespaces[tns] then
						tns = mw.site.namespaces[tns].name
						target = tns .. ':' .. tpg
					end
					
					if title.namespace == 10 then
						if SUBPAGENAME == 'documentation' then
							iattn = (target ~= BASEPAGENAME)
						else
							iattn = (target ~= FULLPAGENAME)
						end
					else
						if SUBPAGENAME == 'documentation' then
							iattn = (target ~= BASEPAGENAME) and (target ~= FULLPAGENAME)
						else
							iattn = (target ~= FULLPAGENAME) and (target ~= (FULLPAGENAME .. '/documentation'))
						end
					end
				end
			end

			if iattn then
				item = '<span class="attentionseeking">' .. item .. '</span>'
			end

			output[#output + 1] = item .. '<br/>'
			
			attn = attn or iattn
		end
	end

	if not args.nocat then
		if attn then
			output[#output + 1] = '[[تصنيف:Shortcut boxes needing attention]]'	
		end
		if SUBPAGENAME ~= 'documentation' then
			output[#output + 1] = '[[تصنيف:صفحات ويكاموس مع إختصارات ]]'
		end
	end

	output[#output + 1] = '</div>'
	
	return table.concat(output)
end

return export