Module:Template documentation

    From TestWiki
    --

    --this module implements a template documentation that updates automatically when the template has been edited --do not invoke directly, use the template {{Template documentation}}


    local p = {} -- p stands for package
    
    local ruler    = '<hr style="background-color:#b3b7ff; clear:both; height:.7ex; margin:1em 0;" />'
    --local template = mw.site.namespaces.Template.name .. ':'
    
    local anzeige  = '<div style="background-color: #aaa;width:90%; border-radius: 1em; box-shadow: 0.1em 0.1em 0.5em rgba(0,0,0,0.75);;padding:0.5em;"><div style="background-color: #fff;padding:1em; border-radius: 0.5em;"><code style="white-space:pre-wrap">'
    local anzeige_ = '</code></div></div>'
    
    function p.doc(frame)
    	-- this function creates the documentation page on templates
    	-- the documentation is included from the subpage /doc
    	-- if the subpage does not exist a hint is displayes
    	
        local ns       = frame.args.ns or mw.site.namespaces.Template.name
    	local vorlage  = frame.args.vorlage or mw.title.getCurrentTitle().text
        local template = ns .. ':'   -- namespace of including page with colon
    	local doc      = frame.args.doc or 'doc' --- change name of documentation subpage if wanted
    	local preload  = frame.args.preload or 'Template:Template documentation/preload-doc'
    	local cat      = frame.args.cat or frame.args.kat or frame.args.kategorie or 'Templates'
    	local nocat    = frame.args.nocat or frame.args.nokat or frame.args.keinekat or frame.args.ns -- do not categorize
    	local hidden   = not(frame.args.show or frame.args.zeigen) -- hidden template (default)
    
    	local _vorlage = template .. vorlage
    	local dok      = vorlage .. '/' .. doc   -- name without namespace
    	local _doc     = template .. dok         -- name with namespace prefix
    	-- end of page link
    	local seitenende = '<h2 style="opacity: 0; visibility: hidden; width: 1px; height: 1px>bottom</h2>' 
    	.. '<div class="metadata" style="z-index: 1; width: 200px; position: fixed; height: auto; top: 8em; right: 0.5em; font-size: 0.8em; white-space: nowrap; overflow-y: hidden; overflow-x: hidden;">__TOC__</div>' 
    
    	local _, mycat, result = '', '', ''
    
    	local verborgen = (hidden and '<div>The template <span style="font-family:&quot;Consolas&quot;, monospace; background-color:yellow;padding:0 0.5em">' .. vorlage .. '</span> is hidden and visible only in embedding pages.</div>' ) or ''
    
    	local duhast = 'The template documentation has been included by the command <code>{{#invoke:Template documentation|doc|...}}</code> using subpage <code>' .. dok .. '</code>. The documentation of [[Template:Template documentation|Template documentation]] contains more information about using the module and its paramters.'
    	
    	local diedokumentationsunterseite = '<div class="messagebox" style="margin-top:1em; clear: both; border: 2px dotted #666666; padding: 0.6em; background-color: #ccffff; text-align: center; ">The subpage for template documentation <code>{{[[' .. _doc .. '|' .. dok..']]}}</code> does not exist.</div>'
    	
    	local damitdie = 'Creating the documentation subpage <code>{{[[' .. _doc .. '|' .. dok..']]}}</code> for the template <code>{{[[' .. _vorlage .. '|' .. vorlage .. ']]}}</code> per link or input box below.\n\n'
    	
    	local input = '<div style="float:left" class="neu"><inputbox>\ntype=create\nbreak=no\nwidth=40em\nbuttonlabel=create subpage\ndefault=' .. _doc .. '\npreload=' .. preload .. '\n</inputbox></div><div style="clear:both;"></div>'
    	local inputbox = frame:preprocess('\n\n' .. input)
    	local subpages = frame:preprocess('\n==Subpages==\n{{:Special:PrefixIndex/' .. _vorlage .. '/}}')
    
        local docu_info = '{| class="plainlinks" id="Dokumentation.Info" style="border-collapse:collapse; margin:2px 0;"\n' .. '| class="noviewer" style="padding:5px; vertical-align:top; width:40px;" | [[Datei:Info-Icon.png|30px]]\n' .. '| style="padding:0; width:100%;" |<ul>' .. '{{Special:PrefixIndex/' .. template .. vorlage .. '/}}'
        local dokgibts = p.gibts(dok,ns)
    	if dokgibts then -- Unterseite doc gibts
    		local doku, layout, bearbeiten
    		local linkliste = frame:preprocess('[{{fullurl:Special:WhatLinksHere/' .. _vorlage .. '|hideredirs=1&hidelinks=1}} template usage]')
    		local Unterseiten = '<h2>Subpages</h2>' .. frame:preprocess('{{Special:PrefixIndex/' .. _vorlage .. '/}}')
    		doku = frame:expandTemplate{ title = _doc, args = {} }
    		layout = p.layout(frame)
    		bearbeiten = p.bearbeiten(_vorlage)
    		
    		-- Link zu Verwendungen der Vorlage und Unterseiten (Parameter zum Einbinden vorsehen?)
    		local docu_info = frame:preprocess('<references />') .. ruler .. '\n{| class="plainlinks" id="Dokumentation.Info" style="border-collapse:collapse; margin:2px 0;"\n' .. '| class="noviewer" style="padding:5px; vertical-align:top; width:40px;" | [[File:Info-Icon.png|30px]]\n' .. '| style="padding:0; width:100%;" |<ul><li>This documentation is located on an [[' .. _doc .. '|included subpage]] <span style="font-size:85%; margin-left:1em;">&#91;[' .. tostring(mw.uri.fullUrl( _doc, 'action=edit')) .. ' edit]&#93;</span>.</li><li>' .. linkliste .. '</li></ul>\n|}'		
    		
    		result = bearbeiten .. verborgen .. ruler .. layout .. doku .. docu_info .. Unterseiten
    	else
    		local mytitel = frame:preprocess('\n==Raw content==\n')
    		local ShowMe = p.wrap(p.Inhalt(vorlage,ns))
    		if doc == 'none' then -- keine Dokumentationsunterseite gewünscht
    		  duhast = ''
    		  diedokumentationsunterseite = ''
    		  damitdie = ''
    		  inputbox = ''
    		end
    		result = duhast .. diedokumentationsunterseite .. damitdie .. inputbox .. mytitel .. ShowMe .. subpages
    	end -- Unterseite doc gibts
    	
    	-- Kategorisieren
    	if not nocat then -- die Vorlage soll kategorisiert werden
    		mycat = '[[category:' .. cat ..']]'
    	end
        return result .. mycat .. seitenende
    	
    end
    
    function p.bearbeiten(vorlage)
    	
    	-- this function creates a box with a dotted border with links to
    	-- editing, history ... of the template
    	
    	local frame = mw.getCurrentFrame()
    	local _vorlage = vorlage
    	
    	local divspan = '<div style="margin: 0.5em;border: 2px dotted #666666; padding: 0.5em;display:inline-block"><span class="mw-editsection plainlinks" style="padding:0em 1em 0em 0em;" >'
    	local edit    = mw.uri.fullUrl( _vorlage, 'action=edit' )
    	local history = mw.uri.fullUrl( _vorlage, 'action=history' )
    	local purge   = mw.uri.fullUrl( _vorlage, 'action=purge' )
    	local qqx     = mw.uri.fullUrl( _vorlage, 'uselang=qqx' )
    	local info    = mw.uri.fullUrl( _vorlage, 'action=info' )
    	
    	local result = '[' .. tostring(edit) .. ' edit] · [' .. tostring(history) .. ' history] · [' .. tostring(purge) .. ' refresh] · [' .. tostring(qqx) .. ' system messages] · [' .. tostring(info) .. ' page info]'
    	result = divspan .. result .. '</span></div>\n'
    	return result 
    end
    
    function p.layout(frame)
    	-- this procedure creates a blue info box with header "Documentation"
    	-- and an icone File:Template-info.png and links for editing the documentation subpage
    
    	local frame = mw.getCurrentFrame()
    	local vorlage = frame.args.vorlage or mw.title.getCurrentTitle().text
    	local doc = frame.args.doc or 'doc' --- rename documentation subpage
    	
        local ns       = frame.args.ns or mw.site.namespaces.Template.name
        local template = ns .. ':'
        
    	local _vorlage = template .. vorlage
    	local dok = vorlage .. '/' .. doc   -- name without namespace
    	local _doc = template .. dok        -- name with namespaceprefix
    	
    	local divspan = '<div style="margin:1em; clear: both; border: 2px dotted #666666; padding: 0.6em; background-color:#ccffff;"><div style="padding-bottom:3px; border-bottom:1px solid #aaa; margin-bottom:1em;"><span style="font-size:150%">[[File:Template-info.png|50px]] Template documentation</span><span class="mw-editsection plainlinks">'
    	
    	local edit    = mw.uri.fullUrl( _doc, 'action=edit' )
    	local history = mw.uri.fullUrl( _doc, 'action=history' )
    	local purge   = mw.uri.fullUrl( _doc, 'action=purge' )
    	local info    = mw.uri.fullUrl( _doc, 'action=info' )
    	
    	local result = ' [' .. tostring(edit) .. ' edit]&nbsp;·&nbsp;[' .. tostring(history) .. ' history]&nbsp;·&nbsp;[' .. tostring(purge) .. ' refresh]&nbsp;·&nbsp;[' .. tostring(info) .. ' page infos]'
    	result = divspan .. result .. '</span></div>\n\n'
    	
    	local small = "''<small>This [[Template:Template_documentation|template documentation]] is included from [[" .. _doc .. "]]</small>''</div>"
    	return result .. small
    
    end
    
    function p.dokuseite(frame)
    	-- this modul is included in the documentation subpage only not in the documentation itself
    	-- creates a link to the template and a box with edit-links
    	-- the page is categorized into the category template documentation
    
       local myns      = mw.title.getCurrentTitle().namespace -- only for template namespace
       if myns ~= 10 then return end  -- if not template namespace do nothing
    	
       local _vorlage = frame.args.vorlage or mw.title.getCurrentTitle().baseText
       local ns       = frame.args.ns or mw.site.namespaces.Template.name
       local vorlage  = ns .. ':' .. _vorlage
       local dok      = frame.args.dok or 'doc'
       local _dok     = vorlage .. '/' .. dok
    
       local rohhtml = '<table style="border-style:solid; margin-bottom:2px; margin-top:2px; border-color:MediumSlateBlue"><tr><td>[[File:Info-Icon.png|30px]]</td><td style="width: 100%;">This is the [[Template:Template_documentation|documention subpage]] ot the [[' .. vorlage .. '|<b>template ' .. _vorlage .. '</b>]]</td></tr></table>'
    
       local divspan = '<div style="margin-bottom: 0.5em;border: 2px dotted #666666; padding: 0.5em;display:inline-block"><span class="mw-editsection plainlinks" style="padding:0em 1em 0em 0em;" >'
       local edit    = mw.uri.fullUrl( _dok,    'action=edit' )
       local history = mw.uri.fullUrl( _dok,    'action=history' )
       local purge   = mw.uri.fullUrl( _dok,    'action=purge' )
       local qqx     = mw.uri.fullUrl( _dok,    'uselang=qqx' )
       local info    = mw.uri.fullUrl( _dok,    'action=info' )
       local editv   = mw.uri.fullUrl( vorlage, 'action=edit' )
       local infov   = mw.uri.fullUrl( vorlage, 'action=info' )
    
       local result = '[' .. tostring(edit) .. ' edit] · [' .. tostring(history) .. ' history] · [' .. tostring(purge) .. ' refresh] · [' .. tostring(qqx) .. ' system messages] · [' .. tostring(info) .. ' page infos] · [' .. tostring(editv) .. ' edit template] · [' .. tostring(infov) .. ' template page information]'
       result = divspan .. result .. '</span></div>\n'
    
       return result .. rohhtml .. ' [[category:Template Documentation]]'
    end
    
    function p.doku(frame)
    	
    	-- dieser Modul konstruiert die Dokumentationsunterseite vorlage/doc
    	-- this is the main modul for constructing the documentation subpage
    
    	local myns      = mw.title.getCurrentTitle().namespace -- for namespage template only
    	if myns ~= 10 then return end  -- if not template ns do nothing
       
    	-- parameters with default values
    	local count    = frame.args.count or 0 
    	local vorlage  = frame.args.vorlage or mw.title.getCurrentTitle().text
    	
    	local ns       = frame.args.ns or mw.site.namespaces.Template.name
    	local erzeugt  = frame.args.text or "misses a description"
    	local rubrik   = frame.args.rubrik or "AlleListen"
    	local trnzn    = string.gsub(frame.args.trennzeichen or ',;','%p', '%%%0')  -- list of delimiter symbols
    	local klappbar = frame.args.klappbar
    	local geklappt = frame.args.geklappt
    
    	-- parameters without defaults
    	local expand = not frame.args.noexpand   -- supresses the expanding of the template noexpand=y
    	local render = not frame.args.norender   -- supresses the rendering of the template norender=y
    	
    	-- Variablen für Formatierung
    	local div_blue = '<div style="width:100%;margin-top:1em; clear: both; border: 2px solid blue; padding: 0.6em">'
    	local div_inlineblock = '<div><div style="display:inline-block;background:#e6f2ff;color:black;padding: 0.1em 0.8em;width:auto">'
    	local div_dotted = '</div></div><div style="width:95%;margin-top:1em; clear: both; border: 2px dotted #666666; padding: 0.6em">'
    	local ergibt_gerendert = div_inlineblock .. 'rendered:' .. div_dotted
    	local ergibt_expandiert = div_inlineblock .. 'unfolds as wikitext:' .. div_dotted
    
    	if vorlage:match('%a+$') == 'doc' then vorlage = vorlage:match('(.+)%/%a+$') end  -- when docu sub then remove doc
    	-- zusammengesetzte Texte
    	
    	if ns == mw.site.namespaces.Template.name then -- Vorlage ohne "Vorlage:"
    		vorlage_ns = vorlage
    	else
    		vorlage_ns = ns .. ':' .. vorlage 
    	end
    	
    	local tl = '<span style="font-family:&quot;Consolas&quot;, monospace;">{{[[' .. ns .. ':' .. vorlage .. '|' .. vorlage .. ']]' .. '}}</span> '
    	local diese_vorlage='__NOTOC__\nThe template ' .. tl .. erzeugt
    	local _vorlage = '{{' .. vorlage_ns -- Vorlage mit geschweiften Klammern zu Beginn und Namespace
    	local _vorlage_ = _vorlage .. '}}'            -- Vorlage von geschweiften Klammern umschlossen
    	
    	-- lokale Parameter
    	local vorlagenliste, i, template,ShowMe = ''
    	local parametertabelle, muster, anw0, kopiervorlage = '', '', '', ''
    	local expanded, rendered
    	
    	ShowMe = frame:preprocess('\n==Wikitext==\n') .. p.wrap(p.Inhalt(vorlage,ns)) -- Vorlageninhalt anzeigen
    	--if 1 then return vorlage .. mw.title.getCurrentTitle().baseText .. mw.title.getCurrentTitle().text end
    	if p.gibts(rubrik) then vorlagenliste = '<div>' .. frame:expandTemplate{ title = rubrik, args = { } } .. '</div>' end
    	
    	--erster Abschnitt, Beschreibung der Funktion der Vorlage
    	local vorlagen_intro = diese_vorlage .. vorlagenliste
    
    	--Parameterliste abarbeiten
    	parametertabelle, kopiervorlage = p.tabelle()
    	parametertabelle = frame:preprocess('\n==Parameter list==\n') .. parametertabelle
    	
    	kopiervorlage  = frame:preprocess('\n==Copy&paste==\n<code>') .. _vorlage .. kopiervorlage .. "}}</code>" -- Kopiervorlage zur Dokumentationsanwendung mit Auflistung aller Parameter
    
    	-- Vorlagenanwendung mit Defaulteinstellungen
    	
    	local nurmit = frame.args.omp  -- Vorlage nur mit Parameter aufrufen omp=1
    	if not nurmit then
    		anw0 = frame:preprocess('\n==Application==\n') .. p.anwendung(_vorlage_,render,expand,klappbar, geklappt)
     	end
    	-- Anwendungsbeispiele
    	-- alle Parameterwerte mit Beistrich oder Strichpunkt getrennt
    	-- wie im Vorlagenaufruf, nur mit einem anderen Trennzeichen
    	
    	for i=1,10 do -- mehr als 10 Anwendungsbeispiele werden kaum sinnvoll sein
    		 local u, liste, expd, rndr, ergibt, anwendung = frame.args["aw" .. i], '', '', '', ''
    		 local diese_anwendung
    		 if u and u~="" then -- Anwendungsbeispiel mit Index i gefunden
    			local raw  = frame.args['raw' .. i] -- die i-te Anwendung im Rohformat ausführen
    			local noexpd = frame.args['noexpand' .. i]
    			local norndr = frame.args['norender' .. i]
    			local expd   = frame.args['expand' .. i]
    			local rndr   = frame.args['render' .. i]
    			local lrender = render
    			local lexpand = expand
    			
    			if render then  -- Indikator zum Ausführen der Vorlage lokal überschreiben
    				if norndr then lrender = false end
    			else
    				if rndr   then lrender = true  end
    			end
    			if expand then  -- Indikator zum Expandieren der Vorlage lokal überschreiben
    				if noexpd then lexpand = false end
    			else
    				if expd   then lexpand = true  end
    			end
    
    			if raw then
    				local _ = u:gsub('!','|')
    				_ = _:gsub('{','{{')
    				_ = _:gsub('}','}}')
    				diese_anwendung = _
    			else
    				liste = '|' .. string.gsub(u, '[' .. trnzn .. ']','|') .. '}}'  -- Trennzeichen in senkrechte Striche umwandeln, default ist ',' oder ';', als Pattern %,%;
    					diese_anwendung = _vorlage .. liste
    			end
    			--if 1 then return diese_anwendung end
    			anwendung = p.anwendung(diese_anwendung,lrender,lexpand,klappbar, geklappt)
    			muster = muster .. anwendung
    			-- if 1 then return '<code><nowiki>anwendung ' .. anwendung .. '</nowiki></code>' end
    		 end -- u and u~=""
    	end -- for i=1,10 do 
    
    	return vorlagen_intro .. parametertabelle .. kopiervorlage .. anw0 .. muster .. ShowMe --vorlagen_intro .. parm_table .. anw0
    
    end
    
    function p.anwendung(vorlage, xender, xxpand, klappbar, geklappt)
    	-- this procedure renders the template
    	-- der Parameter vorlage enthält den kompletten Aufruftext inklusiver sämtlicher Parameter
    	-- wie er in einer Wikiseite normalerweise auftritt
    	-- z.B. {{vorlagenname|parameter1=wert1|parameter2=wert2|...}}
    	-- das Ergebnis der ausgewerteten Vorlage wird in der lokalen Variablen "processed" gespeichert
    	-- anschließend werden alle Wikicode-Zeichen mittels mw.text.nowiki in HTML-Entitäten umgewandelt und in der Variablen "expanded" gespeichert
    	-- https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#mw.text.nowiki
    	-- folgende Zeichen: '"', '&', "'", '<', '=', '>', '[', ']', '{', '|', '}'
    	-- weitere Ersetzungen siehe Manual
    	-- render und expand steuern, ob das Ergebnis der Vorlagenauswertung als expandierter Wikitext und als Vorlageneinbindung angezeigt werden soll
    	-- klappbar und geklappt erzeugen einklappbare Abschnitte
    	-- Rückgabewert: ausgewertete Vorlage: 
    	local frame = mw.getCurrentFrame()
    	local processed, class = frame:preprocess(vorlage), '>'
    	
    	local expanded, gerendert, _ = '', '', ''
    	
    	if klappbar or geklappt then
    		if klappbar then class= class .. ' class =" mw-collapsible' end
    		if geklappt then class = class .. ' class =" mw-collapsible mw-collapsed' end
    		class = class .. '">'
    	end
    
     	-- variables for formatting
    	local div_blue = '<div style="width:100%;margin-top:1em; clear: both; border: 2px solid blue; padding: 0.6em"><code>' .. vorlage .. '</code>'
    	local div_inlineblock = '<div><div style="display:inline-block;background:#e6f2ff;color:black;padding: 0.1em 0.8em;width:auto">'
    	local div_dotted = '<div style="width:95%;margin-top:1em; clear: both; border: 2px dotted #666666; padding: 0.6em "'
    	local ergibt_gerendert = 'renders as</div></div>' .. div_dotted .. '>'
    	local ergibt_expandiert = div_inlineblock .. 'unfolds as wikitext:' .. '</div></div>' .. div_dotted .. class
    
    	if not xxpand then
    		 ergibt_gerendert= ergibt_gerendert
    	end
    	ergibt_gerendert= div_inlineblock .. ergibt_gerendert
    	
    	expanded = '<code style="white-space: pre-wrap;">' .. mw.text.nowiki(processed) .. '</code></div>'
    	gerendert = processed .. '</div>'
    	
    	if xxpand then _ = ergibt_expandiert .. expanded end
    	if xender then _ = _ .. ergibt_gerendert .. gerendert end
    
    	return div_blue .. _ .. '</div>' 
    end
    
    function p.tabelle(frame)
    	-- dieser Modul erzeugt eine Tabelle mit den Parameterwerten
    	-- zu jedem Parameter sollte ein Beschreibungstext angegeben werden
    	-- es können beliebig viele Parameter eingetragen werden: count
    	-- als zweiter Rückgabewert wird eine Kopiervorlage mit einer Liste aller vorhandenen Parameter übermittelt
    	-- weiters kann die Breite der Tabelle sowie der Spalten geändert werden
    	
    	local pframe, xxx, parm_table = mw.getCurrentFrame(), '', '' --:getParent()
    	local count = tonumber(pframe.args.count) or 0
    	local tabwidth  = pframe.args.tabwidth  -- ändern der Breiteneinstellungen
    	local descwidth = pframe.args.descwidth
    	local namewidth = pframe.args.parmwidth
    	local defwidth  = pframe.args.defwidth
    	local mandwidth = pframe.args.mandwidth
    	
    	-- Konstante für Formatierung
    	local table_header = '<table style="width:80%;margin-left: 0;border: 0px;border-bottom: 1px solid #666;border-collapse: collapse;text-align: left;padding: 0.5em 0 0 0;box-shadow: 4px 4px 4px #ccc;"><caption style="background-color:#666; border-radius: 1em 1em 0 0;color:#666;font-family: serif;font-size: 0.4em;border:1px solid #666;padding: 0.5em 0 0 0;>x</caption><tr style="background-color: #666;color: #fff;font-size:1.2em;font-family: serif;border:1px solid #666e;padding: 0.5em 0 0 0;"><th style="width:14%;padding-left:0.5em">name</th><th style="width:50%;" colspan="2">description</th><th style="width:25%">default</th><th style="width:16%">status</th></tr>'
    	local table_end ='</table>'
    	
    	-- change column widths of the table
    	if tabwidth  then table_header = table_header:gsub('width:80%%', 'yidth:' .. p.string2pattern(tabwidth),1) end
    	if descwidth then table_header = table_header:gsub('width:50%%', 'yidth:' .. p.string2pattern(descwidth),1) end
    	if namewidth then table_header = table_header:gsub('width:14%%', 'yidth:' .. p.string2pattern(namewidth),1) end
    	if defwidth  then table_header = table_header:gsub('width:25%%', 'yidth:' .. p.string2pattern(defwidth),1) end
    	if mandwidth then table_header = table_header:gsub('width:16%%', 'yidth:' .. p.string2pattern(mandwidth),1) end
    	table_header = table_header:gsub('yidth:', 'width:')
    	
    	--Parameterliste abarbeiten
    	for i = 1,count do 
    		local _, u, j, x, desc, def, mand, fort
    		j = tostring(i)
    		x = pframe.args["p" .. j]
    		if x and x ~= '' then -- es gibt einen Eintrag pi
    			desc = pframe.args["desc" .. j] or pframe.args["t" .. j] or 'description missing' -- Parameterbeschreibung
    			def  = pframe.args["def" .. j]  or pframe.args["d" .. j] or 'empty'               -- Standardeinstellung
    			mand = pframe.args["mdt" .. j]  or pframe.args["m" .. j]                         -- verpflichtende Eingabe ja/nein
    			fort = pframe.args["fort" .. j] or pframe.args["f" .. j]  -- Fortsetzungszeile der Beschreibung
    			gort = pframe.args["gort" .. j] or pframe.args["g" .. j]  -- Fortsetzungszeile der Beschreibung
    			zeile = p.zeile(x, desc, def, mand, fort, gort)
    			parm_table = parm_table .. zeile
    			xxx = xxx .. '|' .. x .. '=' -- <br>' kein Zeilenumbruch in der Kopiervorlage mehr (=lästig!)
    		end
    	end -- for i = 1,count do
    
    	if count == 0 or count == "0" then -- Abschnitt Parametertabelle fertigstellen
    		parm_table ='<div style=\"font-weight:bold\">none</div>'
    	else
    		parm_table = table_header .. parm_table .. table_end
    	end
    	
    	return parm_table, xxx
    end
    
    function p.gibts(name, namespace)
      local name = name
      local space = namespace or 'template'
      local titel = mw.title.new(space .. ":" .. name)
      if titel == nil then return false end
      if titel.exists then return titel end
      return false
    end
    
    function p.Show(titel)
    	-- titel: muss eine Wiki-Seite sein
    	-- diese Funktion liefert den Inhalt der Seite zurück, wobei alle Sonderzeichen in HTML-Entitäten umgewandelt werden
    	-- sodass nur der Rohinhalt angezeigt wird, aber keine Inhalte geparst werden
    	local titel = titel
    	if titel.exists then
    		return mw.text.nowiki(titel:getContent())
    	else
    		return
    	end
    end
    
    function p.Inhalt(titel,ns)
    	-- titel: Titel einer Seite (default: aufrufende Root-Seite)
    	-- ns: Namespace (default: Template)
    	local space     = ns or mw.site.namespaces.Template.name
    	local text      = titel or mw.title.getCurrentTitle().baseText
        local wseite    = mw.title.new(titel, space)  -- Wikiseite als title-Objekt	
    	if wseite.exists then
    		return mw.text.nowiki(wseite:getContent())
    	else
    		return
    	end
    end
    
    function p.string2pattern(str)
    	return string.gsub(str, "%%", "%%%%")
    end
    
    function p.zeile(pname, beschreibung, default, optional,fort,gort)
      -- erzeugt eine Tabellenzeile für die Parameterliste
    
      local _ = ""
      local pname = pname
      local beschreibung = beschreibung
      local default = default or "empty"
      local optional = optional
      
      if optional == nil or optional=="" then optional="optional" else optional="mandatory" end
    
      local teil1 = [[<tr style="background-image: linear-gradient(#f9f9f9, #e3e3e3); border:none; border-left: 1px solid #666; border-right: 1px solid #666;">
    <td style="font-family: monospace;font-size:1.2em;padding-left:0.5em; border:none;">]]
      local teil2 = '</td><td colspan="2" style="border:none;">'
      local teil3 = '</td><td style="border:none;"><span style="color:#777; font-variant:small-caps">'
      local teil4 = '</span></td><td style="border:none;">'
      local teilf = '</td><td colspan="4" style="border:none;">'
      local teil5 = '</td></tr>'
    
      _ = teil1 .. pname .. teil2 .. beschreibung .. teil3 .. default .. teil4 .. optional .. teil5
      if fort and fort ~="" then -- Fortsetzungszeile
        _ = _ .. teil1 .. teilf .. fort .. teil5
      end
      if gort and gort ~="" then -- 2. Fortsetzungszeile
        _ = _ .. teil1 .. teilf .. gort .. teil5
      end
      return _
    end
    
    function p.showme(frame)
    	local vorlage = frame.args.vorlage or (mw.title.getCurrentTitle().nsText .. ':' .. mw.title.getCurrentTitle().text)
    	local _
    	_ = frame:preprocess(anzeige .. vorlage .. anzeige_)
    	return _
    end
    
    function p.wrap(s)
    	return anzeige .. tostring(s) .. anzeige_
    end
    
    return p