Template:Func link: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(Add <span class="plainlinks"> + api -> 1. Could do this differently)
(Add pre for e.g., _cmdarg())
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly>{{#if: {{{ext|}}} <!-- is an external link is supplied?
<includeonly>{{#if: {{{1|}}} <!-- has argument -->
-->| <span class="plainlinks">[{{{ext}}} <code>{{{1}}}</code>]</span> <!-- yes, so link to that
| <span class="plainlinks"><code><!-- formatting
-->{{#if: {{{link|}}} <!-- has link? -->
  | [{{{link}}} {{{pre|}}}{{{1}}}] <!-- yes -->
  | [[ <!-- no, start wiki link


-->| {{#switch: {{{1|error}}} <!-- no, so use switch for pre-set APIs
  -->{{#if: {{{page|}}} <!-- has page -->
-->| error = <big style="color:red">Missing argument!</big> <!-- error message -->
    | {{#ifeq: {{{page}}} | this | {{FULLPAGENAME}} }}<!-- if page is "this", use page the template is on -->
<!-- pre-made links for core library Nasal APIs below -->
    | Nasal library<!-- no, assume that it is in the doc
| append
    -->{{#if: {{{2|}}} <!-- namespace given? -->
| append() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#append.28.29|<code>append()</code>]]</span>
      | /{{{2}}}<!-- yes, link to it -->
| bind
      }}
| bind() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#bind.28.29|<code>bind()</code>]]</span>
    }}<!--
| call
| call() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#call.28.29|<code>call()</code>]]</span>
| caller
| caller() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#caller.28.29|<code>caller()</code>]]</span>
| chr
| chr() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#chr.28.29|<code>chr()</code>]]</span>
| closure
| closure() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#closure.28.29|<code>closure()</code>]]</span>
| cmp
| cmp() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#cmp.28.29|<code>cmp()</code>]]</span>
| compile
| compile() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#compile.28.29|<code>compile()</code>]]</span>
| contains
| contains() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#contains.28.29|<code>contains()</code>]]</span>
| delete
| delete() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#delete.28.29|<code>delete()</code>]]</span>
| die
| die() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#die.28.29|<code>die()</code>]]</span>
| find
| find() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#find.28.29|<code>find()</code>]]</span>
| ghosttype
| ghosttype() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#ghosttype.28.29|<code>ghosttype()</code>]]</span>
| id
| id() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#id.28.29|<code>id()</code>]]</span>
| int
| int() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#int.28.29|<code>int()</code>]]</span>
| keys
| keys() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#keys.28.29|<code>keys()</code>]]</span>
| left
| left() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#left.28.29|<code>left()</code>]]</span>
| num
| num() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#num.28.29|<code>num()</code>]]</span>
| pop
| pop() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#pop.28.29|<code>pop()</code>]]</span>
| right
| right() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#right.28.29|<code>right()</code>]]</span>
| setsize
| setsize() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#setsize.28.29|<code>setsize()</code>]]</span>
| size
| size() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#size.28.29|<code>size()</code>]]</span>
| sort
| sort() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#sort.28.29|<code>sort()</code>]]</span>
| split
| split() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#split.28.29|<code>split()</code>]]</span>
| sprintf
| sprintf() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#sprintf.28.29|<code>sprintf()</code>]]</span>
| streq
| streq() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#streq.28.29|<code>streq()</code>]]</span>
| substr
| substr() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#substr.28.29|<code>substr()</code>]]</span>
| subvec
| subvec() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#subvec.28.29|<code>subvec()</code>]]</span>
| typeof
| typeof() = <span class="plainlinks">[[User:Red_Leader/Nasal_library#typeof.28.29|<code>typeof()</code>]]</span>
<!-- extension functions -->
| cmdarg
| cmdarg() = <span class="plainlinks">[[List_of_Nasal_extension_functions#cmdarg.28.29|<code>cmdarg()</code>]]</span>
| fgcommand
| fgcommand() = <span class="plainlinks">[[List_of_Nasal_extension_functions#fgcommand.28.29|<code>fgcommand()</code>]]</span>
| addcommand
| addcommand() = <span class="plainlinks">[[List_of_Nasal_extension_functions#addcommand.28.29|<code>addcommand()</code>]]</span>
| removecommand
| removecommand() = <span class="plainlinks">[[List_of_Nasal_extension_functions#removecommand.28.29|<code>removecommand()</code>]]</span>
| print
| print() = <span class="plainlinks">[[List_of_Nasal_extension_functions#print.28.29|<code>print()</code>]]</span>
| logprint
| logprint() = <span class="plainlinks">[[List_of_Nasal_extension_functions#logprint.28.29|<code>logprint()</code>]]</span>
| getprop
| getprop() = <span class="plainlinks">[[List_of_Nasal_extension_functions#getprop.28.29|<code>getprop()</code>]]</span>
| setprop
| setprop() = <span class="plainlinks">[[List_of_Nasal_extension_functions#setprop.28.29|<code>setprop()</code>]]</span>
| interpolate
| interpolate() = <span class="plainlinks">[[List_of_Nasal_extension_functions#interpolate.28.29|<code>interpolate()</code>]]</span>
| settimer
| settimer() = <span class="plainlinks">[[List_of_Nasal_extension_functions#settimer.28.29|<code>settimer()</code>]]</span>
| maketimer
| maketimer() = <span class="plainlinks">[[List_of_Nasal_extension_functions#maketimer.28.29_.282.11.2B.29|<code>maketimer()</code>]]</span>
| geodinfo
| geodinfo() = <span class="plainlinks">[[List_of_Nasal_extension_functions#geodinfo.28.29|<code>geodinfo()</code>]]</span>
| airportinfo
| airportinfo() = <span class="plainlinks">[[List_of_Nasal_extension_functions#airportinfo.28.29|<code>airportinfo()</code>]]</span>
| history
| history() = <span class="plainlinks">[[List_of_Nasal_extension_functions#history.28.29_.283.1.2B.29|<code>history()</code>]]</span>
| flightplan
| flightplan() = <span class="plainlinks">[[List_of_Nasal_extension_functions#flightplan.28.29|<code>flightplan()</code>]]</span>
| carttogeod
| carttogeod() = <span class="plainlinks">[[List_of_Nasal_extension_functions#carttogeod.28.29|<code>carttogeod()</code>]]</span>
| geodtocart
| geodtocart() = <span class="plainlinks">[[List_of_Nasal_extension_functions#geodtocart.28.29|<code>geodtocart()</code>]]</span>
| parsexml
| parsexml() = <span class="plainlinks">[[List_of_Nasal_extension_functions#parsexml.28.29|<code>parsexml()</code>]]</span>
| resolvepath
| resolvepath() = <span class="plainlinks">[[List_of_Nasal_extension_functions#resolvepath.28.29|<code>resolvepath()</code>]]</span>
| rand
| rand() = <span class="plainlinks">[[List_of_Nasal_extension_functions#rand.28.29|<code>rand()</code>]]</span>
| srand
| srand() = <span class="plainlinks">[[List_of_Nasal_extension_functions#srand.28.29|<code>srand()</code>]]</span>
| md5
| md5() = <span class="plainlinks">[[List_of_Nasal_extension_functions#md5.28.29_.283.1.2B.29|<code>md5()</code>]]</span>
| abort
| abort() = <span class="plainlinks">[[List_of_Nasal_extension_functions#abort.28.29|<code>abort()</code>]]</span>
| #default = <span class="plainlinks">[[{{#if: {{{page|}}} <!-- is it on a different page?
-->| {{{page}}} <!-- yes  
-->| {{FULLPAGENAME}} }} <!-- no, it's on the page that the template is on
-->#{{{1}}}|<code>{{{1}}}</code>]]</span><!--  


-->}}<!-- end #switch:
  -->#{{urlencode:{{{1}}}|WIKI}}<!-- encode in wiki link form


-->}}<!-- end #if: --></includeonly><noinclude>{{Informative template|1=
  -->|<!-- start link label
 
  -->{{#if: {{{2|}}} | {{{2}}}. }}<!-- use namespace if given
  -->{{#if: {{{3|}}} | {{{3}}}. }}<!-- use class if given
 
  -->{{{pre|}}}{{{1}}}<!-- finally, function name
 
  -->]] <!-- close wiki link
 
-->}}<!--
 
--></code></span> <!-- end formatting -->
 
| {{error|Missing argument!|func link}} <!-- missing argument case -->
}} <!-- close --></includeonly><noinclude>{{Informative template|1=
__NOTOC__
__NOTOC__
== Goal ==
== Goal ==
Line 123: Line 35:


== Usage ==
== Usage ==
  <nowiki>{{</nowiki>'''Func link'''<nowiki>|</nowiki>api<nowiki>|</nowiki>''page''<nowiki>|</nowiki>''ext''<nowiki>}}</nowiki>
  {{obr}}'''func link'''{{!}}api{{!}}''namespace''{{!}}''class''{{!}}''page=''{{!}}''link=''{{!}}''pre=''{{cbr}}


All parameters except '''api''' are optional
All parameters except '''api''' are optional


; api : Name of the function to link to.
; api : Name of the function to link to. Must include the brackets (<code>()</code>).


; page : Link to another wiki page, for example '''Help:Template'''.
; namespace : Optional namespace. Used when linking to the [[:Template:Nasal namespaces|namespace documentation]].


; ext : External link to another site.  Overrides '''page'''.
; class : Optional class. Used in link label.


== Examples ==
; page : Link to another wiki page, for example '''Help:Template'''. If given as "this", the template will use the page the template is on.
<nowiki>{{Func link|maketimer}} is available in FG 2.11+</nowiki>


{{Func link|maketimer}} is available in FG 2.11+
; link: External link to another site. Overrides '''page'''.


<nowiki>See also {{Func link|http.load()|page=List_of_Nasal_extension_functions}}.</nowiki>
; pre: Text to prepend to the function's name in the link label. Can be used for an underscore, e.g., {{func link|cmdarg()|pre=_}}.


See also {{Func link|http.load()|page=List_of_Nasal_extension_functions}}.
== Examples ==
=== Link to namespace ===
<nowiki>See also {{func link|open()|io}}.</nowiki>
See also {{func link|open()|io}}.


  <nowiki>{{Func link|printf()|ext=http://en.wikipedia.org/wiki/Printf_format_string}}</nowiki>
=== Link to namespace and class ===
  <nowiki>{{func link|set_latlon()|geo|Coord}} is used to set coordinates.</nowiki>
{{func link|set_latlon()|geo|Coord}} is used to set coordinates.


{{Func link|printf()|ext=http://en.wikipedia.org/wiki/Printf_format_string}}
=== Link to external site ===
<nowiki>{{func link|printf()|link=http://en.wikipedia.org/wiki/Printf_format_string}}</nowiki>
{{func link|printf()|link=http://en.wikipedia.org/wiki/Printf_format_string}}


}}
}}


[[Category:Link templates]]
[[Category:Link templates]]
[[Category:Code templates]]
</noinclude>
</noinclude>

Latest revision as of 13:52, 16 November 2016

The following template description is not displayed when the template is inserted in an article.

Goal

This template can be used to add a link to the documentation of a Nasal API function. It can also be used for others (for example C++ functions) and can link to external sites.

Usage

{{func link|api|namespace|class|page=|link=|pre=}}

All parameters except api are optional

api
Name of the function to link to. Must include the brackets (()).
namespace
Optional namespace. Used when linking to the namespace documentation.
class
Optional class. Used in link label.
page
Link to another wiki page, for example Help:Template. If given as "this", the template will use the page the template is on.
link
External link to another site. Overrides page.
pre
Text to prepend to the function's name in the link label. Can be used for an underscore, e.g., _cmdarg() .

Examples

Link to namespace

See also {{func link|open()|io}}.

See also io.open() .

Link to namespace and class

{{func link|set_latlon()|geo|Coord}} is used to set coordinates.

geo.Coord.set_latlon() is used to set coordinates.

Link to external site

{{func link|printf()|link=http://en.wikipedia.org/wiki/Printf_format_string}}

printf()