Template:Documentation/doc: Difference between revisions

→‎top: Add short description
m (1 revision imported)
(→‎top: Add short description)
Line 1: Line 1:
This is the {{tl|documentation}} template.
{{Short description|Displays documentation from a subpage}}
<noinclude>{{pp-semi-indef}}
</noinclude>{{Documentation subpage}}
{{Distinguish|Template:Documentation subpage}}
{{High-use}}
{{Never substitute}}
{{template shortcut|doc}}
{{Lua|Module:Documentation}}


For most of the instructions about how and when to use this template, see [[Wikipedia:Template documentation]].
The {{tlx|documentation}} template is used to contain the [[WP:TDOC|documented information and instructions]] of a certain template, usually from a /doc subpage. It can also be configured to load the content from other pages or be directly fed by text.


This template displays a green doc box like you are seeing now, and automatically loads the content from a /doc subpage. It can also load the content from other places if instructed to.
For detailed instructions on how and when to use this template, see [[Wikipedia:Template documentation]] (shortcut: [[WP:TDOC]]).


This template is intended for documenting templates and other pages which are [[Wikipedia:Transclusion|transcluded]] onto other pages. It can be used in template space and most other [[Wikipedia:Namespace|namespaces]].
This template has two parts: the big "documentation box" with the documentation inside alongside a toolbar (the <code>[view][edit][history][purge]</code> links), and the smaller "link box" that shows metadata about the documentation alongside the [[Wikipedia:Template sandbox and test cases|sandbox and testcases]] links.


Use of this template allows templates to be [[Wikipedia:Protection policy|protected]] where necessary, while allowing anyone to edit the documentation, categories, and interwiki links.
Use of this template allows templates to be [[Wikipedia:Protection policy|protected]], where necessary, while allowing anyone to edit the documentation and categories.


=== Usage ===
== General syntax ==
Normally, the template is used without parameters and is placed inside {{tag|noinclude}} at the bottom of the template page (see {{section link|#Placement and tags}} for more information):


Normally this template is used without any parameters, placed at the bottom of the template or page being documented, within <code>&lt;noinclude></code>:
<syntaxhighlight lang="wikitext">
 
<pre>
<!--Last line of your template code--><noinclude>
<!--Last line of your template code--><noinclude>
 
{{Documentation}}
{{documentation}}
<!-- Add categories to the /doc subpage -->
<!-- Add categories and interwikis to the /doc subpage, not here! -->
</noinclude>
</noinclude>
</pre>
</syntaxhighlight>


Then this template automatically loads the content from the /doc subpage of the template it is used on.
=== Transcluding a different page ===
To transclude a different page other than the /doc subpage, simply provide {{para|1}} like this:


This template can also load the content from any other page. Like this:
<syntaxhighlight lang="wikitext">
 
<pre>
<!--Last line of your template code--><noinclude>
<!--Last line of your template code--><noinclude>
 
{{Documentation|Template:Other page/doc}}
{{documentation|Template:Other page/doc}}
</noinclude>
</noinclude>
</pre>
</syntaxhighlight>


Note that when loading the documentation from another page than the local /doc page it becomes tricky to handle the categories and interwiki links.
Note that when loading the documentation from a page other than the local /doc subpage, it becomes tricky to handle the categories.


The content can also be fed directly as text. Like this:
=== Using the {{para|content}} parameter ===
The documentation can also be fed directly as text, by using the {{para|content}} parameter:


<pre>
<syntaxhighlight lang="wikitext">
<!--Last line of your template code--><noinclude>
<!--Last line of your template code--><noinclude>
{{Documentation
| content =
<!-- template documentation -->
}}</noinclude>
</syntaxhighlight>


{{documentation
When using this parameter, the toolbar will not show. Note that the /doc subpage in the link box will still show up if it exists.
| content = Some documentation text.
}}
</noinclude>
</pre>
 
When the '''content''' parameter is used the doc box normally doesn't show the [edit] [purge] links in the top right corner. Note that if the /doc page exists a link to it is still shown in the link box below the doc box. <!--and no link to a /doc page is shown in the link box below the doc box.-->
 
But parameter 1 and the '''content''' parameter can also be combined, like this:
 
<pre>
<!--Last line of your template code--><noinclude>


{{documentation
Also note that when {{para|1}} and {{para|content}} is specified, {{para|content}} takes precedence and always shows in the documentation box.
| 1 = Template:Any page/doc
| content = {{Template:Any page/doc|parameters}}
}}
</noinclude>
</pre>


Then the pagename fed as parameter 1 is used for the [edit] [purge] links and for the /doc link in the link box below the doc box. But the '''content''' parameter is used for the content shown in the doc box. The above code means that the content is transcluded as "<code><nowiki>{{Template:Any page/doc|parameters}}</nowiki></code>". In this example a parameter is also fed to the /doc page being loaded.
== Advanced syntax ==
=== Customizing the heading ===
The heading in the documentation box changes depending on namespace. See the below list for the default text in each namespace:


=== Best practice ===
* Template namespace: [[File:Test Template Info-Icon - Version (2).svg|32px|link=[[Wikipedia:Template documentation]]]] '''Template documentation'''
* Module namespace: [[File:Test Template Info-Icon - Version (2).svg|32px|link=[[Wikipedia:Template documentation]]]] '''Module documentation'''
* Other namespaces: '''Documentation'''


The code should be added at the bottom of the template code, with no space before "<code>&lt;noinclude></code>" (which would cause extra space on pages where the template is used).
To customize the heading, simply set the parameter {{para|heading}} to anything you like, for example {{para|heading|Infobox documentation}}.


Categories and interwiki links that apply to the template itself should be added to the bottom of the /doc subpage, inside <code>&lt;includeonly>&lt;/includeonly></code> tags. For more complex cases, see [[Wikipedia:Template documentation#Categories and interwiki links]].
Note that if the heading parameter is empty but defined (like {{para|heading|}}) the heading alongside the toolbar will not show.


If the documentation page contains &lt;includeonly> or &lt;noinclude> tags as part of the visible documentation text, replace the "<code>&lt;</code>" with "<code>&amp;lt;</code>".
The {{para|heading-style}} parameter can be fed optional [[Cascading Style Sheets|CSS]] values, like {{para|heading-style|font-size:150%;color:red;}}. Not that you should omit quotation marks <code>" "</code> and add the ending semicolon <code>;</code>.  


=== The heading ===
=== Customizing the link box ===
To customize the link box, set {{para|link box}} to something else, like {{para|link box|The above documentation is automatically generated from [[Template:Foo]]}}.


When in Template space this template shows this heading:
To hide the link box, simply set {{para|link box}} to <code>off</code>.
:[[File:Template-info.svg|32px]] '''Template documentation'''


In most other namespaces, such as "Wikipedia:", it shows this heading:
=== Testing ===
:'''Documentation'''
You can simulate the output for a given page by using the {{para|page}} parameter. For example, if you use the code {{para|page|Template:Edit protected}}, the template will behave exactly as if it were on the page [[Template:Edit protected]], including showing the documentation from [[Template:Edit protected/doc]], linking to [[Template:Edit protected/sandbox]], etc. This parameter is useful for testing and is used extensively on the [[Module:Documentation/testcases|module testcases page]].


But when on File (image) pages it shows this heading:
== Placement and tags ==
:'''Summary'''
{{Further information|Wikipedia:Template documentation#Where to place it}}
This code should be added at the bottom of the template code page, with no space before {{Tag|noinclude|o}} (which causes extra whitespace to show on pages where the template is transcluded):


The '''heading''' parameter can be used to set the heading to something else. Like this:
<syntaxhighlight lang="wikitext"><!--Last line of your template code--><noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage -->
</noinclude></syntaxhighlight>


:<code><nowiki>{{documentation| heading = Infobox documentation }}</nowiki></code>
To automatically insert the above text, you can also use the [[Wikipedia:Substitution|substitution]] code shortcut {{tlxs|doc-code}}.


If the '''heading''' parameter is empty but defined, no heading is shown and no [edit] [purge] links are shown. Like this:
=== Categories and interwikis ===
Depending on where to the documentation is placed, it may be tricky to handle the categories and interwikis. See {{section link|Wikipedia:Template documentation#Categories and interwiki links}} for information about adding these.


:<code><nowiki>{{documentation| heading = }}</nowiki></code>
== Technical details ==
=== Automatic functions ===
If the documentation page does not exist, the toolbar is replaced with a <code>[create][purge]</code> link. The <code>[create]</code> link automatically [[mw:Manual:Creating pages with preloaded text|creates the page with preloaded text]] with the basic documentation syntax. Preload text is also used for the /sandbox and /testcases [create] links.


The '''heading-style''' parameter can be fed optional [[Cascading Style Sheets|CSS]] values. Without quotation marks <code>" "</code> but with the ending semicolons <code>;</code>. For example:
The preload page for the /doc <code>[create]</code> link is [[Template:Documentation/preload]]. The preload pages for the /sandbox and /testcases links are [[Template:Documentation/preload-sandbox]] and [[Template:Documentation/preload-testcases]]. The preload page for the /sandbox <code>[mirror]</code> link is [[Template:Documentation/mirror]].
:<code>heading-style = color: red; font-size: 150%;</code>


=== The link box ===
This template also automatically adds {{tl|pp-template}} to a protected template page. When this template is on a /sandbox subpage, it also adds the {{tl|Template sandbox notice}} template.


Below the big doc box is a small link box that shows some meta-data about the documentation. The link box shows different things depending on what parameters are fed to this template, and in which namespace it is used. In some cases the link box is not shown at all.
=== Link box features ===
Depending on the namespace, the link box may have less features, or may not show up at all. The following table shows this:


To hide the link box, add the parameter "{{para|link box|off}}".
{| class="wikitable"
! Namespace
! Behavior
|-
| Template
| Full behavior
|-
| Module
| Full behavior, with the addition of a "create documentation" link when the page does not exist
|-
| User
| Full behavior
|-
| Other namespaces
| Hidden, unless {{para|1}} is specified (which will show "The above documentation is transcluded from {{param|1}}")
|}


You can also insert customised text in the link box, by defining the {{para|link box}} parameter. For example:
Alongside that, if {{para|1}} or {{para|content}} is specified, the "Add categories to the /doc subpage" text will not show.
<pre>|link box=This documentation is automatically generated by [[Template:Country showdata]]</pre>


=== Automatic functions ===
=== Subject namespaces vs. talk namespaces ===
This template is usually placed in the [[WP:NS#Subject namespaces|subject namespace]]. But in some cases this template needs to be on the [[WP:TALKSPACE|Talk namespace]]:


If the documentation page doesn't exist, the [create] link includes a [[mw:Manual:Creating pages with preloaded text|preload]] page so that clicking it will pre-fill the edit form with the basic documentation page format. Preload text is also used for the /sandbox and /testcases <small>(create)</small> links.
* In the MediaWiki namespace, since {{tag|noinclude|o}} often does not work in system messages, and since the MediaWiki namespace needs to be kept clean for performance reasons.


When this template is on a /sandbox subpage it automatically adds the {{tl|template sandbox notice}}.
When placed on talk pages, this template usually is placed near the top of the page and without {{tag|noinclude}} tags.


=== Subject space vs talk space ===
The /doc, /sandbox and /testcases pages should normally be in the subject namespace, except in the namespaces that do not have the MediaWiki [[meta:Help:Link#Subpage feature|subpage feature]] enabled: Main, File, and MediaWiki. (Categories can have subpages, but documentation is created in the Category talk namespace to prevent creating empty categories. There are also a whole bunch of other technical reasons why the /doc page must be stored under the talk page for those (but only those) namespaces.


Terminology: ''Subject space'' is the opposite of ''talk space''. For instance "Template:" is the subject space of "Template talk:".
This template automatically points its [create] links for the /doc, /sandbox and /testcases to the right namespace.


This template is usually placed in subject space, within &lt;noinclude> tags. But in some cases this template needs to be on the talkpage:
=== Color scheme ===
{| class="wikitable" style="font-size:90%"
|+ Wikipedia background colors for {{Template link|documentation}} <small>([[Help:Using colors]])</small>
! !! RGB !! HSV !! Color !! General usage !! Note
|-
| A&nbsp;
| <kbd>#ECFCF4</kbd> || 150&deg;, 6%, 99%
| style="background:#ECFCF4" | &nbsp;
| Sample || Current documentation background
|-
| B
| <kbd>#00FF80</kbd>
| style="font-size:90%;" | {{nowrap|1=Hue=150&deg; <small>(41.7%; 106/255<small>dec</small>)</small> 100%, 100%}}
| style="background:#00FF80" | &nbsp;
| Basic hue || What we'd call ''the color''
|-
| colspan="6" |
|-
| 1
| <kbd>#A3BFB1</kbd> || 150&deg;, 15%, 75%
| style="background:#A3BFB1" | &nbsp;
| Header border only ||
|-
| 2
| <kbd>#CEF2E0</kbd> || 150&deg;, 15%, 95%
| style="background:#CEF2E0" | &nbsp;
| Main&nbsp;border; header&nbsp;background ||
|-
| 3
| <kbd>#E6FFF2</kbd> || 150&deg;, 10%, 100%
| style="background:#E6FFF2" | &nbsp;
| 2nd header, accent colour ||
|-
| 4
| <kbd>#F5FFFA</kbd> || 150&deg;, 4%, 100%
| style="background:#F5FFFA" | &nbsp;
| Main background || So saturation in A is a bit off
|}
{{collapse top|title=Colors for documentation navbox}}
As a suggestion, here are colors for a navbox intended for documentation pages only.
They follow the shading of regular blue navbox colors:
<syntaxhighlight lang="wikitext">
| titlestyle = background:#ccffe5
| basestyle  = background:#ddffee
<!-- basestyle= sets groupstyle, abovestyle, belowstyle together -->
</syntaxhighlight>
For subgroups, in child navboxes:
<syntaxhighlight lang="wikitext">
{{Navbox|child
| groupstyle = background:#e6fff2
...
</syntaxhighlight>


* For preload pages (usually in Template or Wikipedia space), since they can't use &lt;noinclude>. See for instance [[Template talk:AfC preload]] and [[Template talk:RfD subpage starter]]. Such talkpages can be marked with {{tl|talkdoc}}.
Example:{{Template link expanded|Periodic table templates overview}}
{{collapse bottom}}


* In MediaWiki space, since &lt;noinclude> often doesn't work in system messages and since MediaWiki space needs to be kept clean for performance reasons.
== Full syntax ==
<syntaxhighlight lang="wikitext">
{{Documentation}}


When placed on talkpages this template usually is placed near the top of the page and without &lt;noinclude> tags.
or


The /doc, /sandbox and /testcases pages should normally be in subject space, except in the namespaces that don't have the MediaWiki [[meta:Link#Subpage feature|subpage feature]] enabled: Main, File, MediaWiki and Category. (But currently we only show the /sandbox and /testcases links from User, User talk, Template and Template talk space.) There are also a whole bunch of other technical reasons why the /doc page must be stored under the talkpage for those namespaces.
{{Documentation
| [path to documentation page]
}}


This template automatically points its create links for the /doc, /sandbox and /testcases to the right namespace.
{{Documentation
| content =
}}


=== Technical details ===
or


This template calls {{tl|documentation/start box2}} and {{tl|documentation/end box2}} which in turn call {{tl|documentation/start box}} and {{tl|documentation/end box}}. /start box (and /end box) hold most of the code, while this template and /start box2 (and /end box2) do parameter preprocessing.
{{Documentation
| [path to documentation page]
| heading-style =
| heading =
| link box =
}}


The preload page for the /doc [create] link is [[Template:Documentation/preload]], but in File space it is [[Template:Documentation/preload-filespace]]. The preload pages for the /sandbox and /testcases <small>(create)</small> links are [[Template:Documentation/preload-sandbox]] and [[Template:Documentation/preload-testcases]].
or


For more technical details see the [[Template talk:Documentation|talk page]].
{{Documentation
| [path to documentation page]
| content =
| heading-style =
| heading =
| link box =
| page =
}}
</syntaxhighlight>


=== See also ===
==See also==
* {{tl|Documentation subpage}}, a notice placed at the top of a /doc subpage explaining its role and including a link to the page it documents.
* {{tl|Barnstar documentation}}, a variant of {{tl|Documentation}} for use with [[Wikipedia:Barnstars|barnstar]] templates.
* {{tl|Navbox documentation}}, a variant of {{tl|Documentation}} for use with [[Wikipedia:Navigation template|navigation templates]].
* [[Wikipedia:Template documentation]] is a how-to guide to template documentation.
* [[Wikipedia:Template sandbox and test cases]] explains the use of /sandbox and /testcases subpages and includes more information about template testing.


<!-- {{documentation/see also}} -->
<includeonly><!-- Make sure that only page [[Template:Documentation]] is categorised. No other page (no subpages, not when transcluded).
* {{tl|documentation}} – Placed on templates and other pages to document them.
-->{{#ifeq:{{FULLPAGENAME}}|Template:Documentation|
* {{tl|documentation subpage}} – Used at the top of /doc subpages to explain what they are and to link back to the page they document.
[[Category:Documentation templates| ]]
* [[Wikipedia:Template documentation]] – The how-to guide about template documentation.
[[Category:Template namespace templates|Documentation]]
* [[Wikipedia:Template test cases]] – How to use /sandbox and /testcases subpages and more about template testing.


<includeonly>
}}</includeonly>
[[Category:Core wiki templates]]
</includeonly><noinclude>[[Category:Core wiki templates]]</noinclude>