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 ==
…<noinclude>[[Category:Incomplete template documentation]]</noinclude>
=== Usage ===
<!-- for simple cases -->
* {{tc|TN}}
* {{tc|TN|…}}
* {{tc-var|TN|…}}<!-- {{TN|<var>…</var>|<var>…</var>}} -->
* {{tc-numvar|TN|…}}<!-- {{TN|1=<var>…</var>|2=<var>…</var>}} -->
* {{tc-namevar|TN|…}}<!-- {{TN|…=<var>…</var>|…=<var>…</var>}} -->
* {{tc-names|TN|…}}<!-- {{TN|…=|…=}} -->
<!-- for more complex cases -->
* <code><nowiki>{{TN|…}}</code>
=== Examples ===
* {{tc|TN}} ⇒ {{TN}}
* {{tc|TN|…}} ⇒ {{TN|…}}
* <code>{{TN|…}}</code> ⇒ {{TN|…}}
<includeonly>
[[Category:Templates]]
[[Category:Templates …]]
</includeonly>
</nowiki>
The code <noinclude>[[Category:Incomplete template documentation]]</noinclude> found immediately below the == Documentation == header is there merely for convenience, so the documentation can be saved before it is complete enough to be totally useful to readers. This causes the documentation subpage to be listed in Category:Incomplete template documentation, so it can be found later and expanded/improved upon. Once you feel like the amount of documentation you have provided is sufficient, that code can be removed.
Note that the categories listed in the <includeonly>…</includeonly> portion 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