diff --git a/nxdlTypes.xsd b/nxdlTypes.xsd index 79d28b979..ffe1ae72f 100644 --- a/nxdlTypes.xsd +++ b/nxdlTypes.xsd @@ -87,7 +87,8 @@ - units of angle, example: m + units of angle + m @@ -105,7 +106,9 @@ - units of area, example: m2 or barns + units of area + m^2 + barns @@ -114,7 +117,8 @@ - units of area, example: barns (alias of NX_AREA) + units of area (alias of NX_AREA) + barn @@ -123,7 +127,8 @@ - units of electrical charge, example: c + units of electrical charge + c @@ -132,7 +137,8 @@ - units of electrical current, example: A + units of electrical current + A @@ -141,9 +147,9 @@ - units for fields where the units cancel out, - example: "" or mm/mm + units for fields where the units cancel out (NOTE: not the same as NX_UNITLESS) + m/m @@ -153,7 +159,8 @@ units of emittance (``length * angle``) of a - radiation source, example: ``nm*rad`` + radiation source + nm*rad @@ -162,7 +169,9 @@ - units of energy, example: J or keV + units of energy + J + keV @@ -171,7 +180,8 @@ - units of flux, example: s-1 cm-2 + units of flux + 1/s/cm^2 @@ -180,7 +190,8 @@ - units of frequency, example: Hz + units of frequency + Hz @@ -189,7 +200,8 @@ - units of length, example: m + units of length + m @@ -198,7 +210,8 @@ - units of length, example: g + units of mass + g @@ -207,7 +220,8 @@ - units of mass density, example: g cm-3 + units of mass density + g/cm^3 @@ -216,7 +230,8 @@ - units of molecular weight, example: g mol-1 + units of molecular weight + g/mol @@ -225,7 +240,8 @@ - units of length, example: m + units of 1/length^2 + 1/m^2 @@ -234,7 +250,8 @@ - units of length, example: m + units of 1/length + 1/m @@ -243,8 +260,9 @@ - units of time, period of pulsed source, - example: microseconds (alias to `NX_TIME`) + units of time, period of pulsed source + (alias to `NX_TIME`) + us @@ -253,7 +271,8 @@ - units of power, example: W + units of power + W @@ -262,7 +281,8 @@ - units of pressure, example: Pa + units of pressure + Pa @@ -280,7 +300,8 @@ - units of scattering length density, example: cm-2 + units of scattering length density + m/m^3 diff --git a/utils/dev_units2rst.py b/utils/dev_units2rst.py new file mode 100755 index 000000000..601619f87 --- /dev/null +++ b/utils/dev_units2rst.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +''' +Developers: use this code to develop and test nxdl2rst.py +''' + +import sys +from units2rst import worker + + +sys.argv.append("../nxdlTypes.xsd") +worker('anyUnitsAttr') diff --git a/utils/units2rst.py b/utils/units2rst.py index 4d5d8049d..8b8dd66a8 100755 --- a/utils/units2rst.py +++ b/utils/units2rst.py @@ -49,7 +49,15 @@ def worker(nodeMatchString, section = 'units'): node_name = node.get('name') if 'nxdl:' + node_name in members: words = node.xpath('xs:annotation/xs:documentation', namespaces=ns)[0] - db[node_name] = words.text + examples = [] + for example in words.iterchildren(): + nm = example.attrib.get("name") + if nm is not None and nm == "example": + examples.append("``"+example.text+"``") + a = words.text + if len(examples) > 0: + a = a.strip() + ", example(s): " + " | ".join(examples) + db[node_name] = a # for item in node.xpath('xs:restriction//xs:enumeration', namespaces=ns): # key = '%s' % item.get('value')