Module:GetShortDescription/sandbox: Difference between revisions

Content deleted Content added
getting there; taking a break; note the |none_is_valid= param...
all done bar the testing and cleanup I think; very tired
Line 30:
local result = { wikidata = wikidata_description }
if isEmpty( args.lang_no ) and notEmpty( wikidata_description_lang ) and wikidata_description_lang ~= 'en' then
-- According to the docs this is possible...
result.language = wikidata_description_lang
result.wikidata = require( 'Module:Lang' )._lang {
wikidata_description_lang,
Line 162:
if prefer == 'explicit' then
local short_description = getShortDescription( title_table, args_name )
if short_description and ( not isNone( short_description.explicit ) or args.none_is_valid ) then return short_description end
return short_description
end
return getWikidataDescription( title, args ) end
if prefer == 'wikidata' then return getWikidataDescription( title, args ) or getShortDescription( title_table, args_name ) end
Line 173 ⟶ 171:
local function main( args )
local result = getDescription( args )
if notEmpty( result ) then
if result.alarm then result.alarm = alarmingMessage( result.alarm ) end
mw.logObject( result )
if args.stringify then
if result.alarm then result = result.alarm else
if result = result.alarmexplicit then return alarmingMessage(or result.alarm ) endwikidata
if args.none_is_nil and isNone( result ) then result = nil end
end
elseif not result.alarm and args.none_is_nil then
local description = result.explicit or result.wikidata
if description and args.none_is_nil and isNone( description ) then result = nil end
end
end
return result
end
Line 189 ⟶ 191:
local args = require( 'Module:Arguments' ).getArgs( frame )
if isEmpty( args ) then return alarmingMessage( 'could not getArgs' ) end
return main( args )
--[[ DON'T FORGET THIS ]]
returnlocal result = main( args )
mw.logObject( result )
return result
--[[ DON'T FORGET THIS ]]
end
 
return p
 
-- p.main{ name="" }
-- p.main{ name="", stringify=true }
 
-- p.main{ name="Wikipedia:example of a double redirect" }
-- p.main{ name="Wikipedia:example of a double redirect", stringify=true }
 
-- p.main{ name="The Partisan", only="wackydata" }
-- p.main{ name="The Partisan", only="wackydata", stringify=true }
 
-- p.main{ name="List of sausages" }
-- p.main{ name="List of sausages", none_is_valid=true }
-- p.main{ name="List of sausages", none_is_valid=true, none_is_nil=true }
 
-- p.main{ name="List of sausages", stringify=true }
-- p.main{ name="List of sausages", none_is_valid=true, stringify=true }
-- p.main{ name="List of sausages", none_is_valid=true, none_is_nil=true, stringify=true }