Jump to content
Wikipedia The Free Encyclopedia

Module:Warning

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
This module is rated as beta. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected.
Page template-protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.

This module simply unifies the formatting of all warning messages similar to Module:Error. Currently, it is plain text, but custom formatting may be applied after discussion in the talk page. Warnings are displayed above the preview when previewing an edit.

Usage

localwarn=require('Module:Warning')
warn("Message")
warn(("TypeWarning: %s"):format(warning),level)

See also

The above documentation is transcluded from Module:Warning/doc. (edit | history)
Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.

 locallibraryUtil=require('libraryUtil')

 localwrapper="%s"-- wikitext formatting
 localmsg_loc="Lua warning in %s at line %d: %s."
 localmsg="Lua warning: %s."

 returnfunction(message,level)
 libraryUtil.checkType('warn',2,level,'number',true)
 level=levelor1
 iflevel>0then
 local_,location=pcall(error,'',level+2)
 iflocation~=''then
 location=mw.text.split(location:sub(1,-3),':%f[%d]')
 message=msg_loc:format(location[1],location[2],message)
 else
 message=msg:format(message)
 end
 else
 message=msg:format(message)
 end
 mw.addWarning(wrapper:format(message))
 end

AltStyle によって変換されたページ (->オリジナル) /