Difference between revisions of "Template:FunctionDeclaration"

From Kolmafia
Jump to navigation Jump to search
(Created page with "<includeonly>'''<kbd>{{{return_type}}} {{{name}}}({{ #if: {{{param1|}}} |{{#if: {{{param1.optional|}}}|<nowiki>[</nowiki>}} </kbd>'''{{param|{{{param1.type}}}|{{{para...")
 
Line 32: Line 32:
 
     "param1": {
 
     "param1": {
 
       "label": "Parameter 1 name",
 
       "label": "Parameter 1 name",
       "description": "Name of parameter 1",
+
       "description": "Name of parameter 1 (same for parameters 2 through 5)",
 
       "type": "line"
 
       "type": "line"
 
     },
 
     },

Revision as of 17:26, 18 December 2020


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

Template parameters

ParameterDescriptionTypeStatus
Parameter 1 nameparam1

Name of parameter 1 (same for parameters 2 through 5)

Lineoptional
Parameter 1 typeparam1.type

Parameter 1 data type

Example
string
Lineoptional
Parameter 1 is optional?param1.optional

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

Example
yes
Stringoptional
Parameter 1 default valueparam1.default

If this is specified, param1.optional must be 1

Lineoptional

Examples

No arguments

{{User:Philmasterplus/FunctionDeclaration
|name=my_id
|return_type=int
}}

int my_id()

Single argument

{{User:Philmasterplus/FunctionDeclaration
|name=to_item
|return_type=int
|param1=it
|param1.type=item
}}

int to_item( item it  )

Multiple arguments

{{User:Philmasterplus/FunctionDeclaration
|name=maximize
|return_type=record [int]
|param1=expression
|param1.type=string
|param2=max_price
|param2.type=int
|param3=price_level
|param3.type=int
|param4=simulate
|param4.type=boolean
|param5=include_equip
|param5.type=boolean
}}

record [int] maximize( string expression  , int max_price  , int price_level  , boolean simulate  , boolean include_equip  )

Optional arguments

{{User:Philmasterplus/FunctionDeclaration
|name=creatable_turns
|return_type=int
|param1=check_me
|param1.type=item
|param2=qty
|param2.type=int
|param2.optional=yes
|param3=free
|param3.type=boolean
|param3.optional=yes
}}

int creatable_turns( item check_me  [, int qty  ] [, boolean free  ] )

Default arguments

{{User:Philmasterplus/FunctionDeclaration
|name=visit_url
|return_type=buffer
|param1=url
|param1.type=string
|param2=use_POST
|param2.type=boolean
|param2.optional=yes
|param2.default=true
|param3=encoded
|param3.type=boolean
|param3.optional=yes
|param3.default=false
}}

buffer visit_url([ string url  ] [, boolean use_POST  = true ] [, boolean encoded  = false ] )