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 on this wiki. It transcludes the contents of the template's /doc subpage, which contains the template's documentation. (Templates intentionally not following this system should be listed at Category:Templates not using a documentation subpage. See Special:UncategorizedTemplates and Special:WantedTemplates for templates lacking /doc subpages, or Category:Incomplete template documentation for templates whose /doc subpages are lacking key information.)
It also provides handy links to edit the template documentation and to update the appearance of the template page when that documentation has been changed (if necessary — this will happen eventually without any special actions beyond just saving your changes to the /doc subpage, but the "show changes" link provided by this template can make that happen faster).
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 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 a little work before you can save the page. To be more specific, you should replace each … with whatever content is appropriate, flesh out the usage and examples items (replacing TN with the template name), remove the explanatory <!-- comments -->, and omit anything else that's not relevant for your template). See a typical template documentation subpage for how this might look when it's finalized.
For details on how to use the various "tc" templates, see the documentation of {{tc}}, {{tc-var}}, {{tc-numvar}}, {{tc-namevar}}, and {{tc-names}}.
<noinclude>{{doc subpage}}[[Category:Template documentation]]</noinclude>
== Documentation ==
<!-- replace "…" as appropriate and remove all these HTML comments -->
…<noinclude>[[Category:Incomplete template documentation]]</noinclude>
<!-- remove the line above once the documentation is sufficiently detailed -->
=== Usage ===
* {{tc|TN}}<!-- replace TN by the template name see -->
* {{tc|TN|…}}
* {{tc-var|TN|…}}<!-- looks like: {{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|…=|…=}} -->
* {{code|<nowiki>{{TN|…}}</nowiki>}}<!-- for more complex cases -->
<!-- use whichever forms are needed and delete the rest -->
=== Examples ===
* {{tc|TN}} ⇒ {{TN}}
* {{tc|TN|…}} ⇒ {{TN|…}}
* {{code|<nowiki>{{TN|…}}</nowiki>}} ⇒ {{TN|…}}
<!-- see [[Template:/doc]] for actual sample code for Usage and Examples -->
<includeonly>
[[Category:Templates]]
[[Category:Templates …]]
</includeonly>
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- Category:Templates especially useful in template documentation
- Category:Templates for illustrating wiki markup – more templates that may be useful in template documentation