Template:Script doc auto/doc: Difference between revisions

Content deleted Content added
Adding "{{used in system}}".
m Specing
 
(14 intermediate revisions by 6 users not shown)
Line 1:
{{documentation subpage}}
{{used in system}}
{{cascade-protected template}}
{{lua|Module:Script doc auto}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
This is the {{tl|script doc auto}} template.
 
It is meant to be used in the [[MediaWiki:Clearyourcache]] system message that is shown on top of .css, .js, .json, and .vue pages. This template is only loaded when in "User:" and "Mediawiki" namespaces. It produces the small green doc box seen on top of user .css, .js, .json, and .vue pages.
 
{{divbox|1=gray|2=Examples|3=When this template is called on top of [[User:Davidgothberg/monobook.js]] it produces this output:
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.
{{script doc auto| page = User:Davidgothberg/clockmonobook.js }}
 
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:
{{script doc auto| page = User:Davidgothberg/clock.js }}
 
{{script doc| page = User:Davidgothberg/clock.js }}
 
When this template is called on top of [[MediaWiki:Gadget-Twinkle.js]] it produces this output:
{{script doc auto| page = MediaWiki:Gadget-Twinkle.js }}
}}
 
===Skin files===
When this template is called on a user skin file such as "/monobook.css" it gives a link to the accompanying "/monobook.js" file. It shows that link even if the accompanying skin file does not exist, but it then uses slightly different text.
 
===User scripts===
For .css, .js, .json, and .vue pages in user space other than the skin files:
 
This template links to the documentation page for the script. It shows that link even if the documentation has not been created, but it then uses slightly different text. 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]].
 
This template also detects if a .css, .js, .json, or .vue page has accompanying files with the other three extensions and then links between them. It doesn't show a link if the other file does not exist.
 
===Gadgets===
For .css, .js, .json, and .vue pages in the Mediawiki namespace:
 
This template links to the section of [[Special:Gadgets]] for the gadget. It also shows either the number of users of the gadget or whether it is a hidden or default gadget.
 
This template also detects if a .css, .js, .json, or .vue page has accompanying files with the other three extensions and then links between them. It doesn't show a link if the other file does not exist.
 
===Usage===
For testing and demonstration purposes this template can take a parameter named '''page'''. Like this:
 
<pre>
{{script doc auto| page = User:Davidgothberg/clock.js }}
</pre>
 
The '''page''' parameter makes this template behave exactly as if on that page.
 
=== Technical details ===
 
Internally this template uses the {{tl|str len}} template. Since {{tlf|str len}} is heavy on the servers this template only calls it once, then it feeds the result to {{tl|script doc/core}} which contains most of the code for this template.
 
=== See also ===
 
* [[MediaWiki:Clearyourcache]] – The system message that uses this template.
* [[Wikipedia:WikiProject User scripts/Scripts]] – Lists many user scripts.
* [[MediaWiki talk:Clearyourcache#Script documentation]] – For the discussion that lead to the creation of this template.
* [[mw:Help:Magic words]] – About <code><nowiki>{{padleft:||}}</nowiki></code> etc.
* [[mw:Help:Extension:ParserFunctions]] – About <code><nowiki>{{#ifexpr:||}}</nowiki></code> etc.
 
<includeonly>{{Sandbox other||
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
[[Category:MediaWiki namespace templates]]
 
}}</includeonly>