From 080a88fbc3d77956a1cf000c4dda913ae7854d29 Mon Sep 17 00:00:00 2001 From: domna Date: Tue, 19 Dec 2023 16:20:27 +0100 Subject: [PATCH 1/5] Adds makefile refinements and nyaml as dependency --- Makefile | 34 +++++++++++++++++++++++++++++++--- nyaml.mk | 22 ++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 nyaml.mk diff --git a/Makefile b/Makefile index ae556d7339..ed168052f8 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,17 @@ PYTHON = python3 SPHINX = sphinx-build BUILD_DIR = "build" +BASE_CLASS_DIR := base_classes +CONTRIB_DIR := contributed_definitions +APPDEF_DIR := applications +NYAML_SUBDIR := nyaml -.PHONY: help install style autoformat test clean prepare html pdf impatient-guide all local +YBC_NXDL = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(BASE_CLASS_DIR)/nyaml/*.yaml))) +YCONTRIB_NXDL = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(CONTRIB_DIR)/nyaml/*.yaml))) +YAPPDEF_NXDL = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(APPDEF_DIR)/nyaml/*.yaml))) + + +.PHONY: help install style autoformat test clean prepare html pdf impatient-guide all local nxdl nyaml help :: @echo "" @@ -50,13 +59,18 @@ test :: clean :: $(RM) -rf $(BUILD_DIR) +clean-nyaml :: + $(RM) -rf $(BASE_CLASS_DIR)/$(NYAML_SUBDIR) + $(RM) -rf $(APPDEF_DIR)/$(NYAML_SUBDIR) + $(RM) -rf $(CONTRIB_DIR)/$(NYAML_SUBDIR) + prepare :: $(PYTHON) -m dev_tools manual --prepare --build-root $(BUILD_DIR) $(PYTHON) -m dev_tools impatient --prepare --build-root $(BUILD_DIR) pdf :: $(SPHINX) -M latexpdf $(BUILD_DIR)/manual/source/ $(BUILD_DIR)/manual/build - cp $(BUILD_DIR)/manual/build/latex/nexus.pdf $(BUILD_DIR)/manual/source/_static/NeXusManual.pdf + cp $(BUILD_DIR)/manual/build/latex/nexus-fairmat.pdf $(BUILD_DIR)/manual/source/_static/NeXusManual.pdf html :: $(SPHINX) -b html -W $(BUILD_DIR)/manual/source/ $(BUILD_DIR)/manual/build/html @@ -81,7 +95,21 @@ all :: @echo "HTML built: `ls -lAFgh $(BUILD_DIR)/impatient-guide/build/html/index.html`" @echo "PDF built: `ls -lAFgh $(BUILD_DIR)/impatient-guide/build/latex/NXImpatient.pdf`" @echo "HTML built: `ls -lAFgh $(BUILD_DIR)/manual/build/html/index.html`" - @echo "PDF built: `ls -lAFgh $(BUILD_DIR)/manual/build/latex/nexus.pdf`" + @echo "PDF built: `ls -lAFgh $(BUILD_DIR)/manual/build/latex/nexus-fairmat.pdf`" + +$(BASE_CLASS_DIR)/%.nxdl.xml : $(BASE_CLASS_DIR)/$(NYAML_SUBDIR)/%.yaml + nyaml2nxdl $< --output-file $@ + +$(CONTRIB_DIR)/%.nxdl.xml : $(CONTRIB_DIR)/$(NYAML_SUBDIR)/%.yaml + nyaml2nxdl $< --output-file $@ + +$(APPDEF_DIR)/%.nxdl.xml : $(APPDEF_DIR)/$(NYAML_SUBDIR)/%.yaml + nyaml2nxdl $< --output-file $@ + +nxdl: $(YBC_NXDL) $(YCONTRIB_NXDL) $(YAPPDEF_NXDL) + +nyaml: + $(MAKE) -f nyaml.mk # NeXus - Neutron and X-ray Common Data Format diff --git a/nyaml.mk b/nyaml.mk new file mode 100644 index 0000000000..15e1733fa3 --- /dev/null +++ b/nyaml.mk @@ -0,0 +1,22 @@ +BASE_CLASS_DIR := base_classes +CONTRIB_DIR := contributed_definitions +APPDEF_DIR := applications +NYAML_SUBDIR := nyaml +NXDL_BC = $(addprefix $(BASE_CLASS_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(BASE_CLASS_DIR)/*.nxdl.xml)))) +NXDL_APPDEF = $(addprefix $(APPDEF_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(APPDEF_DIR)/*.nxdl.xml)))) +NXDL_CONTRIB = $(addprefix $(CONTRIB_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(CONTRIB_DIR)/*.nxdl.xml)))) + +.PHONY: all nyaml + +$(BASE_CLASS_DIR)/$(NYAML_SUBDIR)/%.yaml : $(BASE_CLASS_DIR)/%.nxdl.xml + nyaml2nxdl $< --output-file $@ + +$(CONTRIB_DIR)/$(NYAML_SUBDIR)/%.yaml : $(CONTRIB_DIR)/%.nxdl.xml + nyaml2nxdl $< --output-file $@ + +$(APPDEF_DIR)/$(NYAML_SUBDIR)/%.yaml : $(APPDEF_DIR)/%.nxdl.xml + nyaml2nxdl $< --output-file $@ + +nyaml: $(NXDL_BC) $(NXDL_APPDEF) $(NXDL_CONTRIB) + +all: nyaml diff --git a/requirements.txt b/requirements.txt index 6d024bda3a..0460907461 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ # Prepare for Documentation lxml pyyaml +nyaml # Documentation building sphinx>=5 From 8f1622c61f0646b1234602071e76cab816aca1de Mon Sep 17 00:00:00 2001 From: domna Date: Tue, 19 Dec 2023 16:23:10 +0100 Subject: [PATCH 2/5] Build nexus.pdf instead of nexus-fairmat.pdf --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ed168052f8..8d636b3f05 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ prepare :: pdf :: $(SPHINX) -M latexpdf $(BUILD_DIR)/manual/source/ $(BUILD_DIR)/manual/build - cp $(BUILD_DIR)/manual/build/latex/nexus-fairmat.pdf $(BUILD_DIR)/manual/source/_static/NeXusManual.pdf + cp $(BUILD_DIR)/manual/build/latex/nexus.pdf $(BUILD_DIR)/manual/source/_static/NeXusManual.pdf html :: $(SPHINX) -b html -W $(BUILD_DIR)/manual/source/ $(BUILD_DIR)/manual/build/html @@ -95,7 +95,7 @@ all :: @echo "HTML built: `ls -lAFgh $(BUILD_DIR)/impatient-guide/build/html/index.html`" @echo "PDF built: `ls -lAFgh $(BUILD_DIR)/impatient-guide/build/latex/NXImpatient.pdf`" @echo "HTML built: `ls -lAFgh $(BUILD_DIR)/manual/build/html/index.html`" - @echo "PDF built: `ls -lAFgh $(BUILD_DIR)/manual/build/latex/nexus-fairmat.pdf`" + @echo "PDF built: `ls -lAFgh $(BUILD_DIR)/manual/build/latex/nexus.pdf`" $(BASE_CLASS_DIR)/%.nxdl.xml : $(BASE_CLASS_DIR)/$(NYAML_SUBDIR)/%.yaml nyaml2nxdl $< --output-file $@ From 0874db23b483153e15f7bf7132bce6b5469bc9a1 Mon Sep 17 00:00:00 2001 From: domna Date: Thu, 21 Dec 2023 14:16:38 +0100 Subject: [PATCH 3/5] Adresses review comments --- Makefile | 22 +++++++++++----------- nyaml.mk | 11 +++++++---- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 8d636b3f05..eefdcb3a9b 100644 --- a/Makefile +++ b/Makefile @@ -5,15 +5,15 @@ PYTHON = python3 SPHINX = sphinx-build -BUILD_DIR = "build" -BASE_CLASS_DIR := base_classes -CONTRIB_DIR := contributed_definitions -APPDEF_DIR := applications -NYAML_SUBDIR := nyaml +BUILD_DIR = build +BASE_CLASS_DIR = base_classes +CONTRIB_DIR = contributed_definitions +APPDEF_DIR = applications +NYAML_SUBDIR = nyaml -YBC_NXDL = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(BASE_CLASS_DIR)/nyaml/*.yaml))) -YCONTRIB_NXDL = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(CONTRIB_DIR)/nyaml/*.yaml))) -YAPPDEF_NXDL = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(APPDEF_DIR)/nyaml/*.yaml))) +YBC_NXDL_TARGETS = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(BASE_CLASS_DIR)/nyaml/*.yaml))) +YCONTRIB_NXDL_TARGETS = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(CONTRIB_DIR)/nyaml/*.yaml))) +YAPPDEF_NXDL_TARGETS = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(APPDEF_DIR)/nyaml/*.yaml))) .PHONY: help install style autoformat test clean prepare html pdf impatient-guide all local nxdl nyaml @@ -34,6 +34,8 @@ help :: @echo "make impatient-guide Build html & PDF versions of the Guide for the Impatient. Requires prepare first." @echo "make all Builds complete web site for the manual (in build directory)." @echo "make local (Developer use) Test, prepare and build the HTML manual." + @echo "make nxdl Build NXDL files from NYAML files in nyaml subdirectories." + @echo "make nyaml Build NYAML files to nyaml subdirectories from NXDL files." @echo "" @echo "Note: All builds of the manual will occur in the 'build/' directory." @echo " For a complete build, run 'make all' in the root directory." @@ -58,8 +60,6 @@ test :: clean :: $(RM) -rf $(BUILD_DIR) - -clean-nyaml :: $(RM) -rf $(BASE_CLASS_DIR)/$(NYAML_SUBDIR) $(RM) -rf $(APPDEF_DIR)/$(NYAML_SUBDIR) $(RM) -rf $(CONTRIB_DIR)/$(NYAML_SUBDIR) @@ -106,7 +106,7 @@ $(CONTRIB_DIR)/%.nxdl.xml : $(CONTRIB_DIR)/$(NYAML_SUBDIR)/%.yaml $(APPDEF_DIR)/%.nxdl.xml : $(APPDEF_DIR)/$(NYAML_SUBDIR)/%.yaml nyaml2nxdl $< --output-file $@ -nxdl: $(YBC_NXDL) $(YCONTRIB_NXDL) $(YAPPDEF_NXDL) +nxdl: $(YBC_NXDL_TARGETS) $(YCONTRIB_NXDL_TARGETS) $(YAPPDEF_NXDL_TARGETS) nyaml: $(MAKE) -f nyaml.mk diff --git a/nyaml.mk b/nyaml.mk index 15e1733fa3..898ebd6cc5 100644 --- a/nyaml.mk +++ b/nyaml.mk @@ -2,21 +2,24 @@ BASE_CLASS_DIR := base_classes CONTRIB_DIR := contributed_definitions APPDEF_DIR := applications NYAML_SUBDIR := nyaml -NXDL_BC = $(addprefix $(BASE_CLASS_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(BASE_CLASS_DIR)/*.nxdl.xml)))) -NXDL_APPDEF = $(addprefix $(APPDEF_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(APPDEF_DIR)/*.nxdl.xml)))) -NXDL_CONTRIB = $(addprefix $(CONTRIB_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(CONTRIB_DIR)/*.nxdl.xml)))) +NXDL_BC_TARGETS = $(addprefix $(BASE_CLASS_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(BASE_CLASS_DIR)/*.nxdl.xml)))) +NXDL_APPDEF_TARGETS = $(addprefix $(APPDEF_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(APPDEF_DIR)/*.nxdl.xml)))) +NXDL_CONTRIB_TARGETS = $(addprefix $(CONTRIB_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(CONTRIB_DIR)/*.nxdl.xml)))) .PHONY: all nyaml $(BASE_CLASS_DIR)/$(NYAML_SUBDIR)/%.yaml : $(BASE_CLASS_DIR)/%.nxdl.xml + @mkdir -p $(@D) nyaml2nxdl $< --output-file $@ $(CONTRIB_DIR)/$(NYAML_SUBDIR)/%.yaml : $(CONTRIB_DIR)/%.nxdl.xml + @mkdir -p $(@D) nyaml2nxdl $< --output-file $@ $(APPDEF_DIR)/$(NYAML_SUBDIR)/%.yaml : $(APPDEF_DIR)/%.nxdl.xml + @mkdir -p $(@D) nyaml2nxdl $< --output-file $@ -nyaml: $(NXDL_BC) $(NXDL_APPDEF) $(NXDL_CONTRIB) +nyaml: $(NXDL_BC_TARGETS) $(NXDL_APPDEF_TARGETS) $(NXDL_CONTRIB_TARGETS) all: nyaml From 6b251b90c2cc845af43411620881913b7578be4f Mon Sep 17 00:00:00 2001 From: domna Date: Thu, 21 Dec 2023 14:26:50 +0100 Subject: [PATCH 4/5] Adds README explanation for make nyaml and make nxdl --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 76112c7704..5a0a9e734d 100755 --- a/README.md +++ b/README.md @@ -33,6 +33,24 @@ Note: If set this will increase the build time of the documentation by approxima setenv GH_TOKEN +### Working with nyaml files + +There exists a simplified format of nxdl, which is called nyaml. +There is a [tool](https://github.com/FAIRmat-NFDI/nyaml) (`nyaml2nxdl`) available to convert between nxdl and nyaml. +This tool is already installed when you installed the requirements for this repository and it is conveniently available from the make command. + +You can build nyaml files for all nxdl files with invoking + + make nyaml + +which will created `.yaml` files in a subfolder called `nyaml` in the respective directory. + +From this you can do your changes and create nxdl files with + + make nxdl + +from the yaml files. + ## Repository content These are the components that define the structure of NeXus data files From a58110c914a32bcae0c076cf30b6dadb417577f1 Mon Sep 17 00:00:00 2001 From: domna Date: Thu, 21 Dec 2023 17:37:35 +0100 Subject: [PATCH 5/5] Add nyaml to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ae7946a348..353bdd61c2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,8 @@ __pycache__/ # Build artifacts build/ makelog.txt +nyaml/ # Unknown /python/ -__github_creds__.txt +__github_creds__.txt \ No newline at end of file