Module:GetShortDescription/doc: Difference between revisions

Content deleted Content added
updated module name
No edit summary
 
(3 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:Annotated link]].}}
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=Example Wikipedia}}</nowiki></code>
:'''Result:''' {{#invoke:GetShortDescription|main|name=ExampleWikipedia}}
This is equivalent to stating {{para|prefer|explicit}}; see [[#prefer]] (below).
 
Line 19 ⟶ 21:
 
==== explicit ====
:'''Markup:''' <code><nowiki>{{#invoke:GetShortDescription|main |name=ExampleWikipedia |only=explicit }}</nowiki></code>
:'''Result:''' {{#invoke:GetShortDescription|main|name=ExampleWikipedia|only=explicit}}
 
==== wikidata ====
:'''Markup:''' <code><nowiki>{{#invoke:GetShortDescription|main |name=ExampleWikipedia |only=wikidata }}</nowiki></code>
:'''Result:''' {{#invoke:GetShortDescription|main|name=ExampleWikipedia|only=wikidata}}
 
=== prefer ===
Line 30 ⟶ 32:
 
==== explicit or wikidata ====
:'''Markup:''' <code><nowiki>{{#invoke:GetShortDescription|main |name=ExampleWikipedia |prefer=explicit }}</nowiki></code>
:'''Result:''' {{#invoke:GetShortDescription|main|name=ExampleWikipedia |prefer=explicit}}
 
==== wikidata or explicit ====
:'''Markup:''' <code><nowiki>{{#invoke:GetShortDescription|main |name=ExampleWikipedia |prefer=wikidata }}</nowiki></code>
:'''Result:''' {{#invoke:GetShortDescription|main|name=ExampleWikipedia |prefer=wikidata}}
 
=== fallback ===
Line 52 ⟶ 54:
 
== Requiring this module ==
=== objectify_alarmInstances andwhen report_redlinksa table is returned ===
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]]; this allows for a simple test instead of needing to parse the return value; see below for use case.
'''For use via other modules'''; application of these options via template or direct invocation may cause the return of "table" as a string.
 
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]]; this allows for a simple test instead of needing to parse the return value; see below for use case.
 
Providing a value for {{para|report_redlinks}} will cause the return of a report instead of nothing in the event that the page named is nonexistent (i.e. a [[WP:REDLINK]]) and a search for a {{tlc|short description}} template is processed.
 
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 83 ⟶ 87:
} )
 
-- ifIf we've requested to report_redlinks or to objectify_alarm then
if type( short_description ) == 'table' then
if short_description.alarm then
-- An alarming message has been returned
returnlocal 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||
<!-- Categories below this line; interwikis at Wikidata -->
 
[[Category:Modules using data from Wikidata]]
[[Category:WikiProject Short descriptionsdescription related modules]]
}}</includeonly>
 
<noinclude>
}}</includeonly>
[[Category:Module documentation pages]]
</noinclude>