Jump to content

Template:Documentation: Difference between revisions

From We Are Calloway
m 1 revision imported
m remove sandbox and testcases for templates
 
(5 intermediate revisions by the same user not shown)
Line 69: Line 69:
}}<!--
}}<!--


-->{{#vardefine: doc image |
--><!--
  {{#ifeq: {{{heading|a}}} | <!-- null -->
  | <!-- heading is specified but empty, don't show image -->
  | [[File:{{#if: {{{content|}}}
    | Documentation_icon
    | {{#ifexist: {{#var: doc page}}
      | Documentation_icon
      | No Documentation_icon
      }}
    }}.svg|70px|link=|alt=|class=nomobile]]&nbsp;
  }}
}}<!--
-
-
- Sandbox header
- Sandbox header
Line 122: Line 111:
| {{#ifexist: {{#var: doc page}}
| {{#ifexist: {{#var: doc page}}
   | {{<!---->{{#var:doc page}}}}
   | {{<!---->{{#var:doc page}}}}
   | The [[w:Help:Template documentation|documentation]] for this {{#var: page text}} does not exist. Create it at [{{fullurl:{{FULLPAGENAMEE:{{#var: doc page}}}}|action=edit&preload={{#var: preload}} }} {{#var: doc page}}].
   | The documentation for this {{#var: page text}} does not exist. Create it at [{{fullurl:{{FULLPAGENAMEE:{{#var: doc page}}}}|action=edit&preload={{#var: preload}} }} {{#var: doc page}}].
   }}
   }}
}}<!--
}}<!--
Line 143: Line 132:
       | This is the sandbox subpage of [[{{#var: base page}}]];
       | This is the sandbox subpage of [[{{#var: base page}}]];
       | The above
       | The above
       }}&nbsp;[[w:Help:Template documentation|documentation]] is [[mw:Help:Transclusion|transcluded]] from [[{{#var: doc page}}]]. <small>([[Special:EditPage/{{#var: doc page}}|edit]] &#124; [[Special:PageHistory/{{#var: doc page}}|history]])</small><br/>
       }}&nbsp;documentation is [[mw:Help:Transclusion|transcluded]] from [[{{#var: doc page}}]]. <small>([[Special:EditPage/{{#var: doc page}}|edit]] &#124; [[Special:PageHistory/{{#var: doc page}}|history]])</small><br/>
    
    
     | {{#ifeq: {{#var: namespace}} | {{ns:Module}}
     | {{#ifeq: {{#var: namespace}} | {{ns:Module}}
Line 151: Line 140:
     }}
     }}
   }}<!--
   }}<!--
  -
  - Sandbox and testcases.
  -
  - NOTE: THIS WILL CREATE MANY (yes, MANY) REDLINKS (IF YOU DIDN'T MAKE THE /sandbox or /testcases PAGES). IF YOU DONT WANT THE LINKS, PLEASE REPLACE THE CODE BELOW WITH:
  <
    Editors can experiment in the page's [{{fullurl: {{#var: sandbox}}}} sandbox] and [{{fullurl: {{#var: testcases}}}} testcases] pages.
  >
  -
  --><!--
--><!-- CHANGE START --><!--
-->Editors can experiment in this {{#var: page text}}'s <!--
  -
-->{{#ifexist: {{#var: sandbox}}
  | [[{{#var: sandbox}}|sandbox]] <!--
  --><small>(<!--
    -->[[Special:EditPage/{{#var: sandbox}}|edit]] &#124; <!--
    -->[{{fullurl: Special:ComparePages
        | page1={{FULLPAGENAMEE:{{#var: base page}}}}&page2={{FULLPAGENAMEE:{{#var: current page}}}}
        }} diff]<!--
  -->)</small>
     
  | sandbox <small>(<!--
  -->[{{fullurl: {{FULLPAGENAMEE:{{#var: sandbox}}}}
    | action=edit&preload={{#var: preload-sandbox}}
    }} create] &#124; [{{fullurl: {{FULLPAGENAMEE:{{#var: sandbox}}}}
    | action=edit&preload={{FULLPAGENAMEE:{{#var: base page}}}}
    }} mirror]<!--
  -->)</small>
 
  }}<!--
 
  --> and <!--
 
  -->{{#ifexist: {{#var:testcases}}
    | [[{{#var:testcases}}|testcases]] <small>([[Special:EditPage/{{#var: testcases}}|edit]])</small>
   
    | testcases <small>(<!--
    -->[{{fullurl: {{FULLPAGENAMEE:{{#var: testcases}}}}
        | action=edit&preload={{#var: preload-testcases}}
        }} create]<!--
    -->)</small>
    }}<!--
  --> pages.<br/><!--
  --><!-- CHANGE END --><!--
   -
   -
   - Category addition text & subpages text.
   - Category addition text & subpages text.
Line 201: Line 146:
       | <!-- Do NOT show cat text *if* documentation is inline or transcluded from a different page. -->
       | <!-- Do NOT show cat text *if* documentation is inline or transcluded from a different page. -->
       | {{#ifexist: {{#var: doc page}}
       | {{#ifexist: {{#var: doc page}}
         | Add [[w:Help:categories|categories]] and [[w:Help:interwiki links|interwikis]] to the [[{{#var: doc page}}|/doc]] subpage.&nbsp;
         | Add categories   to the [[{{#var: doc page}}|/doc]] subpage.&nbsp;
         }}
         }}
       }}<!--
       }}<!--

Latest revision as of 00:13, 22 November 2025

Template Documentation[view | edit | history | purge]

Description

Note: This template requires the variables extension.

This template is used to insert template information, its parameters, and other information on a template page. More information may be found at Help:Template documentation on Fandom's Community Central.

Syntax

Add <noinclude>{{Documentation}}</noinclude> at the end of the template page.

Add <noinclude>{{Documentation|<documentation page>}}</noinclude> to transclude an alternative page from the /doc subpage.

To add documentation inline, meaning on the main template page itself, add <noinclude>{{Documentation|content=custom inline content}}</noinclude>

For full syntax, see #Advanced syntax.

Basic usage

On the Template page

This is the normal format when used:

TEMPLATE CODE
<includeonly>Any categories to be inserted into articles by the template</includeonly>
<noinclude>{{Documentation}}</noinclude>

Some notes:

  • If your template is not a completed div or table, you may need to close the tags just before {{Documentation}} is inserted (within the noinclude tags).
  • A line break right before {{Documentation}} can also be useful as it helps prevent the documentation template "running into" previous code.
  • If for some reason you need to transclude a different page other than the documentation page (e.g. when using a group of templates with same documentation), you can use the |1= parameter (see Syntax).
  • If the template documentation is rather short, you can specify documentation inline with the text, by using the |content= parameter (see Syntax again).

On the documentation page

The documentation page is usually located on the /doc subpage for a template, but a different page can be specified with the first parameter of the template (see Syntax).

Normally, you will want to write something like the following on the documentation page:

== Description ==
This template is used to do something.

== Syntax ==
Type <code>{{t|templatename|param1}}</code> somewhere.

=== Parameters ===
;<code>param1</code>
: This parameter is used to add something.

=== TemplateData ===
<templatedata>{}</templatedata>

== Examples ==
<code><nowiki>{{templatename|input}}</nowiki></code> 

results in...

{{templatename|input}}

<includeonly>Any categories for the template itself</includeonly>
<noinclude>[[Category:Template documentation]]</noinclude>

Use any or all of the above description/syntax/sample output sections. You may also want to add "see also" or other sections.

Advanced syntax

This template is used to insert a description of a template.

Template parameters[Edit template data]

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Custom page to transclude1

A custom page to transclude, usually another documentation page

Page nameoptional
Custom contentcontent

Custom inline content to add in the template. When this is added, the template does not transclude 1= or the /doc subpage

Stringoptional
Demo pagepage

For testing purposes

Page nameoptional
Demo namespacedemospace

For testing purposes; changes the internal namespace of the template

Stringoptional
Custom documentation preloadpreload

Custom documentation preload that will be used for the [create] links for the /doc subpage

Page nameoptional
Custom preload page for /sandbox subpagepreload-sandbox

no description

Page nameoptional
Custom preload page for /testcases subpagepreload-testcases

no description

Page nameoptional
Custom /sandbox subpagesandbox

Page that is used for the /sandbox link

Page nameoptional
Custom /testcases pagetestcases

Page that is used for the /testcases link

Page nameoptional
Custom heading textheading

no description

Stringoptional
Disable footernofooter

Disables the footer or "link box" located below the documentation content.

Booleanoptional

Dependencies

Templates
Template:Documentation/preload
The above documentation is transcluded from Template:Documentation/doc. (edit | history)
Add categories to the /doc subpage. Subpages of this template.