வார்ப்புரு:Jct/doc
{{Wikipedia how to|WP:TDOC}}
 
 [[Help:Template|Templates]] are a very powerful feature of [[MediaWiki]], but can be confusing to new users and even experienced users can have difficulty making sense of the more complex ones. Templates should therefore be accompanied by '''[[documentation]]''' to improve usability.
 
 Template documentation should explain what a template does and how to use it. It should be simple enough that a user without complete knowledge of the intricacies of template syntax&amp;nbsp;– which includes many experienced contributors who focus their attention elsewhere&amp;nbsp;– can use it correctly. This is especially true in the case of very widely used templates.
 
 == What to include ==
 Template documentation should cover:
 * The '''basic purpose''' of the template: what it does and if it is not immediately obvious, why it needs to be done. If there are other templates with similar names or purposes, it's a good idea to mention those, in order to reduce the chance of the wrong one being used.
 * The '''[[Help:Template#Parameters|parameters]]''' of the template: whether they are numbered, named or optional, and if so, what the default values are and what effect they have. If a parameter can take only a limited set of values or is constrained in any way, for example, if it can only use &quot;yes&quot;, &quot;no&quot;, or a number, this should be clearly explained.
 * '''Usage examples''': specify the exact wikitext that should be used and the result that it produces. The wikitext can be enclosed in a {{tag|code}} container, to make it clear and &lt;code&gt;easy to copy, like this&lt;/code&gt;. If the template can be used in several different ways, with or without optional parameters, for example, provide a range of examples. A good way to do so is to transclude the template itself into the documentation a few times (i.e., use live examples), with different parameters each time and list the parameters used in each case. With [[Template:Xpd]] this can be done without putting the template call twice in the wikitext.
 * '''Related templates''': if the template is one of a series of templates, include links to these&amp;nbsp;– in particular, ensure that every template in the series is linked from each of the others, as this makes navigation easier. (A separate navigation template may be useful for this purpose, see: [[Template:Protection templates]]).
 * '''[[Wikipedia:Categorization|Categories]]''' where applicable ([[Help:Interwikimedia links|InterWikimedia links]] should be listed at [[d:|Wikidata]] – more information at [[Wikipedia:Wikidata]]).  Like the documentation, categories must be listed within a {{tag|noinclude}} container on a template, or witin {{tag|includeonly}} tags if placed on a documentation page. Many template categories are available, see: [[:Category:Wikipedia templates]] to browse through them.
 
 Template documentation is often placed in a [[Wikipedia:Subpages|subpage]] of the template itself, which is then [[Wikipedia:Transclusion|transcluded]] at the end of the template page. This separates the often complex template code from the documentation, making the documentation easier to edit. It also allows templates to be [[Wikipedia:Protection policy|protected]] where necessary, while allowing anyone to edit the documentation. This method is sometimes referred to as the &quot;template doc page pattern&quot;.
 
 Documentation of any sort on a template page should always be enclosed by a {{tag|noinclude}} container, so that it does not show up when the template is used on another page. Text on the template page itself adds to the amount of text that must be processed when displaying the template, which is [[Wikipedia:Template limits|limited]] for performance reasons. Placing the documentation in a subpage avoids this (MediaWiki developers have &lt;span class=&quot;plainlinks&quot;&gt;[http://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(technical)&amp;diff=prev&amp;oldid=69888944 recommended]&lt;/span&gt; it for this reason).
 
 == How to create a documentation subpage ==
 Template documentation subpages should be named and formatted using the following general pattern, for consistency.
 
 Suppose your template is named &lt;code&gt;Template:X&lt;/code&gt;. Create a subpage with the name &lt;code&gt;Template:X/doc&lt;/code&gt;. See the details at {{tl|Documentation subpage}} or start the page by copy-pasting the following standard wikitext:
 &lt;!---------------------------------------------------------------------------------------
   Note: The following code block is copy-pasted from [[Template:Documentation/preload]];
     check it periodically for updates and copy it here again if necessary, amending its
     &quot;&lt;include&lt;includeonly&gt;&lt;/includeonly&gt;only&gt;&quot; accordingly.
  ----------------------------------------------------------------------------------------&gt;
 &lt;pre style=&quot;overflow:auto;&quot;&gt;
 {{Documentation subpage}}
 &lt;!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --&gt;
 == Usage ==
 
 
 &lt;includeonly&gt;{{#ifeq:{{SUBPAGENAME}}|sandbox | |
 &lt;!-- Categories below this line, please; interwikis at Wikidata --&gt;
 
 }}&lt;/includeonly&gt;
 &lt;/pre&gt;
 
 The top line will display a message explaining the current page and a link to the template page.
 
 Insert the documentation after the top line and categories under the appropriate comment line&amp;nbsp;– leaving the comment in place, so that the layout is preserved when the page is edited in future. Related templates, policy page, projects, etc. can be linked to by adding a &quot;See also&quot; section.
 
 Save the subpage and return to the template itself, &lt;code&gt;Template:X&lt;/code&gt;, in this example. Edit the template and append the following at the end of the template code:
 
  {{Colors|black|#CCC|{{var|[--last line of your template code--]}}}}&lt;nowiki&gt;&amp;lt;noinclude&gt;
 {{Documentation}}
 &lt;!--Please add this template's categories to the /doc subpage, not here - thanks!--&gt;
 &amp;lt;/noinclude&gt;&lt;/nowiki&gt;
 
 This will transclude {{tl|documentation}} at the bottom of the template page.
 
 '''Important''': Make sure the opening {{tag|noinclude|o}} begins immediately after the last character of the template code or text and ''not'' on a new line, nor with any intervening spaces. Otherwise, extra space will be inserted below the template when it is used, which is usually not wanted.
 
 If the template is already protected, ask an [[Wikipedia:Administrators|administrator]] to do this or request an edit by using an {{tl2|edit protected}} on the template's talk page. If documentation and categories already exist in a section, enclosed within a {{tag|noinclude}} container, move them into the documentation subpage (where they should be enclosed in {{tag|includeonly}}), as it is best not to have documentation split across two separate pages.
 
 If the code is put on the template page first, one can benefit from the [[mw:Extension:InputBox#Parameters|preload]] feature to get a pre-filled doc page skeleton; if the documentation page does not exist yet, clicking the edit link on the template page will preload the contents of [[Template:Documentation/preload]] into the editbox of the /doc subpage creation.
 
 You may wish to redirect the talk page of the /doc subpage to the talk page of the template itself. Then all talk relating to the template and its documentation will end up on the same talkpage. For example, redirect &lt;code&gt;Template talk:X/doc&lt;/code&gt; to &lt;code&gt;Template talk:X&lt;/code&gt;.
 
 == Categories and interwiki links ==
 * '''To place the template itself into a category''', add the &lt;code&gt;&lt;nowiki&gt;[[Category:Category name]]&lt;/nowiki&gt;&lt;/code&gt; code inside an {{tag|includeonly}} section on the ''doc'' subpage.
 * '''To create an interwiki link for the template itself''', go to [[Wikipedia:Wikidata|Wikidata]] and follow the instructions for adding links to pages.
 * '''To place the ''doc'' subpage into a category''', add the &lt;code&gt;&lt;nowiki&gt;[[Category:Category name]]&lt;/nowiki&gt;&lt;/code&gt; code inside a {{tag|noinclude}} section on the ''doc'' subpage.
 * '''To make the template place an article into a category''' (when the article includes the template), add the &lt;code&gt;&lt;nowiki&gt;[[Category:Category name]]&lt;/nowiki&gt;&lt;/code&gt; code inside an {{tag|includeonly}} section on the template page. Exact placement within the template code may affect how the category code is executed.
 &lt;!-- --&gt;
 &lt;!-- ==Example==
 See the heavily-used [[Template:cite web]] for an example of detailed template documentation. Note that the template itself is protected, but the documentation subpage, [[Template:cite web/doc]] is unprotected and can still be edited.
  --&gt;&lt;!-- The preceding section appears out dated at this time. I left it here so as to hold a place for an updated example. Template:cite web now uses lua. Lua is a programming language now available via the Scribunto MediaWiki extension. --&gt;
 
 == /sandbox and /testcases ==
 Before doing changes to a template it can be good to first copy the template code to a sandbox and run some testcases, since the template might be visible on thousands of pages. If you create subpages named exactly &quot;'''/sandbox'''&quot; and &quot;'''/testcases'''&quot; to a template then the green {{tlc|documentation}} box on the template auto-detects this and will show links to those pages in its header.  See [[Wikipedia:Template sandbox and test cases]] for more information.
 
 == Several templates, one documentation page ==