From DSP Wiki
Template documentation (for the above template, sometimes hidden or invisible)
This template is used to insert documentation on template pages.
Syntax and Parameters
Type <noinclude>{{t|documentation|<var>{{FULLPAGENAME}}/doc</var>}}</noinclude> at the end of the template page. Include the full (exact, including namespace) name of the documentation page as a parameter where possible.

General usage

On the Template page

You should attach <noinclude>{{t|documentation|{{subst:FULLPAGENAME}}/doc}}</noinclude> to the end of the template page, so it looks like the below:

<includeonly> TEMPLATE CODE HERE
Any categories to be inserted into articles by the template</includeonly><noinclude>

This will fill in and add the documentation template to the template-page, but not pages where the template is used due to the inclusion tags. The subst:FULLPAGENAME serves as a wikimedia "Magic Word" and will be replaced by the wikispace and page name once the edit is completed, and serves to direct the template towards the appropriate page for substitution in case the automatic code fails to work.

On the Template/doc page

You should fill this out with information on how to use the template. For example,

See also Template:Documentation/preload
:This template is used to do something.
:Type <code>{{t|templatename}}</code> somewhere.
;Sample output
:<code><nowiki>{{templatename|foo}}</nowiki></code> gives...

<includeonly>Any categories for the template itself</includeonly><noinclude>[[Category:Template documentation|{{PAGENAME}}]]</noinclude>

Use any or all of the above description/syntax/sample output sections. You may also want to add "see also" or further usage information sections.

Note that the above example also uses {{T}} to display the formatting of the template code, without actually calling the template for transclusion (as normally happens with the squiggly brackets).
Visit Template:documentation/doc to edit this text! (How does this work?) (Refresh this text - why?)