Difference between revisions of "Module:Taxonbar/confdoc"

From blackwiki
Jump to navigation Jump to search
blackwiki>Tom.Reding
(better non-prop avoidance)
blackwiki>Tom.Reding
m (interesting)
Line 12: Line 12:
 
for _, db in pairs( conf.databases ) do
 
for _, db in pairs( conf.databases ) do
 
local param = mw.ustring.lower(db[1])
 
local param = mw.ustring.lower(db[1])
local prop = db[3]
+
local prop = tonumber(db[3])
 
if prop > 0 then --avoid 'Wikidata' & non-props
 
if prop > 0 then --avoid 'Wikidata' & non-props
prop = tostring(prop)
+
prop = db[3]
 
doctable = doctable .. '\n' ..  
 
doctable = doctable .. '\n' ..  
 
  '|-\n' ..  
 
  '|-\n' ..  

Revision as of 18:33, 12 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 = tonumber(db[3])
		if prop > 0 then --avoid 'Wikidata' & non-props
			prop = db[3]
			doctable = doctable .. '\n' .. 
					   '|-\n' .. 
					   '|' .. param .. '||{{Taxonbar/Property|' .. prop .. '}}'
		end
	end
	
	doctable = doctable .. '\n|}'
	return doctable
end

return p