Difference between revisions of "Template:Doc"
Komidore64 (talk | contribs) |
Komidore64 (talk | contribs) (replace instances of <code> with Code template) |
||
Line 4: | Line 4: | ||
== Usage == | == Usage == | ||
− | Create a subpage of the template called | + | Create a subpage of the template called {{code|doc}}, place a {{code|<nowiki>{{doc/start}}</nowiki>}} at the start of your documentation, and {{code|<nowiki>{{doc/end}}</nowiki>}} at the end. |
− | On the main template page add | + | On the main template page add {{code|<nowiki><noinclude>{{clear}}{{doc}}</noinclude></nowiki>}} on a newline at the end of the template. |
Documentation subpages will automatically be added to [[:Category:Documentation templates]]. | Documentation subpages will automatically be added to [[:Category:Documentation templates]]. | ||
Line 14: | Line 14: | ||
=== clear === | === clear === | ||
− | If your main template page has floating content and you would like to stop it from going over the documentation, put | + | If your main template page has floating content and you would like to stop it from going over the documentation, put {{code|<nowiki>{{doc/start|clear}}</nowiki>}} instead of {{code|<nowiki>{{doc/start}}</nowiki>}} on your documentation page. |
− | This is also useful for templates not using | + | This is also useful for templates not using {{code|<nowiki><includeonly></nowiki>}} tags, as it will put some space between the template and the documentation box. |
=== nodoc=1 === | === nodoc=1 === | ||
− | If a template has no documentation and you don't know how to use it, put | + | If a template has no documentation and you don't know how to use it, put {{code|<nowiki>{{doc/start|nodoc=1}}</nowiki>}} (or if the template needs clear as well, {{code|<nowiki>{{doc/start|clear|nodoc=1}}</nowiki>}}) instead of {{code|<nowiki>{{doc/start}}</nowiki>}} 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]]. | The documentation's background will become red to make it more noticeable, and the page will be added to [[:Category:Templates with no documentation]]. | ||
Line 26: | Line 26: | ||
=== baddoc=1 === | === baddoc=1 === | ||
− | Similar to | + | Similar to {{code|nodoc}}, {{code|baddoc}} 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]]. | 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 | + | If both {{code|nodoc}} and {{code|baddoc}} are specified, {{code|baddoc}} will be ignored. |
== Example == | == Example == | ||
− | Let's say we want to add a template named | + | Let's say we want to add a template named {{code|HelloWorld}}. Its contents are the following: |
<pre><nowiki> | <pre><nowiki> | ||
Line 40: | Line 40: | ||
</nowiki></pre> | </nowiki></pre> | ||
− | To document how this template works for other editors, we create a subpage of it called | + | To document how this template works for other editors, we create a subpage of it called {{code|doc}}, having the full article name of {{code|HelloWorld/doc}}. |
Within that subpage we'll put the following wikitext: | Within that subpage we'll put the following wikitext: | ||
Line 65: | Line 65: | ||
</nowiki></pre> | </nowiki></pre> | ||
− | Now that we've documented our | + | Now that we've documented our {{code|HelloWorld}} template, we need to reference our documentation from the template by adding it at the bottom. |
<pre><nowiki> | <pre><nowiki> |
Revision as of 02:06, 29 August 2020
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!