Template:FunctionDeclaration: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
No edit summary
No edit summary
Line 61: Line 61:
==Examples==
==Examples==
===Normal===
===Normal===
<pre>{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=1}}</pre>
<pre>{{FunctionDeclaration|name=visit_url|func=1}}</pre>


{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=1}}
{{FunctionDeclaration|name=visit_url|func=1}}


<pre>{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=2}}</pre>
<pre>{{FunctionDeclaration|name=visit_url|func=2}}</pre>


{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=2}}
{{FunctionDeclaration|name=visit_url|func=2}}


===Normal with Description===
===Normal with Description===
<pre>{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=1|desc=yes}}</pre>
<pre>{{FunctionDeclaration|name=visit_url|func=1|desc=yes}}</pre>


{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=1|desc=yes}}
{{FunctionDeclaration|name=visit_url|func=1|desc=yes}}


<pre>{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=2|desc=yes}}</pre>
<pre>{{FunctionDeclaration|name=visit_url|func=2|desc=yes}}</pre>


{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=2|desc=yes}}
{{FunctionDeclaration|name=visit_url|func=2|desc=yes}}


===Signature===
===Signature===
<pre>{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=2|format=signature}}</pre>
<pre>{{FunctionDeclaration|name=visit_url|func=2|format=signature}}</pre>


{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=2|format=signature}}
{{FunctionDeclaration|name=visit_url|func=2|format=signature}}


===Invalid or missing function number===
===Invalid or missing function number===
<pre>{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=4}}</pre>
<pre>{{FunctionDeclaration|name=visit_url|func=4}}</pre>


{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=4}}
{{FunctionDeclaration|name=visit_url|func=4}}


<pre>{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=0}}</pre>
<pre>{{FunctionDeclaration|name=visit_url|func=0}}</pre>


{{FunctionDeclaration|name=User:Philmasterplus/Sandbox|func=0}}
{{FunctionDeclaration|name=visit_url|func=0}}


<pre>{{FunctionDeclaration|name=User:Philmasterplus/Sandbox}}</pre>
<pre>{{FunctionDeclaration|name=visit_url}}</pre>


{{FunctionDeclaration|name=User:Philmasterplus/Sandbox}}
{{FunctionDeclaration|name=visit_url}}
</noinclude>
</noinclude>

Revision as of 11:59, 20 December 2020


Displays an ASH function's declaration. This is meant to be transcluded by other templates, rather than regular pages.

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
Function page namename

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

Page namerequired
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
Rendering formatformat

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

Lineoptional
Show descriptions?desc

If set to "yes", also show the description of each function and its parameters below the declaration. Technically, any non-empty string works, but please use "yes" for ease of maintenance.

Lineoptional

Examples

Normal

{{FunctionDeclaration|name=visit_url|func=1}}

buffer visit_url()

{{FunctionDeclaration|name=visit_url|func=2}}

buffer visit_urlstring url, boolean? use_POST = true, boolean? encoded = false )

Normal with Description

{{FunctionDeclaration|name=visit_url|func=1|desc=yes}}

buffer visit_url()
Returns the original HTML source of the page being overridden inside a relay override script.

{{FunctionDeclaration|name=visit_url|func=2|desc=yes}}

buffer visit_urlstring url, boolean? use_POST = true, boolean? encoded = false )
Visits a web page and returns its HTML source.

  • url: URL of the page to visit. If a relative URL is provided, it is treated as an in-game page.
  • use_POST: If true, makes an HTTP POST request when visiting the URL. Otherwise, makes a GET request.
  • encoded: If true, KoLmafia assumes that url has already been URL-encoded and will not encode it.

Signature

{{FunctionDeclaration|name=visit_url|func=2|format=signature}}

buffer visit_urlstring, boolean?, boolean? )

Invalid or missing function number

{{FunctionDeclaration|name=visit_url|func=4}}

Invalid function number (func = "4") in Template:FunctionDeclaration

{{FunctionDeclaration|name=visit_url|func=0}}

Invalid function number (func = "0") in Template:FunctionDeclaration

{{FunctionDeclaration|name=visit_url}}

Invalid function number (func = "") in Template:FunctionDeclaration