Template:Code Reference: Difference between revisions
Jump to navigation
Jump to search
m (add Category:Templates) |
(expound on documentation) |
||
Line 1: | Line 1: | ||
<noinclude> | <noinclude>Use this template instead of a <code><nowiki><ref></nowiki></code> tag if you are citing a class from the game's C# assemblies, such as <code>Assembly-CSharp.dll</code>. This is useful for cohesively formatting all such code references. | ||
{| class="wikitable" | |||
|- | |||
! Template Parameter !! Required? !! Default Value | |||
|- | |||
| <code>namespace</code> || No || <code>XRL.World.Parts</code> | |||
|- | |||
| <code>class</code> || Yes || None – This must be specified or else the template will error. | |||
|- | |||
| <code>method</code> || No || None – If omitted, a method name will not be included in the reference. | |||
|} | |||
== Usage Examples == | |||
Use the following form if you need to reference a part definition: | |||
<pre><nowiki>{{Code Reference | |||
| class = FakePart | |||
}}</nowiki></pre>{{Code Reference | |||
| class = FakePart | |||
}} | |||
Use the following form if you need to reference a class in a different namespace from <code>XRL.World.Parts</code>: | |||
<pre><nowiki>{{Code Reference | <pre><nowiki>{{Code Reference | ||
| namespace = Fake.Namespace | |||
| class = FakeClass | |||
}}</nowiki></pre>{{Code Reference | |||
| namespace = Fake.Namespace | |||
| class = FakeClass | |||
}} | |||
In some cases, it may be useful to additionally specify which method the logic in question occurs in. In that case, use the following form: | |||
<pre><nowiki>{{Code Reference | |||
| namespace = Fake.Namespace | |||
| class = FakeClass | |||
| method = FakeMethod | |||
}}</nowiki></pre>{{Code Reference | |||
| namespace = Fake.Namespace | | namespace = Fake.Namespace | ||
| class = FakeClass | | class = FakeClass | ||
| method = FakeMethod | | method = FakeMethod | ||
}} | }} | ||
If there are multiple method definitions with the same name, or it otherwise may help to be even more exact, you may append the parameter signature to the name of the method to specify an overload like so: | |||
<pre><nowiki>{{Code Reference | |||
| namespace = Fake.Namespace | |||
| class = FakeClass | |||
| method = FakeMethod(GameObject, GameObject) | |||
}}</nowiki></pre>{{Code Reference | |||
| namespace = Fake.Namespace | | namespace = Fake.Namespace | ||
| class = FakeClass | | class = FakeClass | ||
| method = FakeMethod | | method = FakeMethod(GameObject, GameObject) | ||
}} | }} | ||
[[Category:Templates]]</noinclude><includeonly>{{#if:{{{class|}}}|{{#tag:ref|<code>{{{namespace|XRL.World.Parts}}}.{{{class}}}{{#if:{{{method|}}}|, method {{{method}}}}}</code>}}|[[Category:Pages with code reference errors]]}}</includeonly> | [[Category:Templates]]</noinclude><includeonly>{{#if:{{{class|}}}|{{#tag:ref|<code>{{{namespace|XRL.World.Parts}}}.{{{class}}}{{#if:{{{method|}}}|, method {{{method}}}}}</code>}}|[[Category:Pages with code reference errors]]}}</includeonly> |