WikiDevi.Wi-Cat.RU:Template documentation

Templates are a very powerful feature of MediaWiki, but can be confusing to new users and even experienced users can have difficulty making sense of the more complex ones. Templates should therefore be accompanied by documentation to improve usability.

Template documentation should explain what a template does and how to use it. It should be simple enough that a user without complete knowledge of the intricacies of template syntax – which includes many experienced contributors who focus their attention elsewhere – can use it correctly. This is especially true in the case of very widely-used templates.

What to include
Template documentation should cover:


 * The basic purpose of the template: what it does and if it is not immediately obvious, why it needs to be done. If there are other templates with similar names or purposes, it's a good idea to mention those, in order to reduce the chance of the wrong one being used.
 * The parameters of the template: whether they are numbered, named or optional, and if so, what the default values are and what effect they have. If a parameter can take only a limited set of values or is constrained in any way, for example, if it can only use "yes", "no", or a number, this should be clearly explained.
 * Usage examples: specify the exact wikitext that should be used and the result that it produces. The wikitext can be enclosed in a  container, to make it clear and . If the template can be used in several different ways, with or without optional parameters, for example, provide a range of examples. A good way to do so is to transclude the template itself into the documentation a few times (i.e., use live examples), with different parameters each time and list the parameters used in each case. With Template:Xpd this can be done without putting the template call twice in the wikitext.
 * Related templates: if the template is one of a series of templates, include links to these – in particular, ensure that every template in the series is linked from each of the others, as this makes navigation easier. (A separate navigation template may be useful for this purpose, see: Template:Protection templates).
 * Categories and InterWikimedia links, where applicable. Like the documentation, these must be within a  container. Many template categories are available, see: Category:WikiDevi templates to browse through them.

Template documentation is often placed in a subpage 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. This method is sometimes referred to as the "template doc page pattern".

Documentation of any sort on a template page should always be enclosed by a  container, so that it does not show up when the template is used on another page. Text on the template page itself adds to the amount of text that must be processed when displaying the template, which is limited for performance reasons. Placing the documentation in a subpage avoids this (MediaWiki developers have recommended it for this reason).

How to create a documentation subpage
Template documentation subpages should be named and formatted using the following general pattern, for consistency.

Suppose your template is named. Create a subpage with the name. See the details at Documentation subpage or copy-paste the following wikitext as a start for your documentation:

Categories and interwiki links

 * To place the template itself into a category, add the  code inside an  ...  section on the doc subpage.


 * To create an interwiki link for the template itself, add the  code inside an  ...  section on the doc subpage.


 * To place the doc subpage into a category, add the  code inside a  ...  section on the doc subpage.


 * To make the template place an article into a category (when the article includes the template), add the  code inside an  ...  section on the template page.

/sandbox and /testcases
Before doing changes to a template it can be good to first copy the template code to a sandbox and run some testcases, since the template might be visible on thousands of pages. If you create subpages named exactly "/sandbox" and "/testcases" to a template then the green box on the template auto-detects this and will show links to those pages in its header. See WikiDevi:Template test cases for more information.

Several templates, one documentation page
When several templates work together or are very similar then it is often clearer and easier to maintain one single documentation page that documents them together. The simplest way to do this is to make a full documentation page at one of the templates, and then make "soft redirects" from the other templates. That is, to make very short documentation pages at the other templates that have only one or two sentences that states where the full documentation can be found and link to it. See for instance wrap.

Stub templates
Stub templates are one of the very rare forms of template that do not generally have documentation. As all stub templates operate in identical ways, they could theoretically be linked to one documentation page giving instruction for their use. This is, however, regarded as superfluous, since all stub templates already contain a link to WikiDevi:Stub, which more thoroughly covers all the information that would normally be covered by a documentation page.

Tips & tricks
Here's some tips to facilitate writing documentations.
 * Links to templates like can be inserted by writing . See tlp for similar templates.
 * HTML tags like  can be easily inserted with tag. This example is written as
 * Equals sign = can be inserted with . For example, is made by . Avoid the equivalent notation &amp;#61; which is not easy to read for other editors.
 * Don't forget the single tag.  example becomes  example, and [ https://wikidevi.com no link] is [ https://wikidevi.com no link]. See WP:NOWIKI for the details.
 * For a link to a category, use cat. For example becomes.