Any questions about history, geography, science, etc., as well as Vikidia itself and how it works? Ask The Scholar!

Help:Templates/How to document a template?

From Vikidia, the encyclopedia for 8 to 13-year-old children that anyone can improve
Jump to navigation Jump to search

Why document?[change source]

Templates are pages that accept parameters; these parameters are referenced in the template's source code, but that code is often obscure to those who are not MediaWiki developers. Documentation therefore serves to explain the use of the template clearly (and as consistently as possible). It is ‘’'necessary'‘’ because templates are and must be used by a wide range of contributors who are not familiar with the intricacies of the software (and ‘'a fortiori’' with templates).

Where to document?[change source]

Since template pages are used via inclusion, it is preferable for their text to be as short as possible (to limit the processing of the pages that use them and to speed up the loading of those pages). Furthermore, the {{t}} template refers to the template page, and the user therefore expects to find the documentation there. The documentation should therefore be written on a subpage of the template, included within a <noinclude>...</noinclude> section of the template.

Just as a banner indicates that a user page is not part of the encyclopedia ({{Personal page}}), an equivalent is used to identify a template’s documentation page: {{Documentation subpage}}. This implies that the documentation subpage must be named "Documentation".

How to document?[change source]

To create a new template containing the preloaded text, use the form below:


Alternatively, copy the text below into the template page:

<includeonly><!--

--><!-- Replace this comment with your template code --><!--

--><includeonly><noinclude>
{{Documentation}}
</noinclude>

Once your page is created, click on the link to the documentation subpage and copy the text below into it:

{{Documentation subpage}}

== Usage ==
<!-- Explain here what the template is used for -->

== Syntax ==
<pre><nowiki>
<!-- Enter the template syntax here -->
</nowiki></pre>

{|class=“wikitable”
! Name !! Required !! Default !! Description 
|-
<!-- Enter the description of the template parameters here -->
|}

== Example ==
<pre><nowiki>
<!-- Provide an example of how to use your template here -->
</nowiki></pre>
results in:
<!-- Copy the same example here so that the user can see the result -->

<!-- You can provide other examples if necessary -->

== Variants ==
<!-- Enter the list of related templates here -->

== See also ==
<!-- Enter the list of related pages here -->
[[Category:Templates]]
<!-- Add any other categories here -->

For help, feel free to consult the documentation for other templates. For example, the documentation for the {{purge}} template.