Difference between revisions of "Template:Param2"

From Kolmafia
Jump to navigation Jump to search
(Support TypeScript-like optional parameter signature)
(Put optional parameter mark (?) after types, but before parameter name)
Line 1: Line 1:
 
<includeonly>{{
 
<includeonly>{{
 
   type|{{data|{{{name}}}|function{{{func}}}.param{{{param}}}.type}}}}{{
 
   type|{{data|{{{name}}}|function{{{func}}}.param{{{param}}}.type}}}}{{
 +
    #if: {{data|{{{name}}}|function{{{func}}}.param{{{param}}}.optional}}
 +
    | <span title="This parameter is optional">?</span>
 +
  }}{{
 
   #ifeq: {{{format}}} | signature || {{
 
   #ifeq: {{{format}}} | signature || {{
 
     #if: {{data|{{{name}}}|function{{{func}}}.param{{{param}}}}}
 
     #if: {{data|{{{name}}}|function{{{func}}}.param{{{param}}}}}
 
     |&nbsp;{{Pspan|{{data|{{{name}}}|function{{{func}}}.param{{{param}}}}}}}{{
 
     |&nbsp;{{Pspan|{{data|{{{name}}}|function{{{func}}}.param{{{param}}}}}}}{{
      #if: {{data|{{{name}}}|function{{{func}}}.param{{{param}}}.optional}}
 
      | <span title="This parameter is optional">?</span>
 
    }}{{
 
 
       #if: {{data|{{{name}}}|function{{{func}}}.param{{{param}}}.default}}
 
       #if: {{data|{{{name}}}|function{{{func}}}.param{{{param}}}.default}}
 
       |&nbsp;= {{data|{{{name}}}|function{{{func}}}.param{{{param}}}.default}}
 
       |&nbsp;= {{data|{{{name}}}|function{{{func}}}.param{{{param}}}.default}}

Revision as of 14:11, 31 December 2020


Despite the similar name, this is completely different from [[Template:Param]].

Template parameters

ParameterDescriptionTypeStatus
Function page namename

Name of a function page. '''This must be a data page.'''

Pagerequired
Overloaded function numberfunc

A function page may describe multiple overloaded functions under the same name. This parameter allows you to select one. Allowed values are 1-5, inclusive.

Numberrequired
Parameter numberparam

Specify which parameter to extract. Allowed values are 1-5, inclusive.

Numberrequired
Rendering formatformat

"" (empty string) = show everything, "signature" = only show parameter types (i.e. function signature). Default value is empty string (show everything).

Lineoptional

Examples

Types and parameters

*"{{param2|name=visit_url|func=1|param=1}}"
*"{{param2|name=visit_url|func=2|param=1}}"
*"{{param2|name=visit_url|func=2|param=2}}"
*"{{param2|name=visit_url|func=2|param=3}}"

Types only

*"{{param2|name=visit_url|func=1|param=1|format=signature}}"
*"{{param2|name=visit_url|func=2|param=1|format=signature}}"
*"{{param2|name=visit_url|func=2|param=2|format=signature}}"
*"{{param2|name=visit_url|func=2|param=3|format=signature}}"