Skip to content

Commit

Permalink
Label is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
iherman committed Dec 13, 2023
1 parent e39e64c commit 59049c2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The vocabulary is defined in a YAML file, which contains several block sequences
Each block sequence consists of blocks with the following keys:`id`, `property`, `value`, `label`, `upper_value`, `domain`, `range`, `deprecated`, `comment`, `status`, `defined_by`, and `see_also`. The interpretation of these key/value pairs may depend on the top level block where they reside, but some have a common interpretation.

- Common key/value pairs for the `class`, `property`, and `individual` blocks:
- `label` refers to a short header label to the term.
- `label` refers to a short header label to the term. If missing, the capitalized value of `id` is used.
- `comment` refers to a longer description of the term, and can be used for blocks in the `class`, `property` and `individual` top-level blocks. It may include [HTML Flow content elements](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories). The comment will be encapsulated into an HTML `<div>` element and will then be displayed verbatim in the HTML version of the vocabulary, and as a literal of type `rdf:HTML` in the JSON-LD and Turtle versions. Note that the Markdown syntax for simple formatting, like the use of "`" for `<code.../>`, may also be used.
- `defined_by` should be a URL, referring to the formal definition of the term.
- `see_also` refers to one or more blocks with `label` and `url` keys, providing a human readable title and a URL, respectively, to an external document that can be referred to by the description of the term. (These are translated into an `rdfs:seeAlso` term in the vocabulary.)
Expand Down
2 changes: 1 addition & 1 deletion lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export interface RawVocabEntry {
id : string;
property ?: string;
value ?: string;
label : string;
label ?: string;
upper_value ?: string[];
domain ?: string[];
range ?: string[];
Expand Down
11 changes: 10 additions & 1 deletion lib/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,20 @@ function finalizeRawEntry(raw: RawVocabEntry): RawVocabEntry {
}
})();

const label = ((str: string|undefined): string => {
if (str) {
return str;
} else if (raw.id && raw.id.length > 0) {
return raw.id[0].toLocaleUpperCase() + raw.id.substring(1);
} else {
return ""
}
})(raw.label);
return {
id : (raw.id) ? raw.id : "",
property : raw.property,
value : raw.value,
label : (raw.label) ? raw.label : "",
label : label,
upper_value : toArray(raw.upper_value),
domain : toArray(raw.domain),
range : toArray(raw.range),
Expand Down
3 changes: 1 addition & 2 deletions lib/vocab.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@
}
},
"required": [
"id",
"label"
"id"
],
"anyOf": [
{ "required": ["comment"] },
Expand Down

0 comments on commit 59049c2

Please sign in to comment.