Modèle:Documentation/doc : Différence entre versions

De Wiklou, le Wiki du Biclou
Aller à : navigation, rechercher
m (1 version)
m (1 révision importée)
 
(Une révision intermédiaire par un autre utilisateur non affichée)
Ligne 1 : Ligne 1 :
<noinclude>{{Documentation subpage}}
+
{{TemplateBox
{{timw|Documentation}}
+
|1        = 1
 +
|1d-en    = <!-- English description of the first parameter the template takes -->
 +
|1label  = template name
 +
|1aliases = <!-- List of aliases, separated by / (a slash) -->
 +
|1type    = string/wiki-page-name
 +
|1def    = The page mentioned above, the suffix /doc
 +
|1stat    = optional
 +
 
 +
|2        = heading
 +
|2d-en    = Change the text of the "documentation" heading. If this is set to blank, the entire heading line (including the first [edit] link) will also disappear. If the documentation page doesn't exist, the "edit" link includes a [[mw:Manual:Creating pages with preloaded text|preload]] parameter so that clicking it will pre-fill the edit form with the basic documentation page format.
 +
  |2d-td-en= Change the text of the "documentation" heading. If this is set to blank, the entire heading line (including the first [edit] link) will also disappear. If the documentation page doesn't exist, the "edit" link includes a preload parameter so that clicking it will pre-fill the edit form with the basic documentation page format.
 +
|2label  = heading text
 +
|2aliases = 2
 +
|2type    = string
 +
|2def    = icon and "Documentation" text
 +
|2stat    = optional-
 +
 
 +
|3        = content
 +
|3d-en    = The content of the documentation can also be fed directly as text, instead of being specified buy name of the page containing it (parameter "1"). This option is mostly useful in a rare case where is a single documentation template is used to document many templates, with very little content change. In such a case {{para|content}} parameter can be used to call the documentation template with additional parameters, like <code><nowiki>content = {{Template:Any doc page/doc |parameter1 |parameter2}}</nowiki></code>. See "Usage" section below for more examples and [[:Category:Multi-template documentation]] for examples of template documentation pages used for more than one template.
 +
|3d-td-en =
 +
|3label  = content
 +
|3type    = string
 +
|3def    =
 +
|3stat    = optional-
 +
 
 +
|name = documentation
 +
|desc-en = This template automatically displays a green documentation 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. It is intended for pages which are [[:en:Wikipedia:Transclusion|transcluded]] in other pages, i.e. templates, whether in the template namespace or not.
 +
 
 +
  |desc-td-en = This template automatically displays a green documentation 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. It is intended for pages which are transcluded in other pages, i.e. templates, whether in the template namespace or not.
 +
|namespace = template
 +
|usergroup = all
 +
|placement = bottom
 +
|usage-notes = This template allows any page to use any documentation page, and makes it possible to protect templates while allowing anyone to edit the template's documentation, and categories. It also reduces server resources by circumventing a [[:en:Wikipedia:Template limits|technical limitation of templates]] (see a [{{fullurl:en:Project:Village pump (technical)|diff=prev&oldid=69888944}} developer's explanation]).
 +
 
 +
This code should be added at the bottom of the template code, with no extra space before "<code>&lt;noinclude&gt;</code>" (which would cause extra space on pages where the template is used). The parameter can be used as shown above to transclude an arbitrary documentation page.
 +
 
 +
Add categories to the documentation page inside includeonly tags.
 +
 
 +
If the documentation page contains includeonly or noinclude tags as part of the documentation, replace the "<" with "&amp;lt;".
 +
|type =
 +
|example =
 +
|example-value =
 +
|i18n-method = autotranslate
 +
|i18n-desc =
 +
|i18n-mediawiki-msg =
 +
|i18n-subpage =
 +
|seealso = * {{tl|documentation subpage}}
 +
* [[m:Template:Documentation]]
 +
|setscats =
 +
|lines = one
 +
|shorthand =
 +
|relieson =
 +
|mustbesubst =
 +
|useTemplateData = 1
 +
}}
 +
 
 +
===Usage===
 +
Normally this template is used without any parameters, placed at the bottom of the template or page being documented, within a {{tag|noinclude}} container:
 +
 
 +
<pre>
 +
<!--Last line of your template code--><noinclude>
 +
{{Documentation}}
 +
<!-- Add categories to the /doc subpage -->
 
</noinclude>
 
</noinclude>
 +
</pre>
  
This template automatically displays a documentation box like you are seeing now, of which the content is transcluded from another page. It is intended for pages which are [[Wikipedia:Transclusion|transcluded]] in other pages, i.e. templates, whether in the template namespace or not.
+
Then this template automatically loads the content from the /doc subpage of the template it is used on.
 +
 
 +
This template can also load the content from any other page. Like this:
  
==Usage==
 
===Normal===
 
 
<pre>
 
<pre>
&lt;noinclude&gt;{{documentation}}&lt;noinclude&gt;
+
<!--Last line of your template code--><noinclude>
or &lt;noinclude&gt;{{documentation|template:any page/doc}}&lt;noinclude&gt;
+
{{Documentation |Template:Other page/doc}}
 +
</noinclude>
 
</pre>
 
</pre>
  
This code should be added at the bottom of the template code, with no extra space before "<code>&lt;noinclude&gt;</code>" (which would cause extra space on pages where the template is used). The parameter can be used as shown above to transclude an arbitrary documentation page.
+
Note that when loading the documentation from a page other than the local /doc page it becomes tricky to handle the categories.
  
Add categories and interwiki links to the documentation page inside includeonly tags.
+
The content can also be fed directly as text. Like this:
  
If the documentation page contains includeonly or noinclude tags as part of the documentation, replace the "<" with "&amp;lt;".
+
<pre>
 +
<!--Last line of your template code--><noinclude>
 +
{{Documentation
 +
| content =
 +
(some documentation)
 +
}}</noinclude>
 +
</pre>
  
===Customizing display===
+
When the {{para|content}} parameter is used, the doc box normally does not 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.
Overrides exist to customize the output in special cases:
 
* <nowiki>{{</nowiki>documentation|'''heading'''=}}: change the text of the "documentation" heading. If this is set to blank, the entire heading line (including the first [edit] link) will also disappear.
 
  
==Functions==
+
Parameter {{para|1}} and the {{para|content}} parameter can also be combined, like this:
If the documentation page doesn't exist, the "edit" link includes a [[mw:Manual:Creating pages with preloaded text|preload]] parameter so that clicking it will pre-fill the edit form with the basic documentation page format.
 
  
==Rationale==
+
<pre>
This template allows any page to use any documentation page, and makes it possible to protect templates while allowing anyone to edit the template's documentation, categories, and interwiki links. It also reduces server resources by circumventing a [[Wikipedia:Template limits|technical limitation of templates]] (see a [{{fullurl:Project:Village pump (technical)|diff=prev&oldid=69888944}} developer's explanation]).
+
<!--Last line of your template code--><noinclude>
 +
{{Documentation |1=Template:Any page/doc
 +
| content = {{Template:Any page/doc |parameters}}
 +
}}</noinclude>
 +
</pre>
  
==See also==
+
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 {{tnull|Template:Any page/doc{{!}}parameters}}. In this example a parameter is also fed to the /doc page being loaded.
* {{tiw|template doc}} (similar template with more documentation; see [[User:Pathoschild/Sandbox|template comparison]])
 
* {{tiw|documentation subpage}} (replaces older {{[[template:Template doc page viewed directly|Template doc page viewed directly]]}} and {{[[template:Template doc page transcluded|Template doc page transcluded]]}})
 
*{{tim|Documentation}}
 
  
==See also==
 
* [[w:Wikipedia:Template documentation]]
 
 
<!-- for the template  -->
 
 
<includeonly>
 
<includeonly>
 
[[Category:Template documentation| ]]
 
[[Category:Template documentation| ]]
[[Category:Formatting templates|Template documentation]]
+
[[Category:Template namespace templates|{{PAGENAME}}]]
 
 
[[eo:Ŝablono:Dok]]
 
[[es:Plantilla:Uso de plantilla]]
 
[[fr:Modèle:Documentation modèle]]
 
[[hsb:Předłoha:Doc]]
 
[[hu:Sablon:Sablondokumentáció]]
 
[[ko:틀:틀 설명문서]]
 
[[nl:Sjabloon:Sjabdoc]]
 
[[ru:Шаблон:Doc]]
 
[[sl:Predloga:Dokumentacija]]
 
[[uk:Шаблон:Doc]]
 
[[zh:Template:Template doc]]
 
 
</includeonly>
 
</includeonly>

Version actuelle datée du 19 janvier 2016 à 11:29

This template automatically displays a green documentation 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. It is intended for pages which are transcluded in other pages, i.e. templates, whether in the template namespace or not.

Usage

{{documentation |1= }}

This template allows any page to use any documentation page, and makes it possible to protect templates while allowing anyone to edit the template's documentation, and categories. It also reduces server resources by circumventing a technical limitation of templates (see a developer's explanation).

This code should be added at the bottom of the template code, with no extra space before "<noinclude>" (which would cause extra space on pages where the template is used). The parameter can be used as shown above to transclude an arbitrary documentation page.

Add categories to the documentation page inside includeonly tags.

If the documentation page contains includeonly or noinclude tags as part of the documentation, replace the "<" with "&lt;".

⧼templatedata-doc-params⧽

ParameterDescriptionDefaultStatus
heading
2
heading textChange the text of the "documentation" heading. If this is set to blank, the entire heading line (including the first [edit] link) will also disappear. If the documentation page doesn't exist, the "edit" link includes a preload parameter so that clicking it will pre-fill the edit form with the basic documentation page format.icon and "Documentation" textoptional
contentcontentThe content of the documentation can also be fed directly as text, instead of being specified buy name of the page containing it (parameter "1"). This option is mostly useful in a rare case where is a single documentation template is used to document many templates, with very little content change. In such a case |content= parameter can be used to call the documentation template with additional parameters, like content = {{Template:Any doc page/doc |parameter1 |parameter2}}. See "Usage" section below for more examples and Category:Multi-template documentation for examples of template documentation pages used for more than one template.emptyoptional
1
template nameThe page mentioned above, the suffix /docoptional

Additional information

The template is intended to be used in the following namespaces: the Template namespace

The template is intended to be used by the following user groups: all users

Placement: At the bottom of the page

⧼Seealso⧽

Localization

This template is localized through {{Autotranslate}}. The layout of the template can be found under Template:documentation/layout.

To add your language to the list of languages supported by this template, please copy the code of Template:documentation/en (or any other language version you prefer to translate) and replace the text strings in there (the form below can be used to create a translation, the English version is preloaded in the edit box). Please change the parameter lang from en (or whatever language you are translating) to the language code of your language.


Usage

Normally this template is used without any parameters, placed at the bottom of the template or page being documented, within a <noinclude>...</noinclude> container:

<!--Last line of your template code--><noinclude>
{{Documentation}}
<!-- Add categories to the /doc subpage -->
</noinclude>

Then this template automatically loads the content from the /doc subpage of the template it is used on.

This template can also load the content from any other page. Like this:

<!--Last line of your template code--><noinclude>
{{Documentation |Template:Other page/doc}}
</noinclude>

Note that when loading the documentation from a page other than the local /doc page it becomes tricky to handle the categories.

The content can also be fed directly as text. Like this:

<!--Last line of your template code--><noinclude>
{{Documentation
 | content =
(some documentation)
}}</noinclude>

When the |content= parameter is used, the doc box normally does not 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.

Parameter |1= and the |content= parameter can also be combined, like this:

<!--Last line of your template code--><noinclude>
{{Documentation |1=Template:Any page/doc
| content = {{Template:Any page/doc |parameters}}
}}</noinclude>

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 Modèle:Tnull. In this example a parameter is also fed to the /doc page being loaded.