diff --git a/dev_tools/docs/xsd_units.py b/dev_tools/docs/xsd_units.py index 8306a6fa9f..cab8b3e304 100644 --- a/dev_tools/docs/xsd_units.py +++ b/dev_tools/docs/xsd_units.py @@ -43,16 +43,19 @@ def generate_xsd_units_doc( if node_name is None: continue if "nxdl:" + node_name in members: - words = node.xpath("xs:annotation/xs:documentation", namespaces=ns)[0] + unit_docs = node.xpath("xs:annotation/xs:documentation", namespaces=ns)[0] 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 = " ".join(a.split()) + ",\n\texample(s): " + " | ".join(examples) - db[node_name] = a + for unit_docs_child in unit_docs.iterchildren(): + name = unit_docs_child.attrib.get("name") + if name == "example": + units_example = unit_docs_child.attrib["fixed"] + examples.append(f"``{units_example}``") + unit_docs = unit_docs.text + if examples: + prefix = "\texamples: " if len(examples) > 1 else "\texample: " + examples = " | ".join(examples) + unit_docs = " ".join(unit_docs.split()) + f",\n{prefix}{examples}" + db[node_name] = unit_docs # for item in node.xpath("xs:restriction//xs:enumeration", namespaces=ns): # key = "%s" % item.get("value") diff --git a/nxdlTypes.xsd b/nxdlTypes.xsd index a350af8df5..16d5eaa9d8 100644 --- a/nxdlTypes.xsd +++ b/nxdlTypes.xsd @@ -88,7 +88,7 @@ units of angle - rad + @@ -107,8 +107,8 @@ units of area - m^2 - barns + + @@ -128,7 +128,7 @@ units of area (alias of NX_AREA) - barn + @@ -138,7 +138,7 @@ units of electrical charge - C + @@ -148,7 +148,7 @@ units of electrical current - A + @@ -159,7 +159,7 @@ units for fields where the units cancel out (NOTE: not the same as NX_UNITLESS) - m/m + @@ -170,7 +170,7 @@ units of emittance (``length * angle``) of a radiation source - nm*rad + @@ -180,8 +180,8 @@ units of energy - J - keV + + @@ -191,7 +191,7 @@ units of flux - 1/s/cm^2 + @@ -201,7 +201,7 @@ units of frequency - Hz + @@ -211,7 +211,7 @@ units of length - m + @@ -221,7 +221,7 @@ units of mass - g + @@ -231,7 +231,7 @@ units of mass density - g/cm^3 + @@ -241,7 +241,7 @@ units of molecular weight - g/mol + @@ -251,7 +251,7 @@ units of 1/length^2 - 1/m^2 + @@ -261,7 +261,7 @@ units of 1/length - 1/m + @@ -272,7 +272,7 @@ units of time, period of pulsed source (alias to `NX_TIME`) - us + @@ -282,7 +282,7 @@ units of power - W + @@ -292,7 +292,7 @@ units of pressure - Pa + @@ -313,7 +313,7 @@ units of scattering length density - m/m^3 +