Content deleted Content added
Fred Gandt (talk | contribs) {{Module rating|protected}} |
No edit summary |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1:
{{distinguish|Module:Get short description}}
{{Module rating|protected}}
{{High-use}}
{{Lua|Module:Arguments|Module:Lang}}
{{info|This module is required by [[Module:
{{info|This module may, by design, output alarming informational messages under certain circumstances; if these messages are displayed on any page invoking this module directly or via any other module or template using it, the page will be added to [[:Category:Pages displaying alarming messages about Module:GetShortDescription]].}}
Line 11 ⟶ 13:
If the result is a wikidata description, and it is declared (at the source) as being of a foreign language (i.e. not ''en''), the result will be appropriately formatted by [[Module:Lang]] (the module powering {{tlx|lang}}), in accordance with [[MOS:OTHERLANG]]; see [[#Foreign language wikidata descriptions]] (below).
:'''Markup:''' <code><nowiki>{{#invoke:GetShortDescription|main |name=
:'''Result:''' {{#invoke:GetShortDescription|main|name=
This is equivalent to stating {{para|prefer|explicit}}; see [[#prefer]] (below).
Line 19 ⟶ 21:
==== explicit ====
:'''Markup:''' <code><nowiki>{{#invoke:GetShortDescription|main |name=
:'''Result:''' {{#invoke:GetShortDescription|main|name=
==== wikidata ====
:'''Markup:''' <code><nowiki>{{#invoke:GetShortDescription|main |name=
:'''Result:''' {{#invoke:GetShortDescription|main|name=
=== prefer ===
Line 30 ⟶ 32:
==== explicit or wikidata ====
:'''Markup:''' <code><nowiki>{{#invoke:GetShortDescription|main |name=
:'''Result:''' {{#invoke:GetShortDescription|main|name=
==== wikidata or explicit ====
:'''Markup:''' <code><nowiki>{{#invoke:GetShortDescription|main |name=
:'''Result:''' {{#invoke:GetShortDescription|main|name=
=== fallback ===
Line 52 ⟶ 54:
== Requiring this module ==
=== Instances when a table is returned ===
=== objectify_alarm ===▼
Providing a value for {{para|objectify_alarm}} will cause alarming messages (red informational messages) to be returned as [[mw:Extension:Scribunto/Lua reference manual#table|tables]].
Providing a value for {{para|
A table will also be returned in the event that the module is instructed to {{para|prefer|explicit}} (its default), and returns a Wikidata description. If the reason for there being no explicit short description is because it was set to ''[[WP:SDNONE|none]]''; the table will include a value for <code>table.none</code>
See below for examples of these behaviors:
<syntaxhighlight lang="lua">local getShortDescription = require( 'Module:GetShortDescription' ).main
Line 61 ⟶ 67:
local short_description = getShortDescription( {
-- required
name = 'page name',
-- optional
prefer = 'explicit' or 'wikidata',
only = 'explicit' or 'wikidata',
fallback = 'fallback',
objectify_alarm = 'yes',▼
-- optional {{lang}} options▼
report_redlinks = true,
lang_italic = <yes, no, unset, invert, default>,▼
lang_nocat = <yes, y, true, t, on, 1>,▼
lang_size = <CSS font-size e.g. '1.5em'>,▼
lang_cat = <no, n, false, f, off, 0>,▼
lang_rtl = <no (default), yes>▼
▲ lang_italic = <yes, no, unset, invert, default>,
▲ lang_nocat = <yes, y, true, t, on, 1>,
▲ lang_size = <CSS font-size e.g. '1.5em'>,
▲ lang_cat = <no, n, false, f, off, 0>,
▲ lang_rtl = <no (default), yes>
} )
-- If we've requested to report_redlinks or to objectify_alarm then
if type( short_description ) == 'table' then
-- An alarming message has been returned
▲ return short_description.alarm
local alarming_message = short_description.alarm
elseif short_description.redlink then
-- Do something about that
elseif short_description.wikidata then
-- A Wikidata description was returned without being explicitly requested
local wikidata_description = short_description.wikidata
if short_description.none then
-- Because the explicit short desc was 'none'
end
end
end</syntaxhighlight>
<includeonly>{{Sandbox other||
[[Category:Modules using data from Wikidata]]
[[Category:
}}</includeonly>
<noinclude>
[[Category:Module documentation pages]]
</noinclude>
|