Module:Luadocs

-- Shows modules links in the list of global modules -- Syntax :

local p = {} local getArgs = require("Dev:Arguments").getArgs local isMod = require("Dev:Existsmod").module_exists local link = require("Dev:Links").link

function p.create_links(modName, external, noTests) if not modName then return end modName = mw.language.new('en'):ucfirst(modName) local headerText = modName local modLinks = { "Docs", "Source" }

if external then headerText = link(external, modName)

local icons = { wikipedia = "Wp icon 16x16", github = "GitHub icon 16x16" }

for substring, icon in pairs(icons) do           if external:lower:find(substring) then headerText = " " .. headerText end end end

local headerDiv = mw.html.create("div") :css("font-size", "18px") :css("line-height", "26px") :wikitext(headerText)

if not noTests then local testPage = "Module:" .. modName .. "/testcases" local testLink = "Tests"

if not isMod(testPage, true) then local url = mw.uri.fullUrl(testPage):extend{ action = "edit", preload = "Template:Moduletestcases" }

testLink = testLink .. "([" .. tostring(url) .. " add])" end

modLinks[3] = testLink end

return tostring(headerDiv) .. table.concat(modLinks, " · ") end

function p.main(frame) local args = getArgs(frame)

if args[1] then return p.create_links(args[1], args["external"], args["notests"]) end end

return p