From 4004bbf60b82a08fe4d0d47bf06ede492cc25c5e Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Thu, 9 Feb 2023 00:25:41 +0000 Subject: [PATCH 1/3] feat: support gen-xxx environment variables --- README.md | 7 +++++++ {{cookiecutter.project_name}}/Makefile | 24 ++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 00d773e..946121b 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,13 @@ See [linkml/linkml-project-cookiecutter](https://github.com/linkml/linkml-projec ### Step 4: Setup the LinkML project +Optionally set project generation environment variables, skip if unsure. + +``` +export LINKML_COOKIECUTTER_GEN_DOC_ARGS=--no-mergeimports # custom arg +export LINKML_COOKIECUTTER_GEN_PROJECT_ARGS=--mergeimports # default arg +``` + Change to the folder your generated project is in ```bash diff --git a/{{cookiecutter.project_name}}/Makefile b/{{cookiecutter.project_name}}/Makefile index fbf6b84..bc31e88 100644 --- a/{{cookiecutter.project_name}}/Makefile +++ b/{{cookiecutter.project_name}}/Makefile @@ -21,6 +21,18 @@ SHEET_ID = $(shell sh ./utils/get-value.sh google_sheet_id) SHEET_TABS = $(shell sh ./utils/get-value.sh google_sheet_tabs) SHEET_MODULE_PATH = $(SOURCE_SCHEMA_DIR)/$(SHEET_MODULE).yaml +# environment variables +GEN_PARGS = +ifdef LINKML_COOKIECUTTER_GEN_PROJECT_ARGS +GEN_PARGS = ${LINKML_COOKIECUTTER_GEN_PROJECT_ARGS} +endif + +GEN_DARGS = +ifdef LINKML_COOKIECUTTER_GEN_DOC_ARGS +GEN_DARGS = ${LINKML_COOKIECUTTER_GEN_DOC_ARGS} +endif + + # basename of a YAML file in model/ .PHONY: all clean @@ -91,27 +103,27 @@ gen-examples: # generates all project files {% if cookiecutter.use_schemasheets == "Yes" %} gen-project: $(PYMODEL) compile-sheets - $(RUN) gen-project -d $(DEST) $(SOURCE_SCHEMA_PATH) && mv $(DEST)/*.py $(PYMODEL) + $(RUN) gen-project ${GEN_PARGS} -d $(DEST) $(SOURCE_SCHEMA_PATH) && mv $(DEST)/*.py $(PYMODEL) {% else %} gen-project: $(PYMODEL) - $(RUN) gen-project -d $(DEST) $(SOURCE_SCHEMA_PATH) && mv $(DEST)/*.py $(PYMODEL) + $(RUN) gen-project ${GEN_PARGS} -d $(DEST) $(SOURCE_SCHEMA_PATH) && mv $(DEST)/*.py $(PYMODEL) {% endif %} test: test-schema test-python test-schema: - $(RUN) gen-project -d tmp $(SOURCE_SCHEMA_PATH) + $(RUN) gen-project ${GEN_PARGS} -d tmp $(SOURCE_SCHEMA_PATH) test-python: $(RUN) python -m unittest discover lint: - $(RUN) linkml-lint $(SOURCE_SCHEMA_PATH) + $(RUN) linkml-lint $(SOURCE_SCHEMA_PATH) check-config: @(grep my-datamodel about.yaml > /dev/null && printf "\n**Project not configured**:\n\n - Remember to edit 'about.yaml'\n\n" || exit 0) convert-examples-to-%: - $(patsubst %, $(RUN) linkml-convert % -s $(SOURCE_SCHEMA_PATH) -C Person, $(shell find src/data/examples -name "*.yaml")) + $(patsubst %, $(RUN) linkml-convert % -s $(SOURCE_SCHEMA_PATH) -C Person, $(shell find src/data/examples -name "*.yaml")) examples/%.yaml: src/data/examples/%.yaml $(RUN) linkml-convert -s $(SOURCE_SCHEMA_PATH) -C Person $< -o $@ @@ -133,7 +145,7 @@ $(DOCDIR): gendoc: $(DOCDIR) cp $(SRC)/docs/*md $(DOCDIR) ; \ - $(RUN) gen-doc -d $(DOCDIR) $(SOURCE_SCHEMA_PATH) + $(RUN) gen-doc ${GEN_DOC_ARGS} -d $(DOCDIR) $(SOURCE_SCHEMA_PATH) testdoc: gendoc serve From ecab9b24c71e7286107a43f22edb13db0d0bba3c Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Thu, 9 Feb 2023 00:47:01 +0000 Subject: [PATCH 2/3] fix: corrected varname --- {{cookiecutter.project_name}}/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/Makefile b/{{cookiecutter.project_name}}/Makefile index bc31e88..737e26e 100644 --- a/{{cookiecutter.project_name}}/Makefile +++ b/{{cookiecutter.project_name}}/Makefile @@ -145,7 +145,7 @@ $(DOCDIR): gendoc: $(DOCDIR) cp $(SRC)/docs/*md $(DOCDIR) ; \ - $(RUN) gen-doc ${GEN_DOC_ARGS} -d $(DOCDIR) $(SOURCE_SCHEMA_PATH) + $(RUN) gen-doc ${GEN_DARGS} -d $(DOCDIR) $(SOURCE_SCHEMA_PATH) testdoc: gendoc serve From b0ffbabf3c3f81cf3cd61688798f8ba4de726337 Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Sat, 11 Feb 2023 19:08:04 +0000 Subject: [PATCH 3/3] doc: minor update --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 946121b..26552c7 100644 --- a/README.md +++ b/README.md @@ -91,11 +91,11 @@ See [linkml/linkml-project-cookiecutter](https://github.com/linkml/linkml-projec ### Step 4: Setup the LinkML project -Optionally set project generation environment variables, skip if unsure. +Optionally set project generation environment variables (see `gen-doc --help` and `gen-project --help`): ``` -export LINKML_COOKIECUTTER_GEN_DOC_ARGS=--no-mergeimports # custom arg -export LINKML_COOKIECUTTER_GEN_PROJECT_ARGS=--mergeimports # default arg +export LINKML_COOKIECUTTER_GEN_DOC_ARGS=--no-mergeimports # example +export LINKML_COOKIECUTTER_GEN_PROJECT_ARGS=--no-mergeimports # example ``` Change to the folder your generated project is in