Skip to content

Commit

Permalink
Fix several issues in justfile recipes
Browse files Browse the repository at this point in the history
- lint all schema files not just main #71
- java build #70
- clean up docs/elements before genearting docs #66
- clean up examples/output as part of "just test"
- skip generated files when running codespell or typos
  • Loading branch information
dalito committed Mar 2, 2025
1 parent c249479 commit 2a33ffd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion template/config.public.mk.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
LINKML_SCHEMA_NAME="{{project_slug}}"
LINKML_SCHEMA_AUTHOR="{{author}}"
LINKML_SCHEMA_DESCRIPTION="{{project_description}}"
LINKML_SCHEMA_SOURCE_PATH="src/{{project_slug}}/schema/{{project_slug}}.yaml"
LINKML_SCHEMA_SOURCE_DIR="src/{{project_slug}}/schema"

###### linkml generator variables, used by justfile

Expand Down
8 changes: 5 additions & 3 deletions template/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ generator_args:
directory: "docs/elements"
graphql:
mergeimports: true
java:
mergeimports: true
metadata: true
# gen-java is not yet supported by gen-project.
# https://github.com/linkml/linkml/issues/2537
# java:
# mergeimports: true
# metadata: true
jsonld:
mergeimports: true
jsonschema:
Expand Down
15 changes: 8 additions & 7 deletions template/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ shebang := if os() == 'windows' {
}

# Environment variables with defaults
schema_name := env_var_or_default("LINKML_SCHEMA_NAME", "")
source_schema_path := env_var_or_default("LINKML_SCHEMA_SOURCE_PATH", "")
schema_name := env_var_or_default("LINKML_SCHEMA_NAME", "_no_schema_given_")
source_schema_dir := env_var_or_default("LINKML_SCHEMA_SOURCE_DIR", "")
config_yaml := if env_var_or_default("LINKML_GENERATORS_CONFIG_YAML", "") != "" {
"--config-file " + env_var_or_default("LINKML_GENERATORS_CONFIG_YAML", "")
} else {
Expand All @@ -36,6 +36,7 @@ gen_ts_args := env_var_or_default("LINKML_GENERATORS_TYPESCRIPT_ARGS", "")
src := "src"
dest := "project"
pymodel := src / schema_name / "datamodel"
source_schema_path := source_schema_dir / schema_name + ".yaml"
docdir := "docs/elements" # Directory for generated documentation

# ============== Project recipes ==============
Expand Down Expand Up @@ -88,11 +89,12 @@ test: _test-schema _test-python _test-examples
# Run linting
[group('model development')]
lint:
poetry run linkml-lint {{source_schema_path}}
poetry run linkml-lint {{source_schema_dir}}

# Generate md documentation for the schema
[group('model development')]
gen-doc:
rm -rf {{docdir}}/*.md
poetry run gen-doc {{gen_doc_args}} -d {{docdir}} {{source_schema_path}}

# Build docs and run test server
Expand All @@ -110,9 +112,7 @@ gen-project:
poetry run gen-project {{config_yaml}} -d {{dest}} {{source_schema_path}}
mv {{dest}}/*.py {{pymodel}}
poetry run gen-pydantic {{gen_pydantic_args}} {{source_schema_path}} > {{pymodel}}/{{schema_name}}_pydantic.py
@if [ ! ${{gen_java_args}} ]; then \
poetry run gen-java {{gen_java_args}} --output-directory {{dest}}/java/ {{source_schema_path}} || true ; \
fi
poetry run gen-java {{gen_java_args}} --output-directory {{dest}}/java/ {{source_schema_path}}
@if [ ! ${{gen_owl_args}} ]; then \
mkdir -p {{dest}}/owl && \
poetry run gen-owl {{gen_owl_args}} {{source_schema_path}} > {{dest}}/owl/{{schema_name}}.owl.ttl || true ; \
Expand Down Expand Up @@ -233,8 +233,9 @@ _clean_project:
else:
d.unlink()

_ensure_examples_output:
_ensure_examples_output: # Ensure a clean examples/output directory exists
-mkdir -p examples/output
-rm -rf examples/output/*.*

# ============== Include project-specific recipes ==============

Expand Down
12 changes: 11 additions & 1 deletion template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ mknotebooks = ">= 0.8.0"

# Ref.: https://github.com/codespell-project/codespell
[tool.codespell]
skip = "LICENSE,poetry.lock,pyproject.toml"
skip = [
"LICENSE",
"pyproject.toml",
"poetry.lock",
"project/*",
"src/{{project_slug}}/datamodel/{{project_slug}}_pydantic.py",
"src/{{project_slug}}/datamodel/{{project_slug}}.py",
]

# Reminder: words have to be lowercased for the ignore-words-list
ignore-words-list = "linke"
Expand All @@ -59,4 +66,7 @@ extend-exclude = [
"LICENSE",
"poetry.lock",
"pyproject.toml",
"project/*",
"src/{{project_slug}}/datamodel/{{project_slug}}_pydantic.py",
"src/{{project_slug}}/datamodel/{{project_slug}}.py",
]

0 comments on commit 2a33ffd

Please sign in to comment.