Jump to content

Wikipedia:Template documentation

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ligulem (talk | contribs) at 08:43, 25 August 2006 (new). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

The template doc page pattern can be used to improve the following:

Wikipedians generally do like to have a usage description of the template right at the template page (example: template:cite news). This can be achieved by writing some descriptive text into the template wiki-source inside <noinclude>...</noinclude>. However, this has some drawbacks:

  • The text inside <noinclude>...</noinclude> does add to the pre-expand include size, which is limited (see Wikipedia:Template limits).
  • Some templates are fully protected, because they are transcluded into a lot of pages. Editing the documentation is awkward in this case, because non-sysops must make a request to edit a protected page and a sysop has to do the edit.

How-to

For a template with the name X, create a subpage with the name X/doc and put the following wikicode for a start in that page:

<includeonly>:''This template documentation is transcluded from [[{{FULLPAGENAME}}/doc]]'' [<span class="plainlinks">[{{fullurl:{{FULLPAGENAMEE}}/doc|action=edit}} edit]</span>]</includeonly>
<!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE -->

<includeonly>
<!-- ADD CATEGORIES BELOW THIS LINE -->

<!-- ADD INTERWIKIS BELOW THIS LINE -->
</includeonly>

Insert the documentation, categories and interwikis as indicated by the repsective comment lines (see above).

In the page for template X, add

<noinclude>{{/doc}}</noinlcude>

at the end. Attention: Make sure the opening <noinclude> begins on the same line as the last character of the template code, not on a new line. Otherwise, additional newline will be inserted into pages transcluding X (which is almost never wanted).

The template itself can now be fully protected, while its documentation page at /doc can remain fully unprotected so that everyone can edit it.

Benefits

Edits to the /doc page only propagate to the template display page itself, not to transclusions. Pages transcluding X are therefore not dependent on the doc page, so edits to the doc page don't inflate the job queue. Vandalism to the doc page also doesn't propagate into pages transcluding X.