A modult a Modul:number list/documentation/doc lapon tudod dokumentálni
local export = {}
-- it is either here, or in ], and it is not in ugly hacks.
function export.CONTENTMODEL()
return mw.title.getCurrentTitle().contentModel
end
doc_content = function (title, cats)
local lang_code = title.fullText:match("^Module:number list/data/(.+)")
local lang = require("Module:languages").getByCode(lang_code)
local function page_exists(title)
local success, title_obj = pcall(mw.title.new, title)
return success and title_obj.exists
end
if lang then
local canonical_name = lang:getCanonicalName()
local language_data_modules = canonical_name .. " data modules"
cats:insert((page_exists("Category:" .. language_data_modules)
and language_data_modules or canonical_name .. " modules")
.. "|number list")
cats:insert("Number data modules|" .. canonical_name)
return ("This module contains data on various types of numbers in %s.\n%s")
:format(lang:makeCategoryLink(), require("Module:number list/show").table() or '')
end
end
-- This provides categories and documentation for various data modules, so that
-- ] isn't unnecessarily cluttered.
-- It is a list of tables, each of which have three possible fields:
-- The "regex" field is required. It is a Lua pattern to match the module's
-- title. If it matches, the data will be used. If the pattern contains one
-- capture, and a category has been specified, the capture will be used as a
-- sortkey.
-- The "doc" field is required. This may be a function or a
-- string. If it is a function, it receives a title and an array (see
-- ]) of categories that will be added to the documentation as
-- its first and second arguments, and may return a string, which will be used
-- as documentation. If it is a string, it is the name of a submodule under
-- "Module:documentation/functions/" which returns a function, of the same type
-- as described above.
-- The "cat" field is optional. It is a category in which the module should be
-- placed. The inner part of the category link is generated as follows:
-- mw.ustring.gsub(full_title, cat_field)
-- So if the "cat" field is present, the "regex" field should match the whole
-- title, and if there is "|%1" at the end of the "cat" field, for a sortkey,
-- there should be one capture in the "regex" field.
function export.show(frame)
local params = {
= {},
= {},
= {},
= { type = "boolean", default = false },
= { type = "boolean", default = false },
}
local args = require("Module:parameters").process(frame.args, params)
local output = Array('\n<div class="documentation" style="display:block; clear:both">\n')
local cats = Array()
local nodoc = args.nodoc
if (not args.hr) or (args.hr == "above") then
output:insert("----\n")
end
local title = ((args ~= "") and args) and mw.title.new(args)
or mw.title.getCurrentTitle()
local doc_title = mw.title.new((args ~= "") and args
or (title.fullText .. '/doc'))
local contentModel = title.contentModel
local pagetype = mw.getContentLanguage():lcfirst(title.nsText) .. ""
local preload, fallback_docs, doc_content, doc_content_module,
old_doc_title, user_name, skin_name, needs_doc
end
return export