Template:Doc
Document how a template works and how to use it.
Usage
Create a subpage of the template called Template:Code, place a Template:Code at the start of your documentation, and Template:Code at the end.
On the main template page add Template:Code on a newline at the end of the template.
Documentation subpages will automatically be added to Category:Documentation templates.
Optional parameters
clear
If your main template page has floating content and you would like to stop it from going over the documentation, put Template:Code instead of Template:Code on your documentation page.
This is also useful for templates not using Template:Code tags, as it will put some space between the template and the documentation box.
nodoc=1
If a template has no documentation and you don't know how to use it, put Template:Code (or if the template needs clear as well, Template:Code) instead of Template:Code on your documentation page.
The documentation's background will become red to make it more noticeable, and the page will be added to Category:Templates with no documentation.
baddoc=1
Similar to Template:Code, Template:Code is used to mark templates that do have documentation, but it isn't very good. This can mean it doesn't have enough examples, doesn't explain all the functions properly, or doesn't explain the point of the template well.
The documentation's background will become yellow to make it more noticeable, and the page will be added to Category:Templates with bad documentation.
If both Template:Code and Template:Code are specified, Template:Code will be ignored.
Example
Let's say we want to add a template named Template:Code. Its contents are the following:
Hello, {{{1}}}!
To document how this template works for other editors, we create a subpage of it called Template:Code, having the full article name of Template:Code.
Within that subpage we'll put the following wikitext:
{{doc/start}} Say hello! == Usage == Say hello to a name. {{helloworld|NAME}} == Example == {{helloworld|James}} gives: Hello, James! {{doc/end}}
Now that we've documented our Template:Code template, we need to reference our documentation from the template by adding it at the bottom.
Hello, {{{1}}}! <noinclude>{{clear}}{{doc}}</noinclude>
Now the template's documentation will be displayed any time the template is viewed!