Difference between revisions of "Template:Function"
imported>StDoodle m |
|||
(84 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | < | + | <includeonly><p><b>{{#if: {{{aggregate|}}}|{{Lnkstart}}Data Types#Aggregate{{!}}{{{return_type}}}{{Lnkend}}|{{Lnkstart}}Data Types#{{{return_type}}}{{!}}{{{return_type}}}{{Lnkend}} }}{{#if: {{{return_also|}}}| / {{#if: {{{aggregate|}}}|{{Lnkstart}}Aggregate|{{{return_also}}}{{Lnkend}}|{{Lnkstart}}{{{return_also}}}{{Lnkend}} }} }} {{{name}}}(</b>{{#if: {{{parameter1|}}}|{{{parameter1}}} }}{{#if: {{{parameter2|}}}|<b>,</b>{{{parameter2}}} }}{{#if: {{{parameter3|}}}|<b>,</b>{{{parameter3}}} }}{{#if: {{{parameter4|}}}|<b>,</b>{{{parameter4}}} }}{{#if: {{{parameter5|}}}|<b>,</b>{{{parameter5}}} }}<b>)</b></p>{{ |
− | < | + | #if: {{{p1desc|}}}|<ul><li> {{{p1desc}}}</li>}}{{ |
− | {{# | + | #if: {{{p2desc|}}}|<li> {{{p2desc}}}</li>}}{{ |
− | + | #if: {{{p3desc|}}}|<li> {{{p3desc}}}</li>}}{{ | |
− | {{{ | + | #if: {{{p4desc|}}}|<li> {{{p4desc}}}</li>}}{{ |
− | {{#if: {{{p1desc|}}}|{{{p1desc}}}}} | + | #if: {{{p5desc|}}}|<li> {{{p5desc}}}</li>}}{{#if: {{{p1desc|}}}| </ul> }}</includeonly> |
− | [[Category: | + | <noinclude>This is the template to display a line of function information (for the function page template, see [[Template:FunctionPage]]). |
− | </ | + | ==Using This Template== |
+ | *"name" should be set to the name of the function, without parentheses (for link-building & displaying with parameters; parentheses will automatically be added by the template in the appropriate place). | ||
+ | *"aggregate" should be listed and set to anything you'd like if the function returns an [[aggregate]] (map) data type. If this function returns a simple data type, delete this line. | ||
+ | *"return_type" should be set to the datatype returned by the function. | ||
+ | *"return_also" should be set to a secondary datatype. For instance, some functions can return both a [[string]] and a [[buffer]]. For most functions, which only return a single datatype, this line should be deleted. | ||
+ | *"parameter1" through "parameter5" should be set to the parameters the function accepts. Each should be set using [[Template:Param]]. Use these parameters in order: don't start with "parameter2" if you don't include a "parameter1". (They can be listed in any order, if you really desire; you just can't skip an earlier parameter if you want them to display correctly.) | ||
+ | **The first argument is the data type of the parameter | ||
+ | **The second argument is the short description to display for the parameter (optional). | ||
+ | **If the parameter is an aggregate, you should include "ag=yes" in the template call. | ||
+ | **For more information, see [[Template:Param]]. | ||
+ | *"p1desc" through "p5desc" are for long descriptions of the parameter. They will be displayed in list form below the function call line if used. | ||
+ | **Again, it's recommended that you list them in numerical order. | ||
+ | **For consistency, if you refer to the short description of the parameter, wrap it in [[Template:Pspan]]. | ||
+ | **If you want sub-listing for the parameter description, use additional lines in the assignment that start with <nowiki>"**"</nowiki> to create a nested list. | ||
+ | <pre> | ||
+ | {{Function| | ||
+ | name=NAME_OF_FUNCTION| | ||
+ | aggregate=ANYTHING_IF_RETURNS_AGGREGATE_OR_DELETE| | ||
+ | return_type=DATATYPE_RETURNED_(IF_AGGREGATE_FULL_MAP_DEFINITION)| | ||
+ | return_also=SECONDARY_DATATYPE_RETURNED_OR_DELETE| | ||
+ | parameter1={{Param|DATATYPE|SHORT_DESC}}| | ||
+ | parameter2={{Param|DATATYPE|SHORT_DESC}}| | ||
+ | parameter3={{Param|DATATYPE|SHORT_DESC}}| | ||
+ | parameter4={{Param|DATATYPE|SHORT_DESC}}| | ||
+ | parameter5={{Param|DATATYPE|SHORT_DESC}}| | ||
+ | p1desc=LONG_DESCRIPTION_OF_PARAMETER| | ||
+ | p2desc=LONG_DESCRIPTION_OF_PARAMETER| | ||
+ | p3desc=LONG_DESCRIPTION_OF_PARAMETER| | ||
+ | p4desc=LONG_DESCRIPTION_OF_PARAMETER| | ||
+ | p5desc=LONG_DESCRIPTION_OF_PARAMETER}} | ||
+ | </pre> | ||
+ | <templatedata> | ||
+ | { | ||
+ | "description": "Display the call signature of an ASH function", | ||
+ | "params": { | ||
+ | "name": { | ||
+ | "label": "Function name", | ||
+ | "description": "Function name without parentheses", | ||
+ | "required": true, | ||
+ | "example": "{{#var:name}}", | ||
+ | "type": "line" | ||
+ | }, | ||
+ | "aggregate": { | ||
+ | "label": "Returns aggregate?", | ||
+ | "description": "\"yes\" if the function returns an aggregate type. Otherwise, this parameter must be empty.", | ||
+ | "example": "{{#var:aggregate}}", | ||
+ | "type": "line" | ||
+ | }, | ||
+ | "return_type": { | ||
+ | "label": "Return type", | ||
+ | "description": "Return type of the function", | ||
+ | "required": true, | ||
+ | "example": "{{#var:return_type}}", | ||
+ | "type": "line" | ||
+ | }, | ||
+ | "return_also": { | ||
+ | "label": "Secondary return type", | ||
+ | "description": "Secondary return type of the function. Used only for functions that can return multiple types (e.g. string or buffer).", | ||
+ | "example": "{{#var:return_also}}", | ||
+ | "type": "line" | ||
+ | }, | ||
+ | "parameter1": { | ||
+ | "label": "Parameter 1", | ||
+ | "description": "Parameter 1. Use {{Param}} to describe a parameter", | ||
+ | "example": "{{Param|param_type|param_name}}", | ||
+ | "type": "string" | ||
+ | }, | ||
+ | "parameter2": { | ||
+ | "label": "Parameter 2", | ||
+ | "description": "Parameter 2. Use {{Param}} to describe a parameter.", | ||
+ | "example": "{{Param|param_type|param_name}}", | ||
+ | "type": "string" | ||
+ | }, | ||
+ | "parameter3": { | ||
+ | "label": "Parameter 3", | ||
+ | "description": "Parameter 3. Use {{Param}} to describe a parameter.", | ||
+ | "example": "{{Param|param_type|param_name}}", | ||
+ | "type": "string" | ||
+ | }, | ||
+ | "parameter4": { | ||
+ | "label": "Parameter 4", | ||
+ | "description": "Parameter 4. Use {{Param}} to describe a parameter.", | ||
+ | "example": "{{Param|param_type|param_name}}", | ||
+ | "type": "string" | ||
+ | }, | ||
+ | "parameter5": { | ||
+ | "label": "Parameter 5", | ||
+ | "description": "Parameter 5. Use {{Param}} to describe a parameter.", | ||
+ | "example": "{{Param|param_type|param_name}}", | ||
+ | "type": "string" | ||
+ | }, | ||
+ | "p1desc": { | ||
+ | "label": "Parameter 1 description", | ||
+ | "description": "Long description for parameter 1", | ||
+ | "example": "{{Pspan|param_name}} is the parameter", | ||
+ | "type": "string" | ||
+ | }, | ||
+ | "p2desc": { | ||
+ | "label": "Parameter 2 description", | ||
+ | "description": "Long description for parameter 2", | ||
+ | "example": "{{Pspan|param_name}} is the parameter", | ||
+ | "type": "string" | ||
+ | }, | ||
+ | "p3desc": { | ||
+ | "label": "Parameter 3 description", | ||
+ | "description": "Long description for parameter 3", | ||
+ | "example": "{{Pspan|param_name}} is the parameter", | ||
+ | "type": "string" | ||
+ | }, | ||
+ | "p4desc": { | ||
+ | "label": "Parameter 4 description", | ||
+ | "description": "Long description for parameter 4", | ||
+ | "example": "{{Pspan|param_name}} is the parameter", | ||
+ | "type": "string" | ||
+ | }, | ||
+ | "p5desc": { | ||
+ | "label": "Parameter 5 description", | ||
+ | "description": "Long description for parameter 5", | ||
+ | "example": "{{Pspan|param_name}} is the parameter", | ||
+ | "type": "string" | ||
+ | } | ||
+ | }, | ||
+ | "sets": [ | ||
+ | { | ||
+ | "label": "Param1", | ||
+ | "params": ["parameter1", "p1desc"] | ||
+ | }, | ||
+ | { | ||
+ | "label": "Param2", | ||
+ | "params": ["parameter2", "p2desc"] | ||
+ | }, | ||
+ | { | ||
+ | "label": "Param3", | ||
+ | "params": ["parameter3", "p3desc"] | ||
+ | }, | ||
+ | { | ||
+ | "label": "Param4", | ||
+ | "params": ["parameter4", "p4desc"] | ||
+ | }, | ||
+ | { | ||
+ | "label": "Param5", | ||
+ | "params": ["parameter5", "p5desc"] | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | </templatedata> | ||
+ | [[Category:Basic Templates]] | ||
+ | </noinclude> |
Latest revision as of 12:25, 18 December 2020
This is the template to display a line of function information (for the function page template, see Template:FunctionPage).
Using This Template
- "name" should be set to the name of the function, without parentheses (for link-building & displaying with parameters; parentheses will automatically be added by the template in the appropriate place).
- "aggregate" should be listed and set to anything you'd like if the function returns an aggregate (map) data type. If this function returns a simple data type, delete this line.
- "return_type" should be set to the datatype returned by the function.
- "return_also" should be set to a secondary datatype. For instance, some functions can return both a string and a buffer. For most functions, which only return a single datatype, this line should be deleted.
- "parameter1" through "parameter5" should be set to the parameters the function accepts. Each should be set using Template:Param. Use these parameters in order: don't start with "parameter2" if you don't include a "parameter1". (They can be listed in any order, if you really desire; you just can't skip an earlier parameter if you want them to display correctly.)
- The first argument is the data type of the parameter
- The second argument is the short description to display for the parameter (optional).
- If the parameter is an aggregate, you should include "ag=yes" in the template call.
- For more information, see Template:Param.
- "p1desc" through "p5desc" are for long descriptions of the parameter. They will be displayed in list form below the function call line if used.
- Again, it's recommended that you list them in numerical order.
- For consistency, if you refer to the short description of the parameter, wrap it in Template:Pspan.
- If you want sub-listing for the parameter description, use additional lines in the assignment that start with "**" to create a nested list.
{{Function| name=NAME_OF_FUNCTION| aggregate=ANYTHING_IF_RETURNS_AGGREGATE_OR_DELETE| return_type=DATATYPE_RETURNED_(IF_AGGREGATE_FULL_MAP_DEFINITION)| return_also=SECONDARY_DATATYPE_RETURNED_OR_DELETE| parameter1={{Param|DATATYPE|SHORT_DESC}}| parameter2={{Param|DATATYPE|SHORT_DESC}}| parameter3={{Param|DATATYPE|SHORT_DESC}}| parameter4={{Param|DATATYPE|SHORT_DESC}}| parameter5={{Param|DATATYPE|SHORT_DESC}}| p1desc=LONG_DESCRIPTION_OF_PARAMETER| p2desc=LONG_DESCRIPTION_OF_PARAMETER| p3desc=LONG_DESCRIPTION_OF_PARAMETER| p4desc=LONG_DESCRIPTION_OF_PARAMETER| p5desc=LONG_DESCRIPTION_OF_PARAMETER}}
Display the call signature of an ASH function
Parameter | Description | Type | Status | |
---|---|---|---|---|
Function name | name | Function name without parentheses
| Line | required |
Returns aggregate? | aggregate | "yes" if the function returns an aggregate type. Otherwise, this parameter must be empty.
| Line | optional |
Return type | return_type | Return type of the function
| Line | required |
Secondary return type | return_also | Secondary return type of the function. Used only for functions that can return multiple types (e.g. string or buffer).
| Line | optional |
Parameter 1 | parameter1 | Parameter 1. Use {{Param}} to describe a parameter
| String | optional |
Parameter 2 | parameter2 | Parameter 2. Use {{Param}} to describe a parameter.
| String | optional |
Parameter 3 | parameter3 | Parameter 3. Use {{Param}} to describe a parameter.
| String | optional |
Parameter 4 | parameter4 | Parameter 4. Use {{Param}} to describe a parameter.
| String | optional |
Parameter 5 | parameter5 | Parameter 5. Use {{Param}} to describe a parameter.
| String | optional |
Parameter 1 description | p1desc | Long description for parameter 1
| String | optional |
Parameter 2 description | p2desc | Long description for parameter 2
| String | optional |
Parameter 3 description | p3desc | Long description for parameter 3
| String | optional |
Parameter 4 description | p4desc | Long description for parameter 4
| String | optional |
Parameter 5 description | p5desc | Long description for parameter 5
| String | optional |