From d40f795e6008bbaf874f51702e8c164da863fbd4 Mon Sep 17 00:00:00 2001 From: customcommander Date: Thu, 8 Apr 2021 22:14:30 +0000 Subject: [PATCH] doc: generate example.ris; a file with records of every types with every fields --- .gitignore | 5 +++-- Makefile | 3 +++ README.md | 8 ++++++++ doc/example.jq | 25 +++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 doc/example.jq diff --git a/.gitignore b/.gitignore index 6179b49..499a53b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +example.ris node_modules -yarn-error.log -out.txt \ No newline at end of file +out.txt +yarn-error.log \ No newline at end of file diff --git a/Makefile b/Makefile index 2fe3275..56d0e2f 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,9 @@ tag-map.csv: doc/tag.jq tag-map.json markdown-type: @jq -M -S -r -f doc/type.jq type-map.json | awk -F"," -f doc/type.awk +example.ris: doc/example.jq tag-map.json + @jq -M -S -r -f $^ | tee $@ + /tmp/ris.test: grammar.js index.js ris-parser.feature steps.js yarn cucumber-js --require steps.js ris-parser.feature touch $@ diff --git a/README.md b/README.md index 9f041fb..702f4ff 100644 --- a/README.md +++ b/README.md @@ -146,3 +146,11 @@ The following command will: ``` make sample ``` + +## example.ris + +The [example.ris](./example.ris) file contains one record (reference) of every type with every field: + +``` +make example.ris +``` diff --git a/doc/example.jq b/doc/example.jq new file mode 100644 index 0000000..5cd7d13 --- /dev/null +++ b/doc/example.jq @@ -0,0 +1,25 @@ +def type: split(".")[0]; # e.g. "VIDEO.A2" -> "VIDEO" +def field: split(".")[1]; # e.g. "VIDEO.A2" -> "A2" + +def type_record: "TY - \(.key | type)"; +def field_record: + (.key | field) as $f + | if $f == "A2" or $f == "A3" or $f == "A4" or $f == "AU" then + "\($f) - \(.key)_Doe, John" + elif $f == "PY" then + "\($f) - 1666" + elif $f == "DA" then + "\($f) - 1969/07/20" + elif $f == "RP" then + "\($f) - IN FILE" + else + "\($f) - \(.key)_\(.value)" + end; + + to_entries +| group_by(.key | type) +| map( .[0] as $first_entry + | map(field_record) + | "\($first_entry | type_record)\n\(. | join("\n"))\nER - " + ) +| join("\n\n") \ No newline at end of file