Modul:Hatnote: Unterschied zwischen den Versionen
fix a mistake in the module comments; allow overriding the title in makeWikitextError; allow people to call _hatnote without an options table; and remove a comment about usage, as it is now covered in the test cases
(sorry about that; we need to keep findNamespaceId around for other modules) |
(fix a mistake in the module comments; allow overriding the title in makeWikitextError; allow people to call _hatnote without an options table; and remove a comment about usage, as it is now covered in the test cases) |
||
Zeile 34: | Zeile 34: | ||
-- function will not work if the link is enclosed in double brackets. Colons | -- function will not work if the link is enclosed in double brackets. Colons | ||
-- are trimmed from the start of the link by default. To skip colon | -- are trimmed from the start of the link by default. To skip colon | ||
-- trimming, set the removeColon parameter to | -- trimming, set the removeColon parameter to false. | ||
checkType('findNamespaceId', 1, link, 'string') | checkType('findNamespaceId', 1, link, 'string') | ||
checkType('findNamespaceId', 2, removeColon, 'boolean', true) | checkType('findNamespaceId', 2, removeColon, 'boolean', true) | ||
Zeile 77: | Zeile 75: | ||
end | end | ||
function p.makeWikitextError(msg, helpLink, addTrackingCategory) | function p.makeWikitextError(msg, helpLink, addTrackingCategory, title) | ||
-- Formats an error message to be returned to wikitext. If | -- Formats an error message to be returned to wikitext. If | ||
-- addTrackingCategory is not false after being returned from | -- addTrackingCategory is not false after being returned from | ||
Zeile 85: | Zeile 83: | ||
checkType('makeWikitextError', 2, helpLink, 'string', true) | checkType('makeWikitextError', 2, helpLink, 'string', true) | ||
yesno = require('Module:Yesno') | yesno = require('Module:Yesno') | ||
title = title or mw.title.getCurrentTitle() | |||
-- Make the help link text. | -- Make the help link text. | ||
local helpText | local helpText | ||
Zeile 192: | Zeile 190: | ||
checkType('_hatnote', 1, s, 'string') | checkType('_hatnote', 1, s, 'string') | ||
checkType('_hatnote', 2, options, 'table', true) | checkType('_hatnote', 2, options, 'table', true) | ||
options = options or {} | |||
local classes = {'hatnote'} | local classes = {'hatnote'} | ||
local extraclasses = options.extraclasses | local extraclasses = options.extraclasses |