Template:Documentation subpage/doc

Purpose
This template is intended for helping to document templates.

As a good practice, template documentation is often placed in a subpage (called "doc") of the template itself, which is then transcluded at the end of the template page. This separates the often complex template code from the documentation, making the documentation easier to edit. It also allows templates to be protected where necessary, while allowing anyone to edit the documentation, categories, and interwiki links. This method is sometimes referred to as the "template doc page pattern".

This template is dealing with the documentation subpage part of the job – the template page part being dealt with by the Documentation template.

It displays a message box about template documentation and adds the documentation subpage to the Template documentation category. The message box, however, is not displayed when the documentation is transcluded in the template page.

Usage
This template is used without any parameters, at the top of the /doc subpage of the template being documented (i.e. the page whose name is the name of the template postfixed by ).

This should be the first line of the documentation subpage:

By the way, categories and interwiki links are used to be added to the bottom of the documentation subpage. Those which are related to the template have to be included within  tags, while those which are related to the documentation subpage itself have to be included within   tags.

To summarize, here is a good structure of a template documentation subpage:

Examples
This template is documented using itself. As an example of what message box is displayed at the top of each documentation subpage using this template, see the subpage from which this documentation is transculded. The output of this template can be viewed at the top of this page, below the title.

Related templates

 * Documentation