Template:Nasal doc: Difference between revisions
Jump to navigation
Jump to search
Gets add returns the value of a node in the Property Tree.
Red Leader (talk | contribs) (doc interals) |
Red Leader (talk | contribs) (Remove heading-related parameters; add {{#tag:syntaxhighlight}}; change source and version display) |
||
Line 1: | Line 1: | ||
<includeonly>{{{ | <includeonly>{{#tag:syntaxhighlight|{{{syntax}}}|lang="nasal"}} | ||
{{{ | {{#if: {{{source|}}}{{{version|}}} | <p>{{#if: {{{source|}}} | {{{source}}}{{#if: {{{version|}}}| — }} }}{{#if: {{{version|}}} | '''Version added:''' FG {{{version}}} }}</p> }}<!-- | ||
{{ | -->{{{text}}} | ||
{{{text | |||
;{{{param1|}}}:{{{param1text|}}} | ;{{{param1|}}}:{{{param1text|}}} | ||
;{{{param2|}}}:{{{param2text|}}} | ;{{{param2|}}}:{{{param2text|}}} | ||
Line 13: | Line 12: | ||
;{{{param9|}}}:{{{param9text|}}} | ;{{{param9|}}}:{{{param9text|}}} | ||
;{{{param10|}}}:{{{param10text|}}}{{#if: {{{example1|}}}| | ;{{{param10|}}}:{{{param10text|}}}{{#if: {{{example1|}}}| | ||
<br | <br> | ||
'''Example{{#if: {{{example2|}}}|s}}''' | '''Example{{#if: {{{example2|}}}|s}}''' | ||
{{{example1text|}}}{{{example1|}}} | {{{example1text|}}}{{#if: {{{example1|}}} | {{#tag:syntaxhighlight|{{{example1}}}|lang="nasal"}} }} | ||
{{{example2text|}}}{{{example2|}}} | {{{example2text|}}}{{#if: {{{example2|}}} | {{#tag:syntaxhighlight|{{{example2}}}|lang="nasal"}} }} | ||
{{{example3text|}}}{{{example3|}}} | {{{example3text|}}}{{#if: {{{example3|}}} | {{#tag:syntaxhighlight|{{{example3}}}|lang="nasal"}} }} | ||
{{{example4text|}}}{{{example4|}}} | {{{example4text|}}}{{#if: {{{example4|}}} | {{#tag:syntaxhighlight|{{{example4}}}|lang="nasal"}} }} | ||
{{{example5text|}}}{{{example5|}}} | {{{example5text|}}}{{#if: {{{example5|}}} | {{#tag:syntaxhighlight|{{{example5}}}|lang="nasal"}} }} | ||
{{{example6text|}}}{{{example6|}}} | {{{example6text|}}}{{#if: {{{example6|}}} | {{#tag:syntaxhighlight|{{{example6}}}|lang="nasal"}} }} | ||
{{{example7text|}}}{{{example7|}}} | {{{example7text|}}}{{#if: {{{example7|}}} | {{#tag:syntaxhighlight|{{{example7}}}|lang="nasal"}} }} | ||
{{{example8text|}}}{{{example8|}}} | {{{example8text|}}}{{#if: {{{example8|}}} | {{#tag:syntaxhighlight|{{{example8}}}|lang="nasal"}} }} | ||
{{{example9text|}}}{{{example9|}}} | {{{example9text|}}}{{#if: {{{example9|}}} | {{#tag:syntaxhighlight|{{{example9}}}|lang="nasal"}} }} | ||
{{{example10text|}}}{{{example10|}}}<!-- | {{{example10text|}}}{{#if: {{{example10|}}} | {{#tag:syntaxhighlight|{{{example10}}}|lang="nasal"}} }}<!-- | ||
-->}}</includeonly><noinclude> | -->}}</includeonly><noinclude> | ||
{{Informative template|1= | {{Informative template|1= | ||
Line 32: | Line 31: | ||
== Usage == | == Usage == | ||
{{obr}}''' | {{obr}}'''nasal doc''' | ||
{{!}} | {{!}} syntax = | ||
{{!}} text = | |||
{{!}} | {{!}} ''source'' = | ||
{{!}} ''source'' = | {{!}} ''line'' = | ||
{{!}} ''line'' = | {{!}} ''version'' = | ||
{{!}} ''version'' | {{!}} ''param1'' = | ||
{{!}} ''param1'' = | |||
... | ... | ||
{{!}} ''param10'' = | {{!}} ''param10'' = | ||
{{!}} ''param1text'' = | {{!}} ''param1text'' = | ||
... | ... | ||
{{!}} ''param10text'' = | {{!}} ''param10text'' = | ||
{{!}} ''example1text'' = | {{!}} ''example1text'' = | ||
{{!}} ''example1'' = | {{!}} ''example1'' = | ||
... | ... | ||
{{!}} ''example10text'' = | {{!}} ''example10text'' = | ||
{{!}} ''example10'' = | {{!}} ''example10'' = | ||
{{cbr}} | {{cbr}} | ||
Line 56: | Line 53: | ||
=== Basic data === | === Basic data === | ||
; syntax: Syntax of the function. | ; syntax: Syntax of the function. | ||
; | ; text: Description of the function. | ||
; | ; source: When given, should be a [[:Category:Repository link templates|repository link template]], such as {{tl|flightgear file}} with the text as "Source" (see example below). Ideally, a line number should be given as well. | ||
; | ; version: Optional version statement, sating which version of FlightGear the function was added. | ||
; param(n): Names of the parameters of the function. There can be up to ten parameters, from '''param1''' to '''param10'''. | ; param''(n)'': Names of the parameters of the function. There can be up to ten parameters, from '''param1''' to '''param10'''. | ||
; param(n)text: Description of the parameters. There can be up to ten parameters, from '''param1text''' to '''param10text'''. | ; param''(n)''text: Description of the parameters. There can be up to ten parameters, from '''param1text''' to '''param10text'''. | ||
; example(n)text: Description of the example. There can be up to ten of these, from '''example1text''' to '''example10text'''. | ; example''(n)''text: Description of the example. There can be up to ten of these, from '''example1text''' to '''example10text'''. | ||
; example(n): Examples of the usage of the function. There can be up to ten examples, from '''example1''' to '''example10'''. | ; example''(n)'': Examples of the usage of the function. There can be up to ten examples, from '''example1''' to '''example10'''. | ||
== | == Examples == | ||
{{obr}} | <nowiki>== function() ==</nowiki> | ||
{{obr}}nasal doc | |||
{{!}} syntax = | {{!}} syntax = function(a, [b, c]); | ||
{{!}} version = 3.2 | |||
{{!}} version = 3.2 | |||
{{!}} text = Returns a value or <nowiki><code>'''nil'''</code></nowiki>. | {{!}} text = Returns a value or <nowiki><code>'''nil'''</code></nowiki>. | ||
{{!}} param1 = a | {{!}} param1 = a | ||
Line 93: | Line 81: | ||
{{!}} param3 = c | {{!}} param3 = c | ||
{{!}} param3text = Optional argument. | {{!}} param3text = Optional argument. | ||
{{!}} example1 = | {{!}} example1 = var variable = function("string"); | ||
{{!}} example2 = | {{!}} example2 = var variable = function("string", 1.234, FlightGear); | ||
{{cbr}} | {{cbr}} | ||
{{ | === function() === | ||
{{nasal doc | |||
| syntax = | | syntax = function(a, [b, c]); | ||
| version = 3.2 | |||
| version = 3. | |||
| text = Returns a value or <code>'''nil'''</code>. | | text = Returns a value or <code>'''nil'''</code>. | ||
| param1 = a | | param1 = a | ||
Line 109: | Line 96: | ||
| param3 = c | | param3 = c | ||
| param3text = Optional argument. | | param3text = Optional argument. | ||
| example1 = | | example1 = var variable = function("string"); | ||
| example2 = | | example2 = var variable = function("string", 1.234, FlightGear); | ||
}} | }} | ||
<br | <br> | ||
---- | ---- | ||
<br | <br> | ||
You don't have to give examples (although they are encouraged). | You don't have to give examples (although they are encouraged). | ||
{{obr}} | <nowiki>=== function() ===</nowiki> | ||
{{obr}}nasal doc | |||
{{!}} syntax = | {{!}} syntax = function2(); | ||
{{!}} text = Returns "Hello world!". | {{!}} text = Returns "Hello world!". | ||
{{cbr}} | {{cbr}} | ||
{{ | === function() === | ||
{{nasal doc | |||
| name = function2 | | name = function2 | ||
| syntax = | | syntax = function2(); | ||
| text = Returns "Hello world!". | | text = Returns "Hello world!". | ||
}} | |||
<br> | |||
---- | |||
<br> | |||
You can add a source parameter to link to the source code behind the function. | |||
<nowiki>=== getprop() === | |||
{{obr}}nasal doc | |||
{{!}} syntax = getprop(path); | |||
{{!}} text = Gets add returns the value of a node in the [[Property Tree]]. | |||
{{!}} source = {{flightgear file|src/Scripting/NasalSys.cxx|l=l345|t=Source}} | |||
{{cbr}}</nowiki> | |||
=== getprop() === | |||
{{nasal doc | |||
|syntax = getprop(path); | |||
|text = Gets add returns the value of a node in the [[Property Tree]]. | |||
|source = {{flightgear file|src/Scripting/NasalSys.cxx|l=l345|t=Source}} | |||
}} | }} | ||
}} | }} | ||
Revision as of 19:11, 17 October 2015
The following template description is not displayed when the template is inserted in an article.
Goal
This template is to be used to document Nasal API functions. The underlying aim is to unify Nasal documentation on the wiki.
Usage
{{nasal doc | syntax = | text = | source = | line = | version = | param1 = ... | param10 = | param1text = ... | param10text = | example1text = | example1 = ... | example10text = | example10 = }}
All parameters are optional.
Basic data
- syntax
- Syntax of the function.
- text
- Description of the function.
- source
- When given, should be a repository link template, such as {{flightgear file}} with the text as "Source" (see example below). Ideally, a line number should be given as well.
- version
- Optional version statement, sating which version of FlightGear the function was added.
- param(n)
- Names of the parameters of the function. There can be up to ten parameters, from param1 to param10.
- param(n)text
- Description of the parameters. There can be up to ten parameters, from param1text to param10text.
- example(n)text
- Description of the example. There can be up to ten of these, from example1text to example10text.
- example(n)
- Examples of the usage of the function. There can be up to ten examples, from example1 to example10.
Examples
== function() == {{nasal doc | syntax = function(a, [b, c]); | version = 3.2 | text = Returns a value or <code>'''nil'''</code>. | param1 = a | param1text = Mandatory argument. | param2 = b | param2text = Optional argument. | param3 = c | param3text = Optional argument. | example1 = var variable = function("string"); | example2 = var variable = function("string", 1.234, FlightGear); }}
function()
function(a, [b, c]);
Version added: FG 3.2
Returns a value ornil
.
- a
- Mandatory argument.
- b
- Optional argument.
- c
- Optional argument.
Examples
var variable = function("string");
var variable = function("string", 1.234, FlightGear);
You don't have to give examples (although they are encouraged).
=== function() === {{nasal doc | syntax = function2(); | text = Returns "Hello world!". }}
function()
function2();
Returns "Hello world!".
You can add a source parameter to link to the source code behind the function.
=== getprop() === {{obr}}nasal doc {{!}} syntax = getprop(path); {{!}} text = Gets add returns the value of a node in the [[Property Tree]]. {{!}} source = {{flightgear file|src/Scripting/NasalSys.cxx|l=l345|t=Source}} {{cbr}}
getprop()
getprop(path);