Module:Val/units/doc: Difference between revisions
Content deleted Content added
Caleb Cooper (talk | contribs) m Text replacement - "[[Template talk" to "[[Wikipedia:Template talk" |
Caleb Cooper (talk | contribs) |
||
| (6 intermediate revisions by the same user not shown) | |||
Line 1:
This where you {{edit|Module:Val/units|configure Val units}}. The list of Val units is published at ''[[Template:Val/list]]'', and here is the place that produces that report. So preview {{space}} <kbd>{{big|Template:Val/list}}</kbd> {{space}} from the edit box to see your changes before saving them. The file format and syntax are mostly self explanatory.
* The [[Wikipedia:field separator]] is two or more spaces.
* You can enter new units in the "Unsorted units" section if you are not sure where else it might go.
Line 30:
* Unit codes will be case sensitive.
* Prefer {{code|u}} for the Greek letter μ, if you're not sure.
* Composite units have [[Wikipedia:Dimensional analysis#Definition|dimensions]] that multiply, divide, and apply powers to component units. Use {{code|.}} to multiply, {{code|/}} to divide, and a signed digit for powers. For multiplication, {{code|*}} is deprecated. When adding a unit that includes division, consider also adding a version with multiplication by the negated power; for example, {{code|m/s2}} and {{code|m.s-2}} (for <kbd>m/s<sup>2</sup></kbd> and <kbd>m⋅s<sup>−2</sup></kbd>).
;unit pagename
Line 36:
;unit symbol
:[[Wikipedia:wp:V|Verifiable|]], standard symbol, formatted in accordance with [[Wikipedia:Wikipedia:WP:UNITS|Wikipedia:WP:UNITS]].
* Templates will not work for producing the unit symbol for input to this module; only [[Wikipedia:HTML#Formatting|Wikipedia HTML formatting]] is accepted.
* Composite units use {{code|⋅}} to multiply, {{code|/}} to divide, and {{tag|sup}} for powers. Division is also the unit-inversion form that multiplies a negative numbered power, for example for <kbd>m/s<sup>2</sup></kbd> and <kbd>m⋅s<sup>−2</sup></kbd> (from {{code|m.s-2}} and {{code|m/s2}}).
Line 66:
# Add any unit-code aliases.
# Add any sorting if needed. Details about sorting are covered below.
# Preview a test page. It will have template Val calls on it, and it may have a [[Wikipedia:Help:tables#Sortable tables|sortable table]] to test sorting. [[Template:Val/units/testcases]] is a test page containing Val calls for all units.
# ''Show changes'' to prove no accidental edits occurred.
# Save the page. Saving the page activates the changes immediately, and they go live. You're done adding your unit.
If you want a unit to add for practice, add one from [[Wikipedia:List of common physics notations|List of common physics notations]], or from [[Wikipedia:SI units#Units and prefixes|]].
'''Changing or removing existing unit codes''' is possible by employing {{tl|Template usage|Val|''code''}} to see how Val unit codes may or may not be in use on the wiki. For example, to see about changing or removing unit code <kbd>J.s</kbd>, do a
Line 77:
=== Examples ===
Say you're creating a new page or revamping an old page, and discover the need for a convenient way to make several entries containing [[Speed of light|<span title="speed of light in a vacuum">''c''<sub>0</sub></span>]], and link that symbol to the page ''Speed of light''. The following entry will define your unit code as <kbd>c0</kbd>, your unit symbol as <kbd><nowiki>''c''<sub>0</sub></nowiki></kbd>, and the unit's article as ''[[Wikipedia:Speed of light#Numerical value, notation, and units]]''.
:<kbd>c0{{spaces|2}}'''{{big|1= [[ }}'''Speed of light#Numerical value, notation, and unit symbol'''{{big|{{!}}}}'''<nowiki>''c''<sub>0</sub></nowiki>'''{{big|]]}}'''</kbd>
Line 96:
#:<kbd>'''tins'''{{spaces|3}}'''tins'''{{spaces|3}}Contins unities</kbd>
#Under "Preview page with this module" enter <kbd>Template:Val/list</kbd>, and click ''Show preview''. It shows Val/list through the version of Val/units in the edit box. Say there are no errors, the markup and hover-text look good, and the link navigates to the unit's page.
#Then in the same way of previewing, put the [[Wikipedia:wp:pagename|fullpagename]] of the sandbox from step 1, and click ''Show preview''.
#''Save page'' to save the edit to Module:Val/units.
If you want a unit to add for practice, add one from ''[[Wikipedia:List of common physics notations]]'', or from ''[[Wikipedia:SI units#Units and prefixes]]''.
There are many examples of ''composite'' units that have their own page, so adding a unit code for one of those should link to its page. There are many articles that could use a new Val unit, such as molarity at [[Wikipedia:Resveratrol|Resveratrol]].
Either of the test pages of these examples could have the sortable test-table shown in the next section.
Line 132:
</pre>
This table falls into place unsorted, so when your unit accepts an [[Wikipedia:SI prefix|SI prefix]] you can test, say, k, m, and G, with your unit, and compare with e notations 1e3, 1e6, and 1e9 in the number. For example, Val sorts these two as equal: <code>1e3 m</code> (standard [[Wikipedia:scientific notation#E notation|e notation]]) and <code>1 km</code>.
;What to look for:
Line 158:
:{{#invoke:DemoTemplate|val|99|ul=m|upl=d}}
* The val user can compose a ''multiplier'' unit on the fly by using the {{para|end}} parameter to prepend to the unit, and ''these'' can also be individually linked. For example (in geology) there is already {{Val|333|ul=uBP}} to use with {{para|end}}:
:{{#invoke:DemoTemplate|val|333|end= [[Wikipedia:megaannum|Ma]]|ul=uBP}}".
For example [[Template:Val/list]] says
<code>m.s-1 '''{{big|[<nowiki/>[}}'''Metre per second|m&sdot;s<sup>&minus;1</sup>'''{{big|]<nowiki/>]}}'''</code> linking to an article titled ''[[Wikipedia:Metre per second|Metre per second]]'', not
<code>m.s-1 '''{{big|[<nowiki/>[}}'''Metre|m'''{{big|]<nowiki/>]}}'''&sdot;'''{{big|[<nowiki/>[}}'''Second|s'''{{big|]<nowiki/>]}}'''<sup>&minus;1</sup></code> which has separate links to already existing unit codes.
Line 175:
=== Sorting ===
{{details|topic=sorting |Wikipedia:Help:sorting }}
{{details|topic=scaling |Template:Ntsh}}
Val's sorting scale factor is for comparison to other Val units that might be sorted with it.
Where [[Wikipedia:Help:Sorting|Sorting]] is done on the wiki, it is done in [[Wikipedia:Help:table#Sortable tables|sortable tables]].
Val entries in a sortable table will need a fourth field sorting flag. It can be a number, an equation, or an <kbd>SI</kbd>, but it flags the same function: a wikitable sorting "scale".
Line 192:
For scaling a unit to sort properly, you need to pick a number for a sorting factor.
There are numerous examples at [[Template:Val/list]] and at [[Template:Val/sortkey/unit]]. A [[Wikipedia:system of units|system of units]] will have its base units, for example 1 bit; then the scale for sorting a kilobyte unit is then 8000 (eight bits per byte, times a kilo, or thousand). Or a year scale is seconds so that all ''times'' sort by seconds, which is a base unit. In general the scale shows to be "base unit" of the same type times the "SI prefix", and if it's not that simple, then the unit system's number has associated a number to it, such as Avogadro's number.
For example, the following defines a unit with code <kbd>billion</kbd>, symbol <kbd>billion</kbd>, link [[Wikipedia:1,000,000,000|1,000,000,000]], and scale <kbd>1e9</kbd> ({{val|1|e=9}}). After the following entry is saved to the database
<pre>
billion billion 1,000,000,000 1e9
Line 204:
SI is used because it scales Val expressions automatically, and it is a clean indicator that the unit will sort properly. It correctly scales any SI prefix for sorting, but not other unit codes.
For SI the unit symbol will not accept HTML, but will accept μ. HTML is not accepted at this time because in order to validate the entry, the unit code must differ from the unit symbol by exactly one valid [[Wikipedia:SI prefix|SI prefix]]. If there is no difference, or too much difference, it is an invalid definition for sorting purposes. The exception is for the Greek letter μ: if you used a character input application to "install" the Greek letter <code>μ</code> in your symbol, for your "easy to type" unit code, {{key|u}}, these two are not a character mismatch.
All unit entries that use SI will have the same base unit as the symbol at Val/units, but they will display properly at Val/list.
For example, kilo is a thousand, but you're defining km2 for kilometers squared, and need HTML. You can't use SI with HTML, so use 1000*1000, or 1000000 in the sorting field. Use [[Wikipedia:e notation|1e-6]] or 0.000001 or 1/100000 instead.
If the unit you are maintaining has SI prefixes and they are all likely to be sorted in a table, add up to twelve entries, one for each common SI unit. Some of these, like ''Meter'' in the example, may have their own article, but usually all go to the base unit's pagename. Here is how ''meter'' is defined.
<pre>
m [[Wikipedia:Metre|m]] SI
cm [[Wikipedia:Centimetre|m]] SI
dam [[Wikipedia:Decametre|m]] SI
dm [[Wikipedia:Decimetre|m]] SI
hm [[Wikipedia:Hectometre|m]] SI
km [[Wikipedia:Kilometre|m]] SI
Mm [[Wikipedia:Megametre|m]] SI
mm [[Wikipedia:Millimetre|m]] SI
um [[Wikipedia:Micrometre|µm]] 1/1000000
µm [[Wikipedia:Micrometre|m]] SI
nm [[Wikipedia:Nanometre|m]] SI
pm [[Wikipedia:Picometre|m]] SI
</pre>
| |||