Difference between revisions of "Module:Taxonbar/confdoc"

From blackwiki
Jump to navigation Jump to search
blackwiki>Tom.Reding
(test if tostring() is necessary)
blackwiki>Tom.Reding
m (simplify slightly)
Line 21: Line 21:
 
end
 
end
 
 
doctable = doctable .. '\n|}'
+
return doctable .. '\n|}'
return doctable
 
 
end
 
end
  
 
return p
 
return p

Revision as of 04:48, 13 April 2018

About

This module allows Module:Taxonbar/conf to automatically update its own documentation table of Wikidata taxon ID properties on Template:Taxonbar/doc.

Usage

{{#invoke:Taxonbar/confdoc|confdoc}}



require('Module:No globals')

local conf = require( "Module:Taxonbar/conf" ) -- configuration module

local p = {}
	
function p.confdoc( frame )
	local doctable = '{| class="wikitable sortable"\n' .. 
					 '|-\n' .. 
					 '! Parameter !! data-sort-type=number style="white-space: nowrap;"| Wikidata ID !! Authority !! Description'
	
	for _, db in pairs( conf.databases ) do
		local param = mw.ustring.lower(db[1])
		local prop = db[3]
		if type(prop) == 'number' then
			local TaxonbarProperty = frame:expandTemplate{ title = 'Taxonbar/Property', args = { prop } }
			doctable = doctable .. '\n' .. 
					   '|-\n' .. 
					   '|' .. param .. '||' .. TaxonbarProperty
		end
	end
	
	return doctable .. '\n|}'
end

return p