Template:Script doc auto/doc
![]() | This is a documentation subpage for Template:Script doc auto. It may contain usage information, categories and other content that is not part of the original template page. |
![]() | This template is used in system messages. Changes to it can cause immediate changes to the Wikipedia user interface. To avoid major disruption, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them. |
This is the {{script doc}} template.
It is meant to be 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:
![]() | This user script seems to have a documentation page at User:Davidgothberg/clock. |
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.
See also
- MediaWiki:Clearyourcache – The system message that uses this template.
- MediaWiki talk:Clearyourcache#Script documentation – For the discussion that lead to the creation of this template.
- mw:Help:Magic words – About
{{padleft:||}}
etc. - mw:Help:Extension:ParserFunctions – About
{{#ifexpr:||}}
etc.