Difference between revisions of "Module:Track gauge/data/sandbox/doc"
blackwiki>Jackmcbarn m (→Errors: clean up after move) |
blackwiki>Jackmcbarn m (clean up after move) |
||
| Line 1: | Line 1: | ||
| − | This module holds the data for [[Module: | + | This module holds the data for [[Module:Track gauge]]. Please see the comments in the module text for instructions on how to add new gauges. For instructions on how to use the module itself, please see the corresponding template page, {{tl|Track gauge}}. |
==Entry data structure== | ==Entry data structure== | ||
A single entry is a subtable (within <code>{...}</code>) in the data page. The subtable has the following structure: | A single entry is a subtable (within <code>{...}</code>) in the data page. The subtable has the following structure: | ||
| Line 20: | Line 20: | ||
</pre> | </pre> | ||
;Overall structure | ;Overall structure | ||
| − | A module: | + | A module:Track gauge/data page has the following structure: |
<pre> | <pre> | ||
return | return | ||
| Line 54: | Line 54: | ||
==Adding a new track gauge (entry)== | ==Adding a new track gauge (entry)== | ||
| − | This can be done in [[module: | + | This can be done in [[module:Track gauge/extra]]. |
| − | {{#ifeq:{{FULLPAGENAME}}|Module: | + | {{#ifeq:{{FULLPAGENAME}}|Module:Track gauge/extra| |
| − | <br>New gauges can be added through [[module: | + | <br>New gauges can be added through [[module:Track gauge/extra]].}} |
== Errors == | == Errors == | ||
Revision as of 20:45, 3 September 2014
This module holds the data for Module:Track gauge. Please see the comments in the module text for instructions on how to add new gauges. For instructions on how to use the module itself, please see the corresponding template page, {{Track gauge}}.
Contents
Entry data structure
A single entry is a subtable (within {...}) in the data page. The subtable has the following structure:
{
["id"] = "1000", -- Gauge identification in mm.
["aliases"] = {[[1000mm]], [[1m]]}, -- Aliases for the gauge (input options; input spaces, commas and capitals are re-formatted by the module).
["def1"] = "met", -- The defining measurement, either "met" (metric) or "imp" (imperial).
["name"] = "metre gauge", -- Name for the gauge (alternative).
["link"] = "[[metre gauge]]", -- Link to named gauge article (alternative, linked).
["pagename"] = "standard gauge", -- Link to sourcing Wikipedia article.
["contentcat"] = "Iberian gauge railways" -- Non-default category name (don't add 'Category:').
["m"] = "1", -- Gauge in metre (the ["mm"] value, below, will not be shown).
["mm"] = "1000", -- Gauge in mm.
["ft"] = "3", -- The feet part of the gauge.
["in"] = "3", -- The inches part of the gauge (can have decimals)
["num"] = "3", -- The numerator for fractions of inches (the "3" in 3/8 inches).
["den"] = "8" -- The denominator for fractions of inches (the "8" in 3/8 inches).
},
- Overall structure
A module:Track gauge/data page has the following structure:
return
{
{
["id"] = "1000",
["aliases"] = {[[1000mm]], [[1m]]},
["def1"] = "met",
-- ...,
["den"] = "8"
},
{
["id"] = "1067",
["aliases"] = {[[1067mm]]},
["def1"] = "met",
-- ...,
["in"] = "6"
}
}
- Note: the last data of an entry ("den" and "in" examples) do not have a comma.
- Note: the last entry ("{id=1067, ...}" example) does not have a final comma after its closing "}"
About aliases and identifiers
A rail track gauge is identified by "id". That id is the size in mm (a choice, made for this list). Preferably it has an article link where that gauge definition is described and sourced.
An entry is a data set (a complete subtable) with structure { ["id"] = "n", ... }
An entry is identified by its Aliases. Aliases are unique; any alias will find only one entry (if present). Two entries can point to one gauge id: usually when definied in metric *and* defined in imperial. e.g., "1435mm" and "56.5in" are different entries (showing different primary size: in met or imp) but they point to the same gauge id: ["id"] = "1435".
The "id", "aliases", and "def1" fields are required. Also, some size in metric and in imperial must be present. That is: at least one metric size field (mm or m) and one imperial size field (ft, inch, or num+den) must exist. All other fields are optional.
- id: An id can be reused in multiple entries. Usually used twice when a gauge is defined in both metric and in imperial. Even a third gauge name (by another alias) can be added.
- alias (input option): An Alias must be unique over all data. Alias names here should not contain any spaces; spaces are trimmed from the input when it is processed, so alias names containing spaces will not be matched.
Adding a new track gauge (entry)
This can be done in module:Track gauge/extra.
Errors
- Lua error: bad argument #1 to 'find' (string expected, got table).
- Lua error in package.lua at line 80: module 'module:Track gauge/extra' not found.
See also
- {{Track gauge/doc/input options}} -- Overview