Template:Doc/doc
Documentation
A call to this template (placed inside of a <noinclude>…</noinclude> element, as seen below) should be the last thing in (almost) every template page. It transcludes the contents of the template's /doc subpage, which contains the template's documentation. (Templates not following this system are listed at Category:Templates not using a documentation subpage.)
After saving a newly created template containing a call to this template, simply follow the "redlink" to create the template's documentation subpage. A bare-bones /doc subpage, suitable for copy-pasting is given below.
Usage
active content of template here<noinclude>{{doc}}</noinclude><includeonly>active content of template here</includeonly><noinclude>{{doc}}</noinclude>
Note that the active content of the template should be immediately followed, on the same line, by the <noinclude> tag. This is to prevent extra vertical whitespace from being introduced into the calling template's output, which can have very strange side-effects in some cases.
Sample /doc subpage contents
You can copy and paste the following wiki markup into any /doc subpage you are creating, as a starting point for your documentation. Obviously, this needs to be fleshed out a bit before you save the page (by replacing each … and getting rid of whatever usage lines and example lines are not relevant for your template — the three lines in those sections are for, respectively, bare template calls needing no input, template calls containing unnamed/positional parameters as input, and template calls containing named parameters and accompanying values). See a typical template documentation subpage for how this might look when it's finalized.
<noinclude>{{doc subpage}}[[Category:Template documentation]]</noinclude>
== Documentation ==
…
=== Usage ===
* <code><nowiki>{{…}}</nowiki></code>
* <code><nowiki>{{…</nowiki>|<var>…</var>}}</code>
* <code><nowiki>{{…</nowiki>|…=<var>…</var>}}</code>
=== Examples ===
* <code><nowiki>{{…}}</nowiki></code> ⇒ {{…}}
* <code><nowiki>{{…</nowiki>|…}}</code> ⇒ {{…|…}}
* <code><nowiki>{{…</nowiki>|…=…}}</code> ⇒ {{…|…=…}}
<includeonly>
[[Category:Templates]]
[[Category:Templates …]]
</includeonly>
Note that the categories listed after <includeonly> at the bottom apply to the template that you are documenting (every template should be listed in Category:Templates, and ideally in a few other template-related categories, based on what the template does and how it does it — see the subcategories of Category:Templates to find where your template should be listed). The only category that the /doc subpage itself should have is Category:Template documentation, provided by the first line of this sample code.
See also
{{doc subpage}}– marks a/docsubpage as being template documentation{{tp}},{{tpv}}, and{{tpvv}}– for referring to template parameters and their values in template documentation- Category:Templates for illustrating wiki markup – these templates can also be useful in template documentation