More actions
Added section describing the layout of template pages. |
→Creating and editing templates: Added section detailing template documentation. |
||
| Line 24: | Line 24: | ||
If you are unsure what to name your template early on, choose something slightly cryptic instead of a common term that someone else may/has already used. That name will be reserved by the system indefinitely; please ask an administrator to help rename your template later, if necessary. | If you are unsure what to name your template early on, choose something slightly cryptic instead of a common term that someone else may/has already used. That name will be reserved by the system indefinitely; please ask an administrator to help rename your template later, if necessary. | ||
=== Template documentation === | |||
All templates should include documentation which describes their purpose and use. Template documentation should be written on a separate page, made by appending <code/doc</code> to the template's main page: | |||
{{code|Template:<template name>/doc}} | |||
The {{tl|Documentation}} template can be used on a template's main page (wrapped in {{tag|noinclude}} tags) to automatically transclude a template's documentation, so long as the documentation page follows the aforementioned naming convention. | |||
If the {{tl|Documentation}} template is included on a template page for which documentation has not yet been written, {{tl|Documentation}} will generate a helpful link that will pre-populate the documentation page with a general outline of how documentation may be written, which also includes basic formatting: | |||
<pre> | |||
;Description | |||
:This template is used to do something. | |||
;Dependencies:<!-- delete if N/A --> | |||
:* Uses (some CSS, JS, file, or other template).<!-- delete if N/A --> | |||
;Syntax | |||
:Type <code>{{t|templatename|param1<!-- delete if N/A -->|namedparam=<!-- delete if N/A -->}}</code> somewhere. | |||
;Sample output | |||
:<code><nowiki>{{templatename|foo1<!-- delete if N/A -->|foo2=<!-- delete if N/A -->}}</nowiki></code> | |||
::gives... | |||
{{templatename|foo1<!-- delete if N/A -->|foo2=<!-- delete if N/A -->}} | |||
;See also:<!-- delete if N/A --> | |||
:* [[Template:<!-- Some other template -->]]<!-- delete if N/A --> | |||
:* [[<!-- Some other related page -->]]<!-- delete if N/A --> | |||
<includeonly>[[Category:Template|{{PAGENAME}}]]<!-- Any categories for the template itself --></includeonly> | |||
<noinclude>[[Category:Template documentation|{{PAGENAME}}]]</noinclude> | |||
</pre> | |||
Following this guideline is not required, but it can be useful to editors who lack experience writing template documentation. As noted in the pre-populated text, the documentation, when transcluded on the main template page, will assign the template itself to [[:Category:Template]], and the documentation page to [[:Category:Template documentation]]. Any other categories for either template or documentation should be applied using this method as well. | |||
==== Link to main template ==== | |||
Though not required or suggested by the pre-populated text, it can be useful to include a link to a template's main page at the top of its documentation page, as MediaWiki does not automatically generate such links for templates (though it does in other namespaces). This link must be wrapped in {{tag|noinclude}} tags to ensure it is not transcluded with the actual documentation: | |||
{{code|<nowiki><noinclude>{{main|Template:<template name>}}</noinclude></nowiki>}} | |||
== Using templates == | == Using templates == | ||