Template:Code Reference: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
(expound on documentation)
m (replace error category with Template:Template Error)
Line 56: Line 56:
}}
}}


[[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>}}|{{Template Error}}}}</includeonly>

Revision as of 04:30, 25 August 2020

Use this template instead of a <ref> tag if you are citing a class from the game's C# assemblies, such as Assembly-CSharp.dll. This is useful for cohesively formatting all such code references.

Template Parameter Required? Default Value
namespace No XRL.World.Parts
class Yes None – This must be specified or else the template will error.
method 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:

{{Code Reference
| class = FakePart
}}

[1]

Use the following form if you need to reference a class in a different namespace from XRL.World.Parts:

{{Code Reference
| namespace = Fake.Namespace
| class     = FakeClass
}}

[2]

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:

{{Code Reference
| namespace = Fake.Namespace
| class     = FakeClass
| method    = FakeMethod
}}

[3]

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:

{{Code Reference
| namespace = Fake.Namespace
| class     = FakeClass
| method    = FakeMethod(GameObject, GameObject)
}}

[4]

  1. XRL.World.Parts.FakePart
  2. Fake.Namespace.FakeClass
  3. Fake.Namespace.FakeClass, method FakeMethod
  4. Fake.Namespace.FakeClass, method FakeMethod(GameObject, GameObject)