Template:Function2: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
   |'''<code>{{{function1.return_type}}} {{{name}}}({{
   |'''<code>{{{function1.return_type}}} {{{name}}}({{
     #if: {{{function1.parameter1|}}}
     #if: {{{function1.parameter1|}}}
     |{{#if: {{{function1.parameter1.optional|}}}|<nowiki>[</nowiki>}}{{{
     |{{{User:Philmasterplus/FunctionDeclaration
    function1.parameter1.type|{{error|Parameter 'function1.parameter1.type' is missing for User:Philmasterplus/TemplateSandbox2}}}}} {{Pspan|{{{function1.parameter1}}}}}{{
      |name={{{name}}}
    #if: {{{function1.parameter1.default|}}}| = {{{function1.parameter1.default|}}}}}{{
      |return_type={{{function1.return_type1}}}
    #if: {{{function1.parameter1.optional|}}}|<nowiki>]</nowiki>}}
      |param1={{{function1.param1}}}
  }}{{
      |param1.type={{{function1.param1.type}}}
    #if: {{{function1.parameter2|}}}
      |param1.optional={{{function1.param1.optional}}}
    |{{#if: {{{function1.parameter2.optional|}}}|<nowiki>[</nowiki>}}, {{{
      |param1.default={{{function1.param1.default}}}
       function1.parameter2.type|{{error|Parameter 'function1.parameter2.type' is missing for User:Philmasterplus/TemplateSandbox2}}}}} {{Pspan|{{{function1.parameter2}}}}}{{
      |param2={{{function1.param2}}}
    #if: {{{function1.parameter2.default|}}}| = {{{function1.parameter2.default|}}}}}{{
      |param2.type={{{function1.param2.type}}}
    #if: {{{function1.parameter2.optional|}}}|<nowiki>]</nowiki>}}
      |param2.optional={{{function1.param2.optional}}}
  }}{{
      |param2.default={{{function1.param2.default}}}
    #if: {{{function1.parameter3|}}}
      |param3={{{function1.param3}}}
     |{{#if: {{{function1.parameter3.optional|}}}|<nowiki>[</nowiki>}}, {{{
      |param3.type={{{function1.param3.type}}}
      function1.parameter3.type|{{error|Parameter 'function1.parameter3.type' is missing for User:Philmasterplus/TemplateSandbox2}}}}} {{Pspan|{{{function1.parameter3}}}}}{{
      |param3.optional={{{function1.param3.optional}}}
    #if: {{{function1.parameter3.default|}}}| = {{{function1.parameter3.default|}}}}}{{
      |param3.default={{{function1.param3.default}}}
    #if: {{{function1.parameter3.optional|}}}|<nowiki>]</nowiki>}}
      |param4={{{function1.param4}}}
  }})</code>'''{{
       |param4.type={{{function1.param4.type}}}
   #if: {{{function1.parameter1|}}}
      |param4.optional={{{function1.param4.optional}}}
   |<ul><li>'''{{{function1.parameter1.type}}} {{Pspan|{{{function1.parameter1}}}}}''': {{{function1.parameter1.description}}}</li>}}{{
      |param4.default={{{function1.param4.default}}}
   #if: {{{function1.parameter2|}}}
      |param5={{{function1.param5}}}
   |<li>'''{{{function1.parameter2.type}}} {{Pspan|{{{function1.parameter2}}}}}''': {{{function1.parameter2.description}}}</li>}}{{
      |param5.type={{{function1.param5.type}}}
   #if: {{{function1.parameter3|}}}
      |param5.optional={{{function1.param5.optional}}}
   |<li>'''{{{function1.parameter3.type}}} {{Pspan|{{{function1.parameter3}}}}}''': {{{function1.parameter3.description}}}</li>}}{{
      |param5.default={{{function1.param5.default}}}
   #if: {{{function1.parameter1|}}}|</ul>}}{{
     }})</code>'''{{
  #if: {{{function1.param1|}}}
  |<ul><li>'''{{{function1.param1.type}}} {{Pspan|{{{function1.param1}}}}}''': {{{function1.param1.description}}}</li>}}{{
  #if: {{{function1.param2|}}}
  |<li>'''{{{function1.param2.type}}} {{Pspan|{{{function1.param2}}}}}''': {{{function1.param2.description}}}</li>}}{{
   #if: {{{function1.param3|}}}
   |<li>'''{{{function1.param3.type}}} {{Pspan|{{{function1.param3}}}}}''': {{{function1.param3.description}}}</li>}}{{
   #if: {{{function1.param4|}}}
   |<li>'''{{{function1.param4.type}}} {{Pspan|{{{function1.param4}}}}}''': {{{function1.param4.description}}}</li>}}{{
   #if: {{{function1.param5|}}}
   |<li>'''{{{function1.param5.type}}} {{Pspan|{{{function1.param5}}}}}''': {{{function1.param3.description}}}</li>}}{{
   #if: {{{function1.param1|}}}|</ul>}}{{
   #if: {{{function1.short_description|}}}|: {{{function1.short_description}}}}}
   #if: {{{function1.short_description|}}}|: {{{function1.short_description}}}}}
}}
}}
Line 34: Line 45:
   |'''<code>{{{function2.return_type}}} {{{name}}}({{
   |'''<code>{{{function2.return_type}}} {{{name}}}({{
     #if: {{{function2.parameter1|}}}
     #if: {{{function2.parameter1|}}}
     |{{#if: {{{function2.parameter1.optional|}}}|<nowiki>[</nowiki>}}{{{
     |{{{User:Philmasterplus/FunctionDeclaration
    function2.parameter1.type|{{error|Parameter 'function2.parameter1.type' is missing for User:Philmasterplus/TemplateSandbox2}}}}} {{Pspan|{{{function2.parameter1}}}}}{{
      |name={{{name}}}
    #if: {{{function2.parameter1.default|}}}| = {{{function2.parameter1.default|}}}}}{{
      |return_type={{{function2.return_type1}}}
    #if: {{{function2.parameter1.optional|}}}|<nowiki>]</nowiki>}}
      |param1={{{function2.param1}}}
  }}{{
      |param1.type={{{function2.param1.type}}}
    #if: {{{function2.parameter2|}}}
      |param1.optional={{{function2.param1.optional}}}
    |{{#if: {{{function2.parameter2.optional|}}}|<nowiki>[</nowiki>}}, {{{
      |param1.default={{{function2.param1.default}}}
       function2.parameter2.type|{{error|Parameter 'function2.parameter2.type' is missing for User:Philmasterplus/TemplateSandbox2}}}}} {{Pspan|{{{function2.parameter2}}}}}{{
      |param2={{{function2.param2}}}
    #if: {{{function2.parameter2.default|}}}| = {{{function2.parameter2.default|}}}}}{{
      |param2.type={{{function2.param2.type}}}
    #if: {{{function2.parameter2.optional|}}}|<nowiki>]</nowiki>}}
      |param2.optional={{{function2.param2.optional}}}
  }}{{
      |param2.default={{{function2.param2.default}}}
    #if: {{{function2.parameter3|}}}
      |param3={{{function2.param3}}}
     |{{#if: {{{function2.parameter3.optional|}}}|<nowiki>[</nowiki>}}, {{{
      |param3.type={{{function2.param3.type}}}
      function2.parameter3.type|{{error|Parameter 'function2.parameter3.type' is missing for User:Philmasterplus/TemplateSandbox2}}}}} {{Pspan|{{{function2.parameter3}}}}}{{
      |param3.optional={{{function2.param3.optional}}}
    #if: {{{function2.parameter3.default|}}}| = {{{function2.parameter3.default|}}}}}{{
      |param3.default={{{function2.param3.default}}}
    #if: {{{function2.parameter3.optional|}}}|<nowiki>]</nowiki>}}
      |param4={{{function2.param4}}}
  }})</code>'''{{
       |param4.type={{{function2.param4.type}}}
   #if: {{{function2.parameter1|}}}
      |param4.optional={{{function2.param4.optional}}}
   |<ul><li>'''{{{function2.parameter1.type}}} {{Pspan|{{{function2.parameter1}}}}}''': {{{function2.parameter1.description}}}</li>}}{{
      |param4.default={{{function2.param4.default}}}
   #if: {{{function2.parameter2|}}}
      |param5={{{function2.param5}}}
   |<li>'''{{{function2.parameter2.type}}} {{Pspan|{{{function2.parameter2}}}}}''': {{{function2.parameter2.description}}}</li>}}{{
      |param5.type={{{function2.param5.type}}}
   #if: {{{function2.parameter3|}}}
      |param5.optional={{{function2.param5.optional}}}
   |<li>'''{{{function2.parameter3.type}}} {{Pspan|{{{function2.parameter3}}}}}''': {{{function2.parameter3.description}}}</li>}}{{
      |param5.default={{{function2.param5.default}}}
   #if: {{{function2.parameter1|}}}|</ul>}}{{
     }})</code>'''{{
  #if: {{{function2.param1|}}}
  |<ul><li>'''{{{function2.param1.type}}} {{Pspan|{{{function2.param1}}}}}''': {{{function2.param1.description}}}</li>}}{{
  #if: {{{function2.param2|}}}
  |<li>'''{{{function2.param2.type}}} {{Pspan|{{{function2.param2}}}}}''': {{{function2.param2.description}}}</li>}}{{
   #if: {{{function2.param3|}}}
   |<li>'''{{{function2.param3.type}}} {{Pspan|{{{function2.param3}}}}}''': {{{function2.param3.description}}}</li>}}{{
   #if: {{{function2.param4|}}}
   |<li>'''{{{function2.param4.type}}} {{Pspan|{{{function2.param4}}}}}''': {{{function2.param4.description}}}</li>}}{{
   #if: {{{function2.param5|}}}
   |<li>'''{{{function2.param5.type}}} {{Pspan|{{{function2.param5}}}}}''': {{{function2.param3.description}}}</li>}}{{
   #if: {{{function2.param1|}}}|</ul>}}{{
   #if: {{{function2.short_description|}}}|: {{{function2.short_description}}}}}
   #if: {{{function2.short_description|}}}|: {{{function2.short_description}}}}}
}}
}}
{{#if: {{{function1.return_type|}}}
{{#if: {{{function3.return_type|}}}
   |'''<code>{{{function1.return_type}}} {{{name}}}({{
   |'''<code>{{{function3.return_type}}} {{{name}}}({{
     #if: {{{function1.parameter1|}}}
     #if: {{{function3.parameter1|}}}
     |{{#if: {{{function1.parameter1.optional|}}}|<nowiki>[</nowiki>}}{{{
     |{{{User:Philmasterplus/FunctionDeclaration
    function1.parameter1.type|{{error|Parameter 'function1.parameter1.type' is missing for User:Philmasterplus/TemplateSandbox2}}}}} {{Pspan|{{{function1.parameter1}}}}}{{
      |name={{{name}}}
    #if: {{{function1.parameter1.default|}}}| = {{{function1.parameter1.default|}}}}}{{
      |return_type={{{function3.return_type1}}}
    #if: {{{function1.parameter1.optional|}}}|<nowiki>]</nowiki>}}
      |param1={{{function3.param1}}}
  }}{{
      |param1.type={{{function3.param1.type}}}
    #if: {{{function1.parameter2|}}}
      |param1.optional={{{function3.param1.optional}}}
    |{{#if: {{{function1.parameter2.optional|}}}|<nowiki>[</nowiki>}}, {{{
      |param1.default={{{function3.param1.default}}}
       function1.parameter2.type|{{error|Parameter 'function1.parameter2.type' is missing for User:Philmasterplus/TemplateSandbox2}}}}} {{Pspan|{{{function1.parameter2}}}}}{{
      |param2={{{function3.param2}}}
    #if: {{{function1.parameter2.default|}}}| = {{{function1.parameter2.default|}}}}}{{
      |param2.type={{{function3.param2.type}}}
    #if: {{{function1.parameter2.optional|}}}|<nowiki>]</nowiki>}}
      |param2.optional={{{function3.param2.optional}}}
  }}{{
      |param2.default={{{function3.param2.default}}}
    #if: {{{function1.parameter3|}}}
      |param3={{{function3.param3}}}
     |{{#if: {{{function1.parameter3.optional|}}}|<nowiki>[</nowiki>}}, {{{
      |param3.type={{{function3.param3.type}}}
      function1.parameter3.type|{{error|Parameter 'function1.parameter3.type' is missing for User:Philmasterplus/TemplateSandbox2}}}}} {{Pspan|{{{function1.parameter3}}}}}{{
      |param3.optional={{{function3.param3.optional}}}
    #if: {{{function1.parameter3.default|}}}| = {{{function1.parameter3.default|}}}}}{{
      |param3.default={{{function3.param3.default}}}
    #if: {{{function1.parameter3.optional|}}}|<nowiki>]</nowiki>}}
      |param4={{{function3.param4}}}
  }})</code>'''{{
       |param4.type={{{function3.param4.type}}}
   #if: {{{function1.parameter1|}}}
      |param4.optional={{{function3.param4.optional}}}
   |<ul><li>'''{{{function1.parameter1.type}}} {{Pspan|{{{function1.parameter1}}}}}''': {{{function1.parameter1.description}}}</li>}}{{
      |param4.default={{{function3.param4.default}}}
   #if: {{{function1.parameter2|}}}
      |param5={{{function3.param5}}}
   |<li>'''{{{function1.parameter2.type}}} {{Pspan|{{{function1.parameter2}}}}}''': {{{function1.parameter2.description}}}</li>}}{{
      |param5.type={{{function3.param5.type}}}
   #if: {{{function1.parameter3|}}}
      |param5.optional={{{function3.param5.optional}}}
   |<li>'''{{{function1.parameter3.type}}} {{Pspan|{{{function1.parameter3}}}}}''': {{{function1.parameter3.description}}}</li>}}{{
      |param5.default={{{function3.param5.default}}}
   #if: {{{function1.parameter1|}}}|</ul>}}{{
     }})</code>'''{{
   #if: {{{function1.short_description|}}}|: {{{function1.short_description}}}}}
  #if: {{{function3.param1|}}}
  |<ul><li>'''{{{function3.param1.type}}} {{Pspan|{{{function3.param1}}}}}''': {{{function3.param1.description}}}</li>}}{{
  #if: {{{function3.param2|}}}
  |<li>'''{{{function3.param2.type}}} {{Pspan|{{{function3.param2}}}}}''': {{{function3.param2.description}}}</li>}}{{
   #if: {{{function3.param3|}}}
   |<li>'''{{{function3.param3.type}}} {{Pspan|{{{function3.param3}}}}}''': {{{function3.param3.description}}}</li>}}{{
   #if: {{{function3.param4|}}}
   |<li>'''{{{function3.param4.type}}} {{Pspan|{{{function3.param4}}}}}''': {{{function3.param4.description}}}</li>}}{{
   #if: {{{function3.param5|}}}
   |<li>'''{{{function3.param5.type}}} {{Pspan|{{{function3.param5}}}}}''': {{{function3.param3.description}}}</li>}}{{
   #if: {{{function3.param1|}}}|</ul>}}{{
   #if: {{{function3.short_description|}}}|: {{{function3.short_description}}}}}
}}
}}
{{#if: {{{code1|}}}|{{{code1}}}}}{{#if: {{{code2|}}}|{{{code2}}}}}{{#if: {{{code3|}}}|{{{code3}}}}}{{#if: {{{code4|}}}|{{{code4}}}}}{{#if: {{{code5|}}}|{{{code5}}}}}
{{#if: {{{code1|}}}|{{{code1}}}}}{{#if: {{{code2|}}}|{{{code2}}}}}{{#if: {{{code3|}}}|{{{code3}}}}}{{#if: {{{code4|}}}|{{{code4}}}}}{{#if: {{{code5|}}}|{{{code5}}}}}
Line 115: Line 148:
     "function1.short_description": {
     "function1.short_description": {
       "label": "Function 1, short description",
       "label": "Function 1, short description",
       "description": "Short description for the 1st overloaded form of the function",
       "description": "Short description for the overloaded function 1 (and so on for functions 2 through 3)",
       "type": "content",
       "type": "content",
       "example": "Visits a web page and returns its HTML source."
       "example": "Visits a web page and returns its HTML source."
Line 121: Line 154:
     "function1.return_type": {
     "function1.return_type": {
       "label": "Function 1, return type",
       "label": "Function 1, return type",
       "description": "Return type of the 1st overloaded form of the function.",
       "description": "Return type of the overloaded function 1.",
       "required": true,
       "required": true,
       "type": "line",
       "type": "line",
       "example": "buffer"
       "example": "buffer"
     },
     },
     "function1.parameter1": {
     "function1.param1": {
       "label": "Function 1, parameter 1",
       "label": "Function 1, parameter 1",
       "description": "Name of the parameter 1 of the 1st overloaded form of the function.",
       "description": "Name of the parameter 1 of the overloaded function 1 (and so on for parameters 2 through 5).",
       "type": "line",
       "type": "line",
       "example": "url"
       "example": "url"
     },
     },
     "function1.parameter1.description": {
     "function1.param1.description": {
       "label": "Function 1, parameter 1 description",
       "label": "Function 1, parameter 1 description",
       "description": "Description of parameter 1 of the 1st overloaded form of the function.",
       "description": "Description of parameter 1 of the overloaded function 1.",
       "type": "content",
       "type": "content",
       "example": "URL of the page to visit. If a relative URL is provided, it is treated as an in-game page."
       "example": "URL of the page to visit. If a relative URL is provided, it is treated as an in-game page."
     },
     },
     "function1.parameter1.optional": {
     "function1.param1.optional": {
       "label": "Function 1, parameter 1 is optional?",
       "label": "Function 1, parameter 1 is optional?",
       "description": "Whether parameter 1 of the 1st overloaded form of the function is optional. Note that ASH does not support truly optional parameters; a function with optional parameters is actually multiple overloaded functions.",
       "description": "\"yes\" = optional. Any non-empty string will do, but please use \"yes\" to make standardization easier.",
      "default": "0",
       "type": "line",
       "type": "boolean",
       "example": "yes"
       "example": "1"
     },
     },
     "function1.parameter1.default": {
     "function1.param1.default": {
       "label": "Function 1, parameter 1 default value",
       "label": "Function 1, parameter 1 default value",
       "description": "The default value of parameter 1 of the 1st overloaded form of the function. This should be used in conjunction with function1.parameter1.optional",
       "description": "If this is specified, function1.param1.optional must be \"yes\"",
       "type": "line",
       "type": "line",
       "example": "0"
       "example": "\"\""
     }
     }
   }
   }
}
}
</templatedata>
</templatedata>
==Examples==
</noinclude>
</noinclude>

Revision as of 17:40, 18 December 2020

Replacement for Template:FunctionPage. Must be used with function pages that follow a specific format.

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
ASH function namename

Name of the ASH function. This should match the function page name.

Example
visit_url
Linerequired
Function 1, short descriptionfunction1.short_description

Short description for the overloaded function 1 (and so on for functions 2 through 3)

Example
Visits a web page and returns its HTML source.
Contentoptional
Function 1, return typefunction1.return_type

Return type of the overloaded function 1.

Example
buffer
Linerequired
Function 1, parameter 1function1.param1

Name of the parameter 1 of the overloaded function 1 (and so on for parameters 2 through 5).

Example
url
Lineoptional
Function 1, parameter 1 descriptionfunction1.param1.description

Description of parameter 1 of the overloaded function 1.

Example
URL of the page to visit. If a relative URL is provided, it is treated as an in-game page.
Contentoptional
Function 1, parameter 1 is optional?function1.param1.optional

"yes" = optional. Any non-empty string will do, but please use "yes" to make standardization easier.

Example
yes
Lineoptional
Function 1, parameter 1 default valuefunction1.param1.default

If this is specified, function1.param1.optional must be "yes"

Example
""
Lineoptional

Examples