మాడ్యూల్:Cs1 documentation support: కూర్పుల మధ్య తేడాలు

Content deleted Content added
దిద్దుబాటు సారాంశం లేదు
దిద్దుబాటు సారాంశం లేదు
పంక్తి 1:
require('Module:No globals');
local getArgs = require ('Module:Arguments').getArgs;
 
local cfg = mw.loadData ('Module:Citation/CS1/Configuration'); -- load the configuration module
Line 426 ⟶ 427:
name = name[1]; -- first member of an aliases table is declared canonical
else
for i_, v in ipairs (name) do -- here when override is set; spin throu the aliases to make sure override matches alias in table
if v == override then
name = v; -- declare overrider to the the canonical param for this use case
Line 454 ⟶ 455:
--[[--------------------------< A L I A S _ N A M E S _ G E T >------------------------------------------------
 
experimental code that fetches the alias parameter namenames for the metaparameter; canonical name not fetched<metaparam>. Perhaps basis for some sort of documentation?
 
returns list of aliases for metaparameter <metaparam>
returns empty string when there are no aliases
returns empty string when metaparameter<metaparam> name not found in alias_src{}
 
Some lists of aliases might be better served when a particular alias is identified as the canonical alias for a
particular use case. If, for example, <metaparam> Perodical lists:
'journal', 'magazine', 'newspaper', 'periodical', 'website', 'work'
that order works fine for {{cite journal}} documentation but doesn't work so well for {{cite magazine}}, {{cite news}},
or {{cite web}}. So, for using this function to document {{cite magazine}} the returned value should be the
aliases that are not best suited for that template so we can specify magazine in the override (frame.args[2])
to be the canonical parameter so it won't be listed with the rest of the aliases (normal canonical journal will be)
 
<override> must exist in the alias list
does not apply to identifier parameters (ignored)
 
{{#invoke:cs1 documentation support|alias_name_get|<metaparam>|<override>}}
 
]]
Line 467 ⟶ 479:
local alias_src = cfg.aliases; -- get master list of aliases
local id_src = cfg.id_handlers; -- get master list of identifiers
local args = getArgs (frame);
 
local names;
local meta = frame.args[1];
local override = frame.args[2];
-- if override and ('' == override) then
-- override = nil;
-- end
 
local out = {};
local aliases = {};
 
if alias_src[meta] then
Line 482 ⟶ 495:
aliases = alias_src[meta];
else
local flag; -- so that we know that <override> parameter is a valid alias
local flag;
aliases = {[1] = ''}; -- spoof soto thatpush aliasesalias_src[meta][1] isinto included in outputaliases[2]
for _, v in ipairs (alias_src[meta]) do -- here when override is set; spin through the aliases to make sure override matches alias in table
if v ~= override then
table.insert (aliases, v); -- add all but overridden param to the the aliases list for this use case
else
flag = true; -- set the flag so we know that <override> is a valid alias
end
end
Line 496 ⟶ 509:
end
elseif id_src[meta] then
aliases = id_src[meta].parameters; -- get the id parameter aliases
end
Line 515 ⟶ 528:
--[[--------------------------< I D _ L I M I T S _ G E T >----------------------------------------------------
 
return the limit values for named identifier parameters that have <id> limits (pmc, pmid, ssrn, s2cid); the return value
value used in template documentation and error message help-text
 
{{#invoke:Module:Cs1 documentation support|id_limits_get|<id>}}
 
]]
 
local function id_limits_get (frame)
local args = getArgs (frame)
local id_limits = mw.loadData ('Module:Citation/CS1/Configuration/sandbox').id_limits; -- get id_limits {} table from ~/Configuration
-- local id_limits = cfg.id_limits; -- get id_limits {} table from ~/Configuration; TODO: use this after next cs1|2 update
return args[1] and id_limits[frame.args[1]:lower()] or '';
end
 
"https://te.wikipedia.org/wiki/మాడ్యూల్:Cs1_documentation_support" నుండి వెలికితీశారు