Template:Documentation/doc: Difference between revisions

Template page
(Created page with "'''Template:Documentation''' is used to add instructions on how to use a template, including an explanation of its syntax and parameters, recommended usage, and example code. When added to a page, it will transclude a subpage, found at <code>Template:YOURTEMPLATE/doc</code> (which initially will be a red link) – write your documentation on that subpage. ==Usage== Place the following at the bottom of a template: <pre><noinclude>{{Documentation}}</noinclude></pre> Thi...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
'''Template:Documentation''' is used to add instructions on how to use a template, including an explanation of its syntax and parameters, recommended usage, and example code. When added to a page, it will transclude a subpage, found at <code>Template:YOURTEMPLATE/doc</code> (which initially will be a red link) – write your documentation on that subpage.
'''Template:Documentation''' is used to add instructions on how to use a template, including an explanation of its syntax and parameters, recommended usage, and example code. When added to a page, it will transclude a subpage found at <code>Template:YOURTEMPLATE/doc</code> (which initially will be a red link) – write your documentation on that subpage.


==Usage==
==Usage==
Place the following at the bottom of a template:
<pre><noinclude>{{Documentation|<optional page name>}}</noinclude></pre>


<pre><noinclude>{{Documentation}}</noinclude></pre>
By default, this template retrieves documentation at <code>Template:YOURTEMPLATE/doc</code>. The unnamed first parameter is optional and can be used to point to documentation on a different page.


This '''must''' come directly after the last character in your template (do not place it on a new line).
Template:Documentation '''must''' come directly after the last character in your template do not place it on a new line.


==Example==
==Example==
If you have a template to create bold text that looks like this:
If you have a template to create bold text, add the documentation template like this:


<pre>'''{{{1}}}'''</pre>
<pre>'''{{{1}}}'''<noinclude>{{Documentation}}</noinclude></pre>


Add the documentation template like this:
If your template is named ''Template:Bold'', and you want to reuse documentation from ''Template:Italics'', fill in the first parameter like this:


<pre>'''{{{1}}}'''<noinclude>{{Documentation}}</noinclude></pre>
<pre>'''{{{1}}}'''<noinclude>{{Documentation|Template:Italics/doc}}</noinclude></pre>

Latest revision as of 19:31, 26 October 2025

Template:Documentation is used to add instructions on how to use a template, including an explanation of its syntax and parameters, recommended usage, and example code. When added to a page, it will transclude a subpage found at Template:YOURTEMPLATE/doc (which initially will be a red link) – write your documentation on that subpage.

Usage

<noinclude>{{Documentation|<optional page name>}}</noinclude>

By default, this template retrieves documentation at Template:YOURTEMPLATE/doc. The unnamed first parameter is optional and can be used to point to documentation on a different page.

Template:Documentation must come directly after the last character in your template – do not place it on a new line.

Example

If you have a template to create bold text, add the documentation template like this:

'''{{{1}}}'''<noinclude>{{Documentation}}</noinclude>

If your template is named Template:Bold, and you want to reuse documentation from Template:Italics, fill in the first parameter like this:

'''{{{1}}}'''<noinclude>{{Documentation|Template:Italics/doc}}</noinclude>