Skip to content

Commit 9fbc1f1

Browse files
authored
Merge pull request #871 from GenomicsStandardsConsortium/standardize-linkml-and-yaml
YAML and LinkML auto-formatting and enumeration auto-describing
2 parents 93e9f66 + 9ef3e42 commit 9fbc1f1

File tree

4 files changed

+20373
-10
lines changed

4 files changed

+20373
-10
lines changed

.yamlfmt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
formatter:
2+
type: basic
3+
include_document_start: true
4+
max_line_length: 0

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,40 @@ examples/output: src/mixs/schema/mixs.yaml
8585
--output-directory $@ \
8686
--schema $< > $@/README.md
8787

88+
.PHONY: standardize-schema
89+
90+
# |\
91+
# yamlfmt -in -conf .yamlfmt >
92+
93+
standardize-schema:
94+
$(RUN) python src/scripts/describe_enums_by_slots_using.py \
95+
--schema_file src/mixs/schema/mixs.yaml \
96+
--output_file src/mixs/schema/mixs_with_enum_descriptions.yaml
97+
$(RUN) gen-linkml \
98+
--format yaml \
99+
--no-mergeimports \
100+
--no-materialize-attributes \
101+
--materialize-patterns src/mixs/schema/mixs_with_enum_descriptions.yaml |\
102+
yq eval '(.. | select(has("from_schema")) | .from_schema) style="" | del(.. | select(has("from_schema")).from_schema)' |\
103+
yq eval '.classes[] |= select(has("annotations")).annotations |= map_values(.value)' |\
104+
yq eval '.prefixes |= map_values(.prefix_reference)' |\
105+
yq eval '.settings |= map_values(.setting_value)' |\
106+
yq eval '.slots[] |= select(has("annotations")).annotations |= map_values(.value)' |\
107+
yq eval 'del(.classes.[].name)' |\
108+
yq eval 'del(.classes.[].slot_usage.[].name)' |\
109+
yq eval 'del(.enums.[].name)' |\
110+
yq eval 'del(.enums.[].permissible_values.[].text)' |\
111+
yq eval 'del(.slots.[].domain)' |\
112+
yq eval 'del(.slots.[].name)' |\
113+
yq eval 'del(.source_file)' |\
114+
yq eval 'del(.subsets.[].name)' | cat > src/mixs/schema/mixs_standardized.yaml
115+
mv src/mixs/schema/mixs_standardized.yaml src/mixs/schema/mixs.yaml
116+
rm -rf src/mixs/schema/mixs_standardized.yaml src/mixs/schema/mixs_with_enum_descriptions.yaml
117+
118+
test1:
119+
echo $$PATH
120+
yamlfmt -conf .yamlfmt src/mixs/schema/mixs.yaml > src/mixs/schema/mixs_standardized.yam
121+
88122
# Test documentation locally
89123
serve: mkd-serve
90124

0 commit comments

Comments
 (0)