Difference between revisions of "Template:Lx/doc"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "{{short description|Wikimedia page about template documentation}} {{Wikipedia how to|WP:TDOC|WP:DOC}} {{Wikipedia|Help:Template|Templates}} are a very powerful feature of [{{...")
 
(Fixed half a trillion links to Wikipedia and sprinkled some notes and notices around the page)
Line 1: Line 1:
{{short description|Wikimedia page about template documentation}}
{{short description|Wikimedia page about template documentation}}
{{Wikipedia how to|WP:TDOC|WP:DOC}}


{{Wikipedia|Help:Template|Templates}} are a very powerful feature of [{{Wikipedia|4444ediaWiki]], 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.
{{see also|{{Wikipedia|WP:TDOC}}|{{Wikipedia|WP:DOC}}}}
 
{{notice|Some of the information below does not always apply to this SL Wiki. Nevertheless, it's kept here for the sole purpose of giving some guidelines and some links to Wikipedia where more information on this subject can be found.}}
 
{{Cleanup|reason=There are some missing links to Wikipedia, as well as some templates that have to be copied and adapted specifically for this SL Wiki}}
 
{{Wikipedia|Help:Template|Templates}} are a very powerful feature of {{Wikipedia|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—which includes many experienced contributors who focus their attention elsewhere—can use it correctly. This is especially true in the case of very widely used templates.
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—which includes many experienced contributors who focus their attention elsewhere—can use it correctly. This is especially true in the case of very widely used templates.


Editors should defer to official [[WP:POLICIES |policies or guidelines]] when template documentation pages are inconsistent with established community standards and principles. Editors should also avoid "quoting" template  documentation pages as though they are policy—including this [[WP:INFOPAGES|how-to guide]]. Template documentation pages can be written without much—if any—debate, as opposed to Wikipedia policies that have been [[WP:PROPOSAL|thoroughly vetted by the community]] (see [[WP:Local consensus]] for details).
Editors should defer to official {{Wikipedia|WP:POLICIES|policies or guidelines}} when template documentation pages are inconsistent with established community standards and principles. Editors should also avoid "quoting" template  documentation pages as though they are policy—including this {{Wikipedia|WP:INFOPAGES|how-to guide}}. Template documentation pages can be written without much—if any—debate, as opposed to Wikipedia policies that have been {{Wikipedia|WP:PROPOSAL|thoroughly vetted by the community}} (see {{Wikipedia|WP:Local consensus}} for details).


== What to include ==
== What to include ==
Template documentation should cover:
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.  Include important '''limitations''', such as the lack of {{tl|Navbox visibility}} on the Mobile web site, if a template should only be used for certain countries or time periods, or other things that editors need to know before choosing to use the template.  
* 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.  Include important '''limitations''', such as the lack of {{tl|Navbox visibility}} on the Mobile web site, if a template should only be used for certain countries or time periods, or other things that editors need to know before choosing to use the template.  
* 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 "yes", "no", or a number, this should be clearly explained.
* The '''{{WikipediaHelp: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 "yes", "no", 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 <code>easy to copy, like this</code>. If the template can be used in several 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 {{tl|Xpd}} this can be done without putting the template call twice in the wikitext.
* '''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 <code>easy to copy, like this</code>. If the template can be used in several 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 {{tl|Xpd}} this can be done without putting the template call twice in the wikitext.
* '''TemplateData''' tags: See [[Wikipedia:TemplateData/Tutorial]].
* '''TemplateData''' tags: See {{Wikipedia|Wikipedia:TemplateData/Tutorial}} ''(note: not supported on this SL Wiki)''.
* '''Related templates''': if the template is one of a series of templates, include links to these&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, e.g., {{tl|Protection templates}}).
* '''Related templates''': if the template is one of a series of templates, include links to these&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, e.g., {{tl|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 within {{tag|includeonly|p|content={{((}}Sandbox other{{!!}}...{{))}}}} tags if placed on a documentation page. Many template categories are available, see: [[:Category:Wikipedia templates]] to browse through them.
* '''{{Wikipedia|Wikipedia:Categorization|Categories}}''' where applicable ({{Wikipedia|Help:Interwikimedia links|InterWikimedia links}} should be listed at {{Wikipedia|d:|Wikidata}} – more information at {{Wikipedia|Wikipedia:Wikidata}}).  Like the documentation, categories must be listed within a {{tag|noinclude}} container on a template, or within {{tag|includeonly|p|content={{((}}Sandbox other{{!!}}...{{))}}}} tags if placed on a documentation page. Many template categories are available, see: {{Wikipedia|:Category:Wikipedia templates}} to browse through them.


The English Wikipedia is a source of templates for hundreds of other Wikipedias and sister projects.  Often, templates are fully self-contained, so the process easy:  the contents are simply copied to a new template page at the other wiki, and everything works.  However, on more complex templates, the template may invoke a module, transclude other templates, only work if paired with a separate template, or need particular CSS or JavaScript code to work.  In these cases, it is helpful to include a brief list of templates or other code that this one requires, at the end of the documentation.
The English Wikipedia is a source of templates for hundreds of other Wikipedias and sister projects.  Often, templates are fully self-contained, so the process easy:  the contents are simply copied to a new template page at the other wiki, and everything works.  However, on more complex templates, the template may invoke a module, transclude other templates, only work if paired with a separate template, or need particular CSS or JavaScript code to work.  In these cases, it is helpful to include a brief list of templates or other code that this one requires, at the end of the documentation.


== Where to place it ==
== Where to place it ==
When viewing the rendered template page itself (as opposed to its wikicode), what is usually visible right under the title is the rendered template itself, followed by a separate section to display the template's rendered documentation, followed by the categories to which the template belongs. Categories and documentation of any sort on a template page (including [[Wikipedia:TemplateData|TemplateData]]) should always be enclosed by [[WP:PARTRANS|noinclude tags]], so that they do not show up when the template is used on another page.
When viewing the rendered template page itself (as opposed to its wikicode), what is usually visible right under the title is the rendered template itself, followed by a separate section to display the template's rendered documentation, followed by the categories to which the template belongs. Categories and documentation of any sort on a template page (including {{Wikipedia|Wikipedia:TemplateData|TemplateData}}) should always be enclosed by {{Wikipedia|WP:PARTRANS|noinclude tags}}, so that they do not show up when the template is used on another page.


The editable [[Wikipedia:Wikicode|wikicode]] for the template's documentation is often placed on a separate [[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 and reducing the number of accidental editing errors in the template code. It also allows templates to be [[Wikipedia:Protection policy|protected]] where necessary, limiting editing access to important templates' code while allowing anyone to edit those templates' documentation. This method is sometimes referred to as the "template-doc page pattern".
The editable {{Wikipedia|Wikipedia:Wikicode|wikicode}} for the template's documentation is often placed on a separate {{Wikipedia|Wikipedia:Subpages|subpage}} of the template itself, which is then {{Wikipedia|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 and reducing the number of accidental editing errors in the template code. It also allows templates to be {{Wikipedia|Wikipedia:Protection policy|protected}} where necessary, limiting editing access to important templates' code while allowing anyone to edit those templates' documentation. This method is sometimes referred to as the "template-doc page pattern".


== How to create a documentation subpage ==
== How to create a documentation subpage ==
Line 41: Line 46:
'''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.
'''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 template is already protected, ask an {{Wikipedia|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.


=== Automatic creation ===
=== Automatic creation ===


Use <code><nowiki>[create]</nowiki></code> link at the bottom of the empty documentation box to automatically create a [[Wikipedia:Preload|preloaded]] documentation subpage. Insert the documentation after the top line and categories under the appropriate comment line&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 "See also" section. Save the subpage.
Use <code><nowiki>[create]</nowiki></code> link at the bottom of the empty documentation box to automatically create a {{Wikipedia|Wikipedia:Preload|preloaded}} documentation subpage. Insert the documentation after the top line and categories under the appropriate comment line&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 "See also" section. Save the subpage.


=== Manual creation ===
=== Manual creation ===
Line 66: Line 71:
</syntaxhighlight>
</syntaxhighlight>


The top line will display a message explaining the current page and a link to the template page. Save the subpage and follow instructions in section "[[#Use Template:Documentation|Use Template:Documentation]]".
The top line will display a message explaining the current page and a link to the template page. Save the subpage and follow instructions in section "{{Wikipedia|#Use Template:Documentation|Use Template:Documentation}}".


=== With TemplateData ===
=== With TemplateData ===
Instead of manually writing a lead graf and a usage table, the {{tl|Format TemplateData}} template can do most of the job. Simply write your TemplateData in the table interface, and then wrap it into a template call like <code><nowiki>{{Format TemplateData|1=<templatedata>...</templatedata>}}</nowiki></code> at the top of the page.
Instead of manually writing a lead graf and a usage table, the {{tl|Format TemplateData}} template can do most of the job. Simply write your TemplateData in the table interface, and then wrap it into a template call like <code><nowiki>{{Format TemplateData|1=<templatedata>...</templatedata>}}</nowiki></code> at the top of the page.
{{notice|TemplateData is currently not available on the SL Wiki. Replace with <nowiki><code><syntaxhighlight lang="json">...</syntaxhighlight></code> instead, if you wish.}}


=== Notes ===
=== Notes ===
Line 90: Line 97:
== Categories and interwiki links ==
== Categories and interwiki links ==
* '''To place the template itself into a category''', add the <code><nowiki>[[Category:Category name]]</nowiki></code> code inside an {{tag|includeonly}} section on the ''doc'' subpage.
* '''To place the template itself into a category''', add the <code><nowiki>[[Category:Category name]]</nowiki></code> 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 create an interwiki link for the template itself''', go to {{Wikipedia|Wikipedia:Wikidata|Wikidata}} and follow the instructions for adding links to pages.
* '''To place the ''doc'' subpage into a category''', add the <code><nowiki>[[Category:Category name]]</nowiki></code> code inside a {{tag|noinclude}} section on the ''doc'' subpage.
* '''To place the ''doc'' subpage into a category''', add the <code><nowiki>[[Category:Category name]]</nowiki></code> 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 <code><nowiki>[[Category:Category name]]</nowiki></code> code inside an {{tag|includeonly}} section on the template page. Exact placement within the template code may affect how the category code is executed.
* '''To make the template place an article into a category''' (when the article includes the template), add the <code><nowiki>[[Category:Category name]]</nowiki></code> code inside an {{tag|includeonly}} section on the template page. Exact placement within the template code may affect how the category code is executed.
<!-- -->
<!-- ==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.
--><!-- 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. -->


== /sandbox and /testcases ==
== /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 or even millions of pages. If you create subpages named exactly "'''/sandbox'''" and "'''/testcases'''" 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.
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 or even millions of pages. If you create subpages named exactly "'''/sandbox'''" and "'''/testcases'''" 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|Wikipedia:Template sandbox and test cases}} for more information.


== Several templates, one documentation page ==
== Several templates, one documentation page ==
Line 127: Line 130:
* HTML tags like {{tag|ref|params=group{{=}}"note"}} can be easily inserted with {{tl|tag}}. This example is written as {{tlp|tag|ref|params{{=}}group{{=}}"note"}}
* HTML tags like {{tag|ref|params=group{{=}}"note"}} can be easily inserted with {{tl|tag}}. This example is written as {{tlp|tag|ref|params{{=}}group{{=}}"note"}}
* Equals sign '''=''' can be inserted with {{tn|{{=}}}}. For example, {{tlp|Citation needed|date{{=}}1900-02-29}} is made by {{tlp|tlp|Citation needed|date{{<nowiki />=}}1900-02-29}}. Avoid the equivalent notation &amp;#61; which is not easy to read for other editors.
* Equals sign '''=''' can be inserted with {{tn|{{=}}}}. For example, {{tlp|Citation needed|date{{=}}1900-02-29}} is made by {{tlp|tlp|Citation needed|date{{<nowiki />=}}1900-02-29}}. Avoid the equivalent notation &amp;#61; which is not easy to read for other editors.
* Don't forget the single {{tag|nowiki|s}} tag. [[<nowiki />{{tag|nowiki|s}}example]] becomes [[<nowiki />example]], and [<nowiki />{{tag|nowiki|s}}http://en.wikipedia.org no link] is [<nowiki />http://en.wikipedia.org no link]. See [[WP:NOWIKI]] for the details.
* Don't forget the single {{tag|nowiki|s}} tag. [[<nowiki />{{tag|nowiki|s}}example]] becomes [[<nowiki />example]], and [<nowiki />{{tag|nowiki|s}}http://en.wikipedia.org no link] is [<nowiki />http://en.wikipedia.org no link]. See {{Wikipedia|WP:NOWIKI}} for the details.
* For a link to a category, use {{tl|cat}}. For example, {{tlp|cat|Templates with incorrect parameter syntax}} becomes {{cat|Templates with incorrect parameter syntax}}.
* For a link to a category, use {{tl|cat}}. For example, {{tlp|cat|Templates with incorrect parameter syntax}} becomes {{cat|Templates with incorrect parameter syntax}}.
* To suppress categorization of the /sandbox and /testcases pages of the template (if they exist), use this code at the bottom of the documentation subpage:
* To suppress categorization of the /sandbox and /testcases pages of the template (if they exist), use this code at the bottom of the documentation subpage:
Line 149: Line 152:
* {{tl|Documentation}} – Transcludes the documentation on the template page, and provides documentation view, edit and history links
* {{tl|Documentation}} – Transcludes the documentation on the template page, and provides documentation view, edit and history links
* {{tl|Documentation subpage}} – Explains that what follows is documentation, and links to the documented page
* {{tl|Documentation subpage}} – Explains that what follows is documentation, and links to the documented page
* [[m:Help:Template#Noinclude, includeonly, and onlyinclude|{{tag|noinclude|o}} and {{tag|includeonly|o}}]]
* {{Wikipedia|m:Help:Template#Noinclude, includeonly, and onlyinclude|{{tag|noinclude|o}} and {{tag|includeonly|o}}}}
* {{tl|Improve documentation}}
* {{tl|Improve documentation}}
* {{tl|Tag}} – global use
* {{tl|Tag}} – global use
* {{tl|Template reference list}}
* {{tl|Template reference list}}
* {{tl|WPBannerDoc}} – for WikiProject templates
* {{tl|WPBannerDoc}} – for WikiProject templates
* [[Wikipedia:High-risk templates]]
* {{Wikipedia|Wikipedia:High-risk templates}}
* [[Wikipedia:Template sandbox and test cases]]
* {{Wikipedia|Wikipedia:Template sandbox and test cases}}
* [[:Category:Documentation assistance templates]]
* [[:Category:Documentation assistance templates]]


{{Help navigation}}
<!--{{Help navigation}}
{{Wikipedia technical help|collapsed}}
{{Wikipedia technical help|collapsed}}-->
[[Category:Template documentation|*]]
[[Category:Template documentation|*]]
[[Category:Wikipedia template help]]
[[Category:Wikipedia template help]]

Revision as of 15:00, 20 June 2023



"Wikipedia logo"Templates are a very powerful feature of "Wikipedia logo"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—which includes many experienced contributors who focus their attention elsewhere—can use it correctly. This is especially true in the case of very widely used templates.

Editors should defer to official "Wikipedia logo"policies or guidelines when template documentation pages are inconsistent with established community standards and principles. Editors should also avoid "quoting" template documentation pages as though they are policy—including this "Wikipedia logo"how-to guide. Template documentation pages can be written without much—if any—debate, as opposed to Wikipedia policies that have been "Wikipedia logo"thoroughly vetted by the community (see "Wikipedia logo"WP:Local consensus for details).

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. Include important limitations, such as the lack of {{Navbox visibility}} on the Mobile web site, if a template should only be used for certain countries or time periods, or other things that editors need to know before choosing to use the template.
  • The Template:WikipediaHelp:Template 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 "yes", "no", 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 <code>...</code> container, to make it clear and easy to copy, like this. If the template can be used in several 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 {{Xpd}} this can be done without putting the template call twice in the wikitext.
  • TemplateData tags: See "Wikipedia logo"Wikipedia:TemplateData/Tutorial (note: not supported on this SL Wiki).
  • Related templates: if the template is one of a series of templates, include links to these – 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, e.g., {{Protection templates}}).
  • "Wikipedia logo"Categories where applicable ("Wikipedia logo"InterWikimedia links should be listed at "Wikipedia logo"Wikidata – more information at "Wikipedia logo"Wikipedia:Wikidata). Like the documentation, categories must be listed within a <noinclude>...</noinclude> container on a template, or within <includeonly>{{Sandbox other||...}}</includeonly> tags if placed on a documentation page. Many template categories are available, see: "Wikipedia logo" [https://en.wikipedia.org/wiki/
Category:Wikipedia_templates :Category:Wikipedia templates] to browse through them.

The English Wikipedia is a source of templates for hundreds of other Wikipedias and sister projects. Often, templates are fully self-contained, so the process easy: the contents are simply copied to a new template page at the other wiki, and everything works. However, on more complex templates, the template may invoke a module, transclude other templates, only work if paired with a separate template, or need particular CSS or JavaScript code to work. In these cases, it is helpful to include a brief list of templates or other code that this one requires, at the end of the documentation.

Where to place it

When viewing the rendered template page itself (as opposed to its wikicode), what is usually visible right under the title is the rendered template itself, followed by a separate section to display the template's rendered documentation, followed by the categories to which the template belongs. Categories and documentation of any sort on a template page (including "Wikipedia logo"TemplateData) should always be enclosed by "Wikipedia logo"noinclude tags, so that they do not show up when the template is used on another page.

The editable "Wikipedia logo"wikicode for the template's documentation is often placed on a separate "Wikipedia logo"subpage of the template itself, which is then "Wikipedia logo"transcluded at the end of the template page. This separates the often complex template code from the documentation, making the documentation easier to edit and reducing the number of accidental editing errors in the template code. It also allows templates to be "Wikipedia logo"protected where necessary, limiting editing access to important templates' code while allowing anyone to edit those templates' documentation. This method is sometimes referred to as the "template-doc page pattern".

How to create a documentation subpage

Put documentation in the template

You must put {{documentation}} when creating (publishing) a template. Then a documentation page is created with [view] [edit] [history] [purge] links. You can create and edit the template documentation clicking in this pane [edit] link.

Template documentation subpages using {{documentation}} are named and formatted using the following general pattern, for consistency.

Suppose your template is named Template:X. Edit the template and append the following at the end of the template code, or use {{subst:doc-code}}:

[--last line of your template code--]<noinclude>
{{Documentation}}
<!-- Add categories to the /doc subpage and interwikis in Wikidata, not here! -->
</noinclude>

This will transclude {{documentation}} at the bottom of the template page.

Important: Make sure the opening <noinclude> 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 logo"administrator to do this or request an edit by using an {{edit protected}} on the template's talk page. If documentation and categories already exist in a section, enclosed within a <noinclude>...</noinclude> container, move them into the documentation subpage (where they should be enclosed in <includeonly>...</includeonly>), as it is best not to have documentation split across two separate pages.

Automatic creation

Use [create] link at the bottom of the empty documentation box to automatically create a "Wikipedia logo"preloaded documentation subpage. Insert the documentation after the top line and categories under the appropriate comment line – 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 "See also" section. Save the subpage.

Manual creation

To create the documentation subpage manually, create a subpage with the name Template:X/doc. See the details at {{Documentation subpage}} or start the page by copy-pasting the following standard wikitext:

{{Documentation subpage}}
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->
== Usage ==


<includeonly>{{sandbox other||
<!-- Categories below this line; interwikis at Wikidata -->

}}</includeonly>

The top line will display a message explaining the current page and a link to the template page. Save the subpage and follow instructions in section ""Wikipedia logo"Use Template:Documentation".

With TemplateData

Instead of manually writing a lead graf and a usage table, the {{Format TemplateData}} template can do most of the job. Simply write your TemplateData in the table interface, and then wrap it into a template call like {{Format TemplateData|1=<templatedata>...</templatedata>}} at the top of the page.

{{notice|TemplateData is currently not available on the SL Wiki. Replace with <code><syntaxhighlight lang="json">...</syntaxhighlight></code> instead, if you wish.}} === Notes === 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 <code>Template talk:X/doc</code> to <code>Template talk:X</code>. A documentation page can also be redirected to the /doc subpage of another template, if that covers the usage for both templates. In this case, clicking the links to view or edit the documentation will directly open the target of the redirect. If it is necessary to access the redirect itself (e.g. to remove the redirect and create a separate doc page), go to the template URL by clicking in the location bar at the top of your browser, and add /doc at the end. == Blank == To generate a blank template, which may then be copied from the documentation and pasted into another page, use: :<code><nowiki>{{subst:#tag:pre|{{subst:Parameters|code|base={{subst:BASEPAGENAME}}}}|style=overflow: auto;}}

Examples

To generate an instance of the template, populated with its own property names, use:

{{subst:Parameters|demo|base={{subst:BASEPAGENAME}}|_base=}}

Categories and interwiki links

  • To place the template itself into a category, add the [[Category:Category name]] code inside an <includeonly>...</includeonly> section on the doc subpage.
  • To create an interwiki link for the template itself, go to "Wikipedia logo"Wikidata and follow the instructions for adding links to pages.
  • To place the doc subpage into a category, add the [[Category:Category name]] code inside a <noinclude>...</noinclude> section on the doc subpage.
  • To make the template place an article into a category (when the article includes the template), add the [[Category:Category name]] code inside an <includeonly>...</includeonly> section on the template page. Exact placement within the template code may affect how the category code is executed.

/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 or even millions of pages. If you create subpages named exactly "/sandbox" and "/testcases" to a template then the green {{documentation}} box on the template auto-detects this and will show links to those pages in its header. See "Wikipedia logo"Wikipedia:Template sandbox and test cases for more information.

Several templates, one documentation page

When several templates work together or are very similar then it is often clearer and easier to maintain one single documentation page that documents them together. The simplest way to do this is to make a full documentation page at one of the templates, and then make "soft redirects" from the other templates. See, for instance: {{wrap}}.

Directly on a template page

When a documentation subpage has not been created, and the {{documentation}} template is being used with a |content = parameter on the actual template page, then to place the template itself into a category, add [[Category:Category name]] inside the documentation template, after the content. For example, for placement on the actual template page:

<!--Last line of your template code--><noinclude>
{{Documentation
 | content =
<!-- template documentation -->

[[Category:Category name]]
[[Category:Category name2]]
}}</noinclude>

When no documentation is needed

When a template as displayed will link to a page that can serve as the documentation, then separate documentation is superfluous and does not need to be created. For instance, a stub template, using the {{asbox}} template as a base, will already display pre-loaded common documentation for all stub templates using that template, and will not need additional documentation.

Tips and tricks

Here are some tips to facilitate writing documentations:

  • Links to templates like {{Japanese year|1800}} can be inserted by writing {{tlp|Japanese year|1800}}. See {{tlp}} for similar templates.
  • HTML tags like <ref group="note">...</ref> can be easily inserted with {{tag}}. This example is written as {{tag|ref|params=group="note"}}
  • Equals sign = can be inserted with {{=}}

. For example, {{Citation needed|date=1900-02-29}} is made by {{tlp|Citation needed|date{{=}}1900-02-29}}. Avoid the equivalent notation &#61; which is not easy to read for other editors.

<includeonly>{{sandbox other||{{testcases other||
<!-- Categories below this line, please; interwikis at Wikidata -->

}}}}</includeonly>
  • When the template is a child infobox, documentation appears broken. Prevent this by adding the <includeonly> tag:
{{Some infobox (child) template
|  child = <includeonly>yes</includeonly>
| label1 = Hello
|  data1 = World
}}<noinclude>{{documentation}}</noinclude>

See also