Template:Nasal doc: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(doc interals)
(Remove heading-related parameters; add {{#tag:syntaxhighlight}}; change source and version display)
Line 1: Line 1:
<includeonly>{{{heading|==}}}{{{name|function}}}(){{{heading|==}}}
<includeonly>{{#tag:syntaxhighlight|{{{syntax}}}|lang="nasal"}}
{{{syntax|}}}
{{#if: {{{source|}}}{{{version|}}} | <p>{{#if: {{{source|}}} | {{{source}}}{{#if: {{{version|}}}|&nbsp;&mdash;&nbsp;}} }}{{#if: {{{version|}}} | '''Version added:''' FG {{{version}}} }}</p> }}<!--
{{Nasal doc/table|source = {{{source|}}}|version = {{{version|}}}|line = {{{line|}}}}}
-->{{{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}}'''Nasal doc'''
  {{obr}}'''nasal doc'''
  {{!}} ''name''        =
  {{!}} syntax      =
{{!}} ''syntax''     = <nowiki><syntaxhighlight lang="nasal"></syntaxhighlight></nowiki>
  {{!}} text        =
  {{!}} ''heading''    =  
  {{!}} ''source''      =
  {{!}} ''source''      =  
  {{!}} ''line''        =
  {{!}} ''line''        =  
  {{!}} ''version''    =
  {{!}} ''version''    =
  {{!}} ''param1''      =
{{!}} ''text''        =  
  {{!}} ''param1''      =  
  ...
  ...
  {{!}} ''param10''    =  
  {{!}} ''param10''    =
  {{!}} ''param1text''  =  
  {{!}} ''param1text''  =
  ...
  ...
  {{!}} ''param10text'' =  
  {{!}} ''param10text'' =
  {{!}} ''example1text'' =  
  {{!}} ''example1text'' =
  {{!}} ''example1''    = <nowiki><syntaxhighlight lang="nasal"></syntaxhighlight></nowiki>
  {{!}} ''example1''    =
  ...
  ...
  {{!}} ''example10text'' =  
  {{!}} ''example10text'' =
  {{!}} ''example10''  = <nowiki><syntaxhighlight lang="nasal"></syntaxhighlight></nowiki>
  {{!}} ''example10''  =
  {{cbr}}
  {{cbr}}


Line 56: Line 53:


=== Basic data ===
=== Basic data ===
; name:          Name of the function (for example '''maketimer''').
; syntax:        Syntax of the function.
; syntax:        Syntax of the function.
:                {{inote|Please use <nowiki><syntaxhighlight></nowiki> tags.}}


; heading:       Heading level, in wiki syntax.  Defaults to 2nd level heading
; text:         Description of the function.
 
; source:        Flag for the source code link.  Can be ''core,'' ''ext,'' or a URL to another site.  ''core'' will link to {{repo link|site=s|proj=flightgear/simgear|path=simgear/nasal/lib.c}}, while ''ext'' links to {{repo link|site=s|proj=flightgear/flightgear|path=src/Scripting/NasalSys.cxx}}.  Will be displayed in a table along with '''version'''.
 
; line:          Line to link to. Used with '''source'''.


; version:       Optional version statement, which will use {{tl|FG ver}}.
; 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.


; text:         Description of the function.
; 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'''.
:                {{inote|Please use <nowiki><syntaxhighlight></nowiki> tags.}}


== Example ==
== Examples ==
  {{obr}}'''Nasal doc'''
<nowiki>== function() ==</nowiki>
{{!}} name      = function
  {{obr}}nasal doc
  {{!}} syntax    = <nowiki><syntaxhighlight lang="nasal">function(a, [b, c]);</syntaxhighlight></nowiki>
  {{!}} syntax    = function(a, [b, c]);
{{!}} heading    = ===
  {{!}} 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  = <nowiki><syntaxhighlight lang="nasal">var variable = function("string");</syntaxhighlight></nowiki>
  {{!}} example1  = var variable = function("string");
  {{!}} example2  = <nowiki><syntaxhighlight lang="nasal">var variable = function("string", 1.234, FlightGear);</syntaxhighlight></nowiki>
  {{!}} example2  = var variable = function("string", 1.234, FlightGear);
  {{cbr}}
  {{cbr}}


{{Nasal doc
=== function() ===
| name      = function
{{nasal doc
| syntax    = <syntaxhighlight lang="nasal">function(a, [b, c]);</syntaxhighlight>
| syntax    = function(a, [b, c]);
| heading    = ===
| version    = 3.2
| version    = 3.4+
| 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  = <syntaxhighlight lang="nasal">var variable = function("string");</syntaxhighlight>
| example1  = var variable = function("string");
| example2  = <syntaxhighlight lang="nasal">var variable = function("string", 1.234, FlightGear);</syntaxhighlight>
| 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}}'''Nasal doc'''
<nowiki>=== function() ===</nowiki>
{{!}} name      = function2
  {{obr}}nasal doc
  {{!}} syntax    =
  {{!}} syntax    = function2();
<nowiki><syntaxhighlight lang="nasal">function2();</syntaxhighlight></nowiki>
  {{!}} text      = Returns "Hello world!".
  {{!}} text      = Returns "Hello world!".
  {{cbr}}
  {{cbr}}


{{Nasal doc
=== function() ===
{{nasal doc
| name      = function2
| name      = function2
| syntax    =
| syntax    = function2();
<syntaxhighlight lang="nasal">function2();</syntaxhighlight>
| 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}}
}}
}}


== Known issues ==
* You have to manually add the <code><nowiki><syntaxhighlight></nowiki></code> tags.
}}
}}



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 or nil.
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);

Source

Gets add returns the value of a node in the Property Tree.