Template:Func link: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
No edit summary
(Add pre for e.g., _cmdarg())
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly>{{#switch: {{{api|error}}}
<includeonly>{{#if: {{{1|}}} <!-- has argument -->
| error = <big style="color:red">Missing argument!</big> <!-- error message -->
| <span class="plainlinks"><code><!-- formatting
<!-- pre-made links for core library Nasal APIs below -->
-->{{#if: {{{link|}}} <!-- has link? -->
| maketimer
  | [{{{link}}} {{{pre|}}}{{{1}}}] <!-- yes -->
| maketimer() = [[List_of_Nasal_extension_functions#maketimer.28.29_.282.11.2B.29|<tt>maketimer()</tt>]]
  | [[ <!-- no, start wiki link
| #default = {{#if: {{{ext|}}}<!-- check if an external link is supplied
 
-->| <span class="plainlinks">[{{{ext}}} <tt>{{{api}}}</tt>]</span> <!-- yes, so link to that
  -->{{#if: {{{page|}}} <!-- has page -->
-->| [[<!-- no so add wikilink
    | {{#ifeq: {{{page}}} | this | {{FULLPAGENAME}} }}<!-- if page is "this", use page the template is on -->
-->{{#if: {{{page|}}} <!-- is it on a different page?
    | Nasal library<!-- no, assume that it is in the doc
-->| {{{page}}} <!-- yes -->  
    -->{{#if: {{{2|}}} <!-- namespace given? -->
| {{FULLPAGENAME}} }} <!-- no, it's on this page
      | /{{{2}}}<!-- yes, link to it -->
-->#{{{api}}}|<tt>{{{api}}}</tt>]] <!-- finish the link
      }}
-->}}}}</includeonly><noinclude>{{Informative template|1=
    }}<!--
 
  -->#{{urlencode:{{{1}}}|WIKI}}<!-- encode in wiki link form
 
  -->|<!-- 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 ==
This template can be used to add a link to the documentation of a [[Nasal]] API function.  It can also be used for others (e.g., C++ functions) and can link to external sites.
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 ==
== 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}}


{{inote|All parameter 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 : If desired, link to another wiki page (e.g., ''Help:Template'').
; namespace : Optional namespace. Used when linking to the [[:Template:Nasal namespaces|namespace documentation]].


; ext : External link to another site.
; 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|api=maketimer()}} is available in FG 2.11+</nowiki>


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


<nowiki>See also {{Func link|api=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|api=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|api=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|api=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: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()