Jump to content

Module:Convert/makeunits/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m update link
update for new version
Line 1: Line 1:
The purpose of this module is to prepare the data used by [[Module:Convert]] to allow conversion between units of measurement.
The purpose of this module is to prepare the data used by [[Module:Convert]] to allow conversion between units of measurement.


Usage: Put one of the following lines (with nothing else) in a sandbox:
This module is run on a stand-alone computer—it currently will not run as a module because it uses <code>loadstring()</code> to evaluate expressions, and that is not allowed in Scribunto.
*<code><nowiki>{{#invoke:convert/makeunits|makeunits}}</nowiki></code>
*<code><nowiki>{{subst:#invoke:convert/makeunits|makeunits}}</nowiki></code>


Previewing the sandbox should display the wikitext that needs to be copied and pasted into [[Module:Convert/data]]. If a problem occurs, warning messages will be displayed to indicate that the unit definitions need to be fixed.
This script reads wikitext defining units, and outputs a Lua script with tables containing that data:
*The input is the wikitext at [[Module:Convert/documentation/conversion data/doc]].
*Additional input for localization is read from [[Module:Convert/text]].
*The output is manually copied to [[Module:Convert/data]] to replace its current contents.


A bug somewhere means that currently the first method shown above fails (see [[WT:Lua#Scribunto issue when output has pre tags|report]]). However, the second works.
The <code>specials</code> table is used to insert a small amount of "built-in" data that is not currently defined in the input wikitext.


By default, the module reads the unit definitions from [[Module:Convert/documentation/conversion data/doc]]. For testing purposes, it is possible to specify that the definitions are read from another page, for example, [[User:Johnuniq/sandbox2]], by specifying the wanted title:
To run the script, edit the above conversion data page and copy its wikitext to a local file, say <code>wikidata.txt</code>. Alternatively, the [[wget]] command can be used to get the wikitext, as shown below. With the script saved in file <code>makeunits.lua</code>, use the command line to run.
*<code><nowiki>{{#invoke:convert/makeunits|makeunits|User:Johnuniq/sandbox2}}</nowiki></code>
*<code><nowiki>{{subst:#invoke:convert/makeunits|makeunits|User:Johnuniq/sandbox2}}</nowiki></code>


The module reads localization information from [[Module:Convert/text]].
<pre>
wget -O makeunits.lua http://en.wikipedia.org/wiki/Module:Convert/makeunits?action=raw
wget -O wikidata.txt http://en.wikipedia.org/wiki/Module:Convert/documentation/conversion_data/doc?action=raw
wget -O converttext.lua http://en.wikipedia.org/wiki/Module:Convert/text?action=raw
lua makeunits.lua converttext wikidata.txt
</pre>


The module contains table <code>specials</code> which is used to insert a small amount of "built-in" data that is not currently defined in the input wikitext.
On some systems, "<code>lua</code>" is not needed.

By default, the script creates output file <code>makeunits.tmp</code>. Use that file to replace the contents of [[Module:Convert/data]].

Revision as of 10:22, 7 October 2013

The purpose of this module is to prepare the data used by Module:Convert to allow conversion between units of measurement.

Usage: Put one of the following lines (with nothing else) in a sandbox:

  • {{#invoke:convert/makeunits|makeunits}}
  • {{subst:#invoke:convert/makeunits|makeunits}}

Previewing the sandbox should display the wikitext that needs to be copied and pasted into Module:Convert/data. If a problem occurs, warning messages will be displayed to indicate that the unit definitions need to be fixed.

A bug somewhere means that currently the first method shown above fails (see report). However, the second works.

By default, the module reads the unit definitions from Module:Convert/documentation/conversion data/doc. For testing purposes, it is possible to specify that the definitions are read from another page, for example, User:Johnuniq/sandbox2, by specifying the wanted title:

  • {{#invoke:convert/makeunits|makeunits|User:Johnuniq/sandbox2}}
  • {{subst:#invoke:convert/makeunits|makeunits|User:Johnuniq/sandbox2}}

The module reads localization information from Module:Convert/text.

The module contains table specials which is used to insert a small amount of "built-in" data that is not currently defined in the input wikitext.