Difference between revisions of "Module:Convert/sandbox/doc"

From blackwiki
Jump to navigation Jump to search
blackwiki>Johnuniq
(copy from Module:Convert/doc)
 
m (4 revisions imported)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
This module converts a value from one unit of measurement to another. For example:
+
When making a change, copy the current modules to the sandbox pages, then edit the sandbox copies.
*<code><nowiki>{{convert|123|lb|kg}}</nowiki></code> → 123 pounds (56 kg)
 
  
The module is called using a template—parameters passed to the template are used by this module to control how a conversion is performed. For example, units can be abbreviated (like <code>kg</code>), or displayed as names (like <code>kilogram</code>), and the output value can be rounded to a specified precision. For usage information, see the [[User:Johnuniq/Convert documentation|convert documentation]].
+
If wanted, use the purge link just above to update the following status report.
 
+
{{#invoke:convert/sandbox/testcases|check_sandbox}}
The template that invokes this module is:
 
*[[Template:Convert/sandboxlua]]
 
 
 
The following modules are required:
 
*[[Module:Convert]] – ''(this module)'' code to convert units
 
*[[Module:Convert/data]] – unit definitions
 
*[[Module:Convert/text]] – text messages and parameter names and values
 
 
 
The following modules are optional and are used only if required and if the module exists:
 
*[[Module:Convert/extra]] – extra (temporary) unit definitions; used if a unit is not found in [[Module:Convert/data]]
 
*[[Module:ConvertNumeric]] – code to spell an input value in words (only English is supported)
 
 
 
Many testcase pages are available. Currently, the testcases compare the output from the current [[Template:Convert]] with the output from [[Template:Convert/sandboxlua]].
 
*[[Template:Convert/testcases]] – template tests
 
 
 
Units are defined in the wikitext of the master list of units. Wikitext copied from that page is translated to create the unit definitions by running a Lua script on a local computer.
 
*[[User:Johnuniq/Conversion data]] – master list of unit definitions
 
*[[Module:Convert/makeunits]] – script to translate wikitext from [[User:Johnuniq/Conversion data]] to Lua source for [[Module:Convert/data]]
 
 
 
[[Module:Convert/data]] is transcluded into every page using the convert module, so experimenting with a new unit in that module would involve a significant overhead. The [[Module:Convert/extra]] module is an alternative which is only transcluded on pages with a unit that is not defined in the main data module.
 
 
 
===Sandbox===
 
When making a change, copy the current modules to the sandbox pages, then edit the sandbox copies:
 
*[[Module:Convert/sandbox]]
 
*[[Module:Convert/data/sandbox]]
 
*[[Module:Convert/text/sandbox]]
 
*[[Module:Convert/extra/sandbox]]
 
  
 
Use the following template to test the results (example <code><nowiki>{{convert/sandbox|123|lb|kg}}</nowiki></code>):
 
Use the following template to test the results (example <code><nowiki>{{convert/sandbox|123|lb|kg}}</nowiki></code>):
*[[Template:Convert/sandbox]]
+
*[[Template:Convert/sandbox]] invokes the sandbox modules and shows all warnings
 
 
[[Template:Convert/sandbox]] invokes [[Module:Convert/sandbox]] with parameter <code>sandbox = on</code> which causes convert to use the sandbox modules rather than the normal modules.
 
 
 
{{red|'''To do:''' Implement unit tests and document usage.}}
 
 
 
===Configuration===
 
The template that invokes this module can define options to configure the module. For example:
 
*<code><nowiki>{{#invoke:convert | convert | numdot = , | numsep = . }}</nowiki></code>
 
:Sets the [[decimal mark]] to be a comma, and the thousands separator to be a dot.
 
 
 
Other options, with default values, are:
 
*<code>maxsigfig = 14</code> – maximum number of significant figures
 
*<code>warnings = off</code> – on if invalid options should show a warning
 
*<code>sandbox = off</code> – on if the sandbox modules should be used
 
  
Other configuration is available in the <code>translation_table</code> at [[Module:Convert/text]]. For example, [[:bn:Module:Convert/text]] uses:
+
Testscases:
*<code>group = 2</code> – group numbers 3 digits, then 2 digits
+
*[[Module:Convert/sandbox/testcases]] • templates to be tested, with expected outputs
*<code>plural_suffix = <nowiki>''</nowiki></code> – disable plural unit names (do not append "s")
+
*[[Module talk:Convert/sandbox/testcases]] • view test results
*Tables to translate digits to and from the English digits used in calculations.
+
*[[Template:Convert/testcases#Sandbox testcases]] • more tests
  
[[Module:Convert/text]] contains all text used for input parameters and for output messages and categories. For example, <code>lk=on</code> may be used at en.wikipedia to link each displayed unit to its article. The text module could be edited to replace "<code>lk</code>" and "<code>on</code>" with any desired text.
+
It is not necessary to save a module before viewing test results. For example, [[Module:Convert/sandbox]] could be edited. While still editing that page, paste
 +
:{{nowrap|<code>Module talk:Convert/sandbox/testcases</code>}}
 +
into the page title box under "Preview page with this template", then click "Show preview".

Latest revision as of 15:52, 26 September 2020

When making a change, copy the current modules to the sandbox pages, then edit the sandbox copies.

If wanted, use the purge link just above to update the following status report.

Use the following template to test the results (example {{convert/sandbox|123|lb|kg}}):

Testscases:

It is not necessary to save a module before viewing test results. For example, Module:Convert/sandbox could be edited. While still editing that page, paste

Module talk:Convert/sandbox/testcases

into the page title box under "Preview page with this template", then click "Show preview".