Jump to content

Template:Script doc auto/doc

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Davidgothberg (talk | contribs) at 02:05, 21 December 2009 (moved Template:Script doc/doc to Template:Script doc auto/doc: To make the shorter {{script doc}} name available for a version for manual use.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

This is the {{script doc}} template.

It is used in the MediaWiki:Clearyourcache system message that is shown on top of .css and .js pages.

This template detects if a script page has an accompanying documentation page. If the doc page exists it shows a small green doc box with a link to the doc page. If no doc page exists then this template returns an empty string.

The doc pages of scripts are the page name but without the ending ".css" or ".js". For instance User:Davidgothberg/clock.js has its documentation at User:Davidgothberg/clock.

When this template is called on top of User:Davidgothberg/clock.js it produces this output:

The above box is not transparent, instead it uses the same background colour as the green doc box.

For testing and demonstration purposes this template can take a parameter named page. Like this:

{{script doc| page = User:Davidgothberg/clock.js }}

The page parameter makes this template behave exactly as if on that page.

Technical details

Internally this template uses the {{str len}} template. Since {{str len}} is heavy on the servers this template only calls it once, then it feeds the result to {{script doc/core}} which contains most of the code for this template, that template then in turn calls {{script doc/core2}} which renders the green doc box and the actual text message.

Note to admins: MediaWiki does not parse and convert HTML wikimarkup in system messages the same way as it does for normal pages. This means for instance that <br> is not automatically converted to <br /> and missing </td> and </tr> tags are not automatically added. Thus see to that any HTML code you use in this template is valid XHTML. That is, close all tags that you begin. However, regular wikimarkup works fine in most system messages.

For more technical details see the talk page.

See also