You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-26Lines changed: 25 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,9 +24,8 @@ Each block sequence consists of blocks with the following keys:`id`, `property`,
24
24
- The `context` key refers to list of URLs or two special keywords. It is used to add information on JSON-LD `@context` file(s) that "mention" the term; the list of URLs refer to the relevant `@context` file. If the value is `vocab`, and a global `@context` file is defined in the `vocab` block, that "default" `@context` is used. Finally, if the value of the property is `none`, there is no context file reference for the term. The default setting is `vocab` (i.e., unless it is otherwise specified, the default value is used for the term).
25
25
- The `example` key refers to on or more blocks with `label` and `json` keys, providing a (JSON) example with a title. These examples are placed, in the HTML version, to the end of the section referring to a term (the examples are ignored in the Turtle and the JSON-LD versions). Care should be taken to use the `"|"`[block style indicator](https://yaml-multiline.info) in the YAML file for the examples.
26
26
27
-
28
27
- Top level blocks:
29
-
-`vocab`: a block with the `id` and the `value` keys defining the prefix and the URL of the vocabulary, respectively. The `id` provides a prefix that can be used in the vocabulary descriptions, e.g., for cross-references. The additional, optional `context` key may provide a default context file reference (as a URI), used by all terms unless locally overwritten (see above).
28
+
-`vocab`: a block with the `id` and the `value` keys defining the prefix and the URL of the vocabulary, respectively. The `id` provides a prefix that can be used in the vocabulary descriptions, e.g., for cross-references. The additional, optional `context` key may provide a default context file reference (as a URI), used by all terms unless locally overwritten (see above). Note that the `context` key is required if the HTML template includes a context section.
30
29
31
30
-`prefix`: definition of a prefixes, and corresponding URLs, for each external vocabulary in use, defined by the `id` and `value` keys, respectively.
32
31
@@ -64,7 +63,6 @@ External terms, while they appear in the HTML document generated by the tool, do
64
63
65
64
The prefix part of the curie _must_ be defined through the `prefix` top level block.
66
65
67
-
68
66
## Installation and use
69
67
70
68
The script is in TypeScript (version 5.0.2 and beyond) running on top of [`node.js`](https://nodejs.org) (version 21 and beyond). It can also run with [`deno`](http://deno.land) (version 2.1 and beyond).
@@ -82,15 +80,35 @@ npm install yml2vocab
82
80
83
81
#### Running on a command line
84
82
83
+
##### NPM/Node.js
84
+
85
85
The npm installation installs the `node_modules/.bin/yml2vocab` script. The script can be used as:
Running this script generates the `vocab_file_name.ttl`, `vocab_file_name.jsonld`, and `vocab_file_name.html` files for the Turtle, JSON-LD, and HTML+RDFa versions, respectively. The script relies on the `vocab_file_name.yml` file for the vocabulary specification in YAML and a `template_file_name` file for a template file. The defaults are `vocabulary` and `template.html`, respectively.
91
+
##### Deno
92
+
93
+
If `deno` is installed globally, one can also run the script directly (without any further installation) by
in the top level. To make it simpler, a binary, compiled version of the program can be generated by
92
100
93
-
If the `-c` flag is also set, the additional `vocab_file_name_context.jsonld` is also generated, containing a simple `@context` structure that can be used as a separate `@context` file or embedded in a JSON file. Note that this is a "minimal" JSON-LD file, which does not necessarily use all the sophistication that JSON-LD [defines](https://www.w3.org/TR/json-ld11/#the-context) for `@context`; these may have to be added manually.
which results in an executable file, called `yml2vocab`, that can be stored anywhere in the user's `$PATH`.
106
+
107
+
#### Command line argument
108
+
109
+
The script generates the `vocab_file_name.ttl`, `vocab_file_name.jsonld`, and `vocab_file_name.html` files for the Turtle, JSON-LD, and HTML+RDFa versions, respectively. The script relies on the `vocab_file_name.yml` file for the vocabulary specification in YAML and a `template_file_name` file for a template file. The defaults are `vocabulary` and `template.html`, respectively.
110
+
111
+
If the `-c` flag is also set, the additional `vocab_file_name.context.jsonld` is also generated, containing a JSON-LD file that can be used as a separate `@context` reference in a JSON-LD file. Note that this JSON-LD file does not necessarily use all the sophistication that JSON-LD [defines](https://www.w3.org/TR/json-ld11/#the-context) for `@context`; these may have to be added manually.
94
112
95
113
#### Running from a Javascript/TypeScript program
96
114
@@ -128,26 +146,7 @@ There is no need to install any extra typing, it is included in the package. The
128
146
129
147
### Cloning the repository
130
148
131
-
The [repository](https://github.com/yml2vocab) may also be cloned. For a complete installation:
132
-
133
-
1. If necessary, install [`node.js`](https://nodejs.org/) on your local machine. Installation of `node.js` should automatically install the [`npm`](https://www.npmjs.com) package manager.
134
-
2. Clone the repository (i.e., https://github.com/w3c/yml2vocab/) to your local machine.
135
-
3. In the directory of the repository clone, run `npm install` on the command line. This installs all the necessary packages in the `node_modules` subdirectory.
136
-
4. Create a directory for the vocabulary definition; this should include
137
-
1. A `vocabulary.yml` file. You can start with the YAML file in the `example` directory of the repository, and change the cells for your vocabulary.
138
-
2. A `template.html` file. You can start with the HTML file in the `example` directory of the repository, and adapt/change it as you wish.
139
-
5. Run the `main.ts` file in the directory vocabulary definition. This generates the `vocabulary.ttl`, `vocabulary.jsonld`, and `vocabulary.html` files for, respectively, the Turtle, JSON-LD, and HTML representations.
140
-
141
-
"Running" may be done in three different ways:
142
-
143
-
1. Run, via `node`, the file `dist/main.js` of the repository
144
-
2. Run, via `node_modules/.bin/ts-node`, the file `main.ts` of the repository
145
-
3. Run, via `deno run`, the file `main.ts` or the repository
146
-
4. Alternatively, an executable file can be generated via `deno task compile` in the repository, which can then be put to the user's `$PATH`.
147
-
148
-
Alternative (2) or (3) is preferred
149
-
150
-
The script also accepts a single argument to be used instead of `vocabulary` to name the various files (see above).
149
+
The [repository](https://github.com/yml2vocab) may also be cloned.
151
150
152
151
#### Content of the directory
153
152
@@ -169,6 +168,6 @@ The following files and directories are generated/modified by either the script
169
168
170
169
## Acknowledgement
171
170
172
-
The original idea, structure, and script (in Ruby) was created by Gregg Kellogg for v1 of the Credentials Vocabulary and with a vocabulary definition using CSV. The CSV definitions have been changed to YAML, and the script itself has been re-written in TypeScript (and developed further since).
171
+
The original idea, structure, and script (in Ruby) was created by Gregg Kellogg for v1 of the Credentials Vocabulary and with a vocabulary definition using CSV. The CSV definitions have been changed to YAML, and the script itself has been re-written in TypeScript, and developed further since.
173
172
174
173
Many features are the result of further discussions with Many Sporny and Benjamin Young.
0 commit comments