Template:Doc/Documentation

Template page

This template is for adding documentation to other templates.

Usage

To add documentation to a template, simply add the following to the bottom of the template code:

<noinclude>
{{doc}}
</noinclude>

It is usually important that there be no space at all between the last bit of the template code, and the documentation code lines. Normally you also want to wrap the actual template code in <includeonly> tags.

For example, if your template code looked like this:

This is {{{my}}} template.

To add documentation, first you wrap the template in <includeonly> tags:

<includeonly>This is {{{my}}} template.</includeonly>

Then you add the {{doc}} template (wrapped in <noinclude> tags):

<includeonly>This is {{{my}}} template.</includeonly><noinclude>
{{doc}}
</noinclude>

If no documentation page exists for the template this documentation template is used for, there will be a warning on the template page. The template will also be added to the hidden category Templates needing documentation.

It is very important to use the <noinclude> tags to wrap the documentation, otherwise it will propagate up to any pages that include the template. Once you have the documentation safely wrapped in <noinclude>, nobody can break your template by editing the template's documentation - they would have to edit the template code itself (or the code of some other template your template includes). So don't forget those <noinclude> tags!