Template:Nasal doc: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(<tt> tag; rduce to one example, minor doc edits)
(Fix example; add commit param; typo fix)
Line 1: Line 1:
<includeonly>{{#if: {{{private|}}} | :<span style="color: grey"><tt>'''{{{private}}}'''</tt></span> }}
<includeonly>{{#if: {{{private|}}} | :<span style="color: grey"><tt>'''{{{private}}}'''</tt></span> }}
{{#tag:syntaxhighlight|{{{syntax}}}|lang="nasal"}}
{{#tag:syntaxhighlight|{{{syntax}}}|lang="nasal"}}
{{#if: {{{source|}}}{{{version|}}} | <p>{{#if: {{{source|}}} | {{{source}}}{{#if: {{{version|}}}|&nbsp;&mdash;&nbsp;}} }}{{#if: {{{version|}}} | '''Version added:''' FG {{{version}}} }}</p> }}<!--
{{#if: {{{source|}}}{{{version|}}} | <p>{{#if: {{{source|}}} | {{{source}}}{{#if: {{{version|}}}|&nbsp;&mdash;&nbsp;}} }}{{#if: {{{version|}}} | '''Version added:''' FG {{{version}}} }} {{#if: {{{commit|}}} | ({{{commit}}}) }}</p> }}<!--
-->{{{text}}}
-->{{{text}}}
;{{{param1|}}}:{{{param1text|}}}
;{{{param1|}}}:{{{param1text|}}}
Line 37: Line 37:
  {{!}} ''source''      =
  {{!}} ''source''      =
  {{!}} ''version''    =
  {{!}} ''version''    =
{{!}} ''commit''      =
  {{!}} ''private''    =
  {{!}} ''private''    =
  {{!}} ''param1''      =
  {{!}} ''param1''      =
Line 43: Line 44:
  {{!}} ''param1text''  =
  {{!}} ''param1text''  =
  ...
  ...
  {{!}} ''param10text'' =
  {{!}} ''param10text'' =
  {{!}} ''example1text'' =
  {{!}} ''example1text'' =
  {{!}} ''example1''   =
  {{!}} ''example1''     =
  ...
  ...
  {{!}} ''example10text'' =
  {{!}} ''example10text'' =
  {{!}} ''example10''   =
  {{!}} ''example10''     =
  {{cbr}}
  {{cbr}}


Line 60: Line 61:
; 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.
; 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.
; version:      Optional version statement, stating which version of FlightGear the function was added.
 
; commit:      Optional commit link. If given, the parameter should use one of {{tl|fgdata commit}}, {{tl|flightgear commit}}, or {{tl|simgear commit}}.


; private:      The private function behind the function being documented. It is often named the same, but usually has an underscore (<code>_</code>) preceding it. An example is <code>cmdarg()</code> and <code>_cmdarg()</code>.
; private:      The private function behind the function being documented. It is often named the same, but usually has an underscore (<code>_</code>) preceding it. An example is <code>cmdarg()</code> and <code>_cmdarg()</code>.
Line 102: Line 105:
| param3    = c
| param3    = c
| param3text = Optional argument.
| param3text = Optional argument.
| example1   = Example using just one parameter.
| example1text   = Example using just one parameter.
| example1  = var variable = function("string");
| example1  = var variable = function("string");
| example2text = Example of the usage of all parameters.
| example2text = Example of the usage of all parameters.

Revision as of 13:22, 12 February 2016


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      =
| version     =
| commit      =
| private     =
| 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, stating which version of FlightGear the function was added.
commit
Optional commit link. If given, the parameter should use one of {{fgdata commit}}, {{flightgear commit}}, or {{simgear commit}}.
private
The private function behind the function being documented. It is often named the same, but usually has an underscore (_) preceding it. An example is cmdarg() and _cmdarg().
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]);
| source     = {{flightgear file|t=Source}}
| 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()
function(a, [b, c]);

Source — Version added: FG 3.2

Returns a value or nil.
a
Mandatory argument.
b
Optional argument.
c
Optional argument.

Examples

Example using just one parameter.
var variable = function("string");
Example of the usage of all parameters.
var variable = function("string", 1.234, FlightGear);