FAIRmat-NFDI / nyaml

https://fairmat-nfdi.github.io/nyaml
https://pypi.org/project/nyaml/
Apache License 2.0
1 stars 0 forks source link

ISO reference in enumeration docstring breaks building of nexus definitions #6

Closed domna closed 6 months ago

domna commented 6 months ago

This part of NXmpes breaks the building into html of the nexus definitions:

...
       \@type:
          type: NX_CHAR
          exists: recommended
          doc: |
            The energy can be either stored as kinetic or as binding energy.
          enumeration: 
            kinetic: 
              doc:
              - |
                Calibrated kinetic energy axis.
              - |
                xref:
                  spec: ISO 18115-1:2023
                  term: 3.35
                  url: https://www.iso.org/obp/ui/en/#iso:std:iso:18115:-1:ed-3:v1:en:term:3.35
...

It can be fixed by changing the _get_doc_line to

def _get_doc_line(self, ns, node):
  blocks = self._get_doc_blocks(ns, node)
  if len(blocks) == 0:
      return ""
  if len(blocks) > 1:
      return re.sub(r"\n", " ", "".join(blocks))
      # raise Exception(f"Unexpected multi-paragraph doc [{'|'.join(blocks)}]")
  return re.sub(r"\n", " ", blocks[0])

but this breaks the RST syntax inside the docstring:

Bildschirmfoto 2024-01-03 um 14 53 58

So the suggested solution is checking whether we are inside an enumeration docstring during nyaml2nxdl conversion and use the 3.35 <https://www.iso.org/obp/ui/en/#iso:std:iso:18115:-1:ed-3:v1:en:term:3.35>_ in-line syntax of RST in this case.

Edit: This idea is problematic as we cannot use < and > in nxdl because it is xml based.

domna commented 6 months ago

Fixed in nexus_definitions: https://github.com/FAIRmat-NFDI/nexus_definitions/pull/52/commits/31096450674b1034e4536c65406c6e1775f14296