Skip to content

Commit

Permalink
Updated MRG construction, prepare for -d option, minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Rieks <[email protected]>
  • Loading branch information
RieksJ committed Sep 7, 2024
1 parent 0407367 commit bc0f128
Show file tree
Hide file tree
Showing 11 changed files with 432 additions and 204 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.swp
node_modules
build
docs/testdir

.docusaurus
.cache-loader
Expand Down
51 changes: 24 additions & 27 deletions docs/specs/files/90-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,17 @@ Parameters that can be used by most, if not all tools can be put both in tool-sp
| `scopedir: <path>` | Y | Path of the scope directory where the SAF is located. |
| `onNotExist: <action>` | n | The action in case something that is necessary for further processing didn't exist. |

The `<action>` parameter can take the following values.
<details>
<summary>`onNotExist` Actions</summary>

| `<action>` | Description |
| :--------- | :---------- |
| `'throw'` | An error is thrown (an exception is raised), and processing will stop. |
| `'warn'` | A message is displayed (and logged) and processing continues. |
| `'log'` | A message is written to a log(file) and processing continues. |
| `'ignore'` | Processing continues as if nothing happened. |
| `'throw'` | an error is thrown (an exception is raised), and processing will stop. |
| `'warn'` | a message is displayed (and logged) and processing continues. |
| `'log'` | a message is written to a log(file) and processing continues. |
| `'ignore'` | processing continues as if nothing happened. |

</details>

</TabItem>

Expand All @@ -103,16 +106,18 @@ Parameters that are specific to the [MRG Import tool](@) can be put in the YAML
| MRG Import Parameters | Req'd | Description |
| :---------------------- | :---: | :---------- |
| `onNotExist: <action>` | n | The action in case an MRG file unexpectedly does not exist. |
| `prune: <bool>` | n | If `<bool>` is `true`, remove all [MRG](@) files in the [glossarydir](@) where the scopetag is not administered in the [SAF](@). |

The `<action>` parameter can take the following values.
<details>
<summary>`onNotExist` Actions</summary>

| `<action>` | Description |
| :--------- | :---------- |
| `'throw'` | An error is thrown (an exception is raised), and processing will stop. |
| `'warn'` | A message is displayed (and logged) and processing continues. |
| `'log'` | A message is written to a log(file) and processing continues. |
| `'ignore'` | Processing continues as if nothing happened. |
| `'throw'` | an error is thrown (an exception is raised), and processing will stop. |
| `'warn'` | a message is displayed (and logged) and processing continues. |
| `'log'` | a message is written to a log(file) and processing continues. |
| `'ignore'` | processing continues as if nothing happened. |

</details>

</TabItem>

Expand All @@ -132,18 +137,19 @@ See https://github.com/tno-terminology-design/tev2-tools/issues/6
| `prune: <bool>` | n | If `<bool>` is `true`, remove all [MRG](@) files in the local scope from the [glossarydir](@) where the vsntag (or altvsntag) is not administered in the [SAF](@) |
-->

The `<action>` parameter can take the following values.
<details>
<summary>`onNotExist` Actions</summary>

| `<action>` | Description |
| :--------- | :---------- |
| `'throw'` | An error is thrown (an exception is raised), and processing will stop. |
| `'warn'` | A message is displayed (and logged) and processing continues. |
| `'log'` | A message is written to a log(file) and processing continues. |
| `'ignore'` | Processing continues as if nothing happened. |
| `'throw'` | an error is thrown (an exception is raised), and processing will stop. |
| `'warn'` | a message is displayed (and logged) and processing continues. |
| `'log'` | a message is written to a log(file) and processing continues. |
| `'ignore'` | processing continues as if nothing happened. |

The `<macromap>` parameter
</details>

The `<macromap>` parameter is a (YAML) list of [form phrase macros](@) (it is a [form phrase macro map(@)).
The `<macromap>` parameter is a (YAML) list of [form phrase macros](@) (it is a [form phrase macro map](@)).

Here is an example of the `mrgt` section of the config file that contains a [macro map](@).

Expand Down Expand Up @@ -177,15 +183,6 @@ Multiple [converters](@) can be specified, as `converter[1]`, `converter[2]`, et
All [converters](@) that are specified will be executed for every [MRG entry](@)
in the [MRG](@) for which the [HRG](@) is created.

The `<action>` parameter can take the following values.

| `<action>` | Description |
| :--------- | :---------- |
| `'throw'` | An error is thrown (an exception is raised), and processing will stop. |
| `'warn'` | A message is displayed (and logged) and processing continues. |
| `'log'` | A message is written to a log(file) and processing continues. |
| `'ignore'` | Processing continues as if nothing happened. |

</TabItem>

<TabItem value="trrt">
Expand Down
6 changes: 3 additions & 3 deletions docs/specs/syntax/62-term-selection.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ Take care to properly nest quotes (as in the 'rename' instruction of the example
| `"[ <f1>, <f2>, ... ]"` | Create an [MRG entry](@) from *every* [curated text](@) that [matches](form-phrase#matching@) any of the [form phrases](@) `<f<i>>`. |
| `"<key> [ <v1>, <v2>, ... ]"` | Create an [MRG entry](@) from every [curated text](@) that has a [header](@) with a field named `<key>`, and whose value matches any of the specified values `<v<i>>`.[^1] |

[^1]: 'matching' means that [<mark>TBD: specify the matching algorithm, in particular when the field itself is an arry, such as `grouptags`, `headingids`, etc.</mark>]
[^1]: 'matching' means that [<mark>TBD: specify the matching algorithm, in particular when the field itself is an array, such as `grouptags`, `headingids`, etc.</mark>].

:::tip Adding terms from other scopes
By adding `@<tid>` to any of the above instructions, you specify that the [MRG entries](@) that are to be selected must originate from the [terminology](@) that the [terminology identifier](@) `<tid>` identifies.
By adding a [terminology identifier](@) `@<tid>` to any of the above instructions, you specify that the [MRG entries](@) that are to be selected must originate from the [terminology](@) that this [terminology identifier](@) `<tid>` identifies.

The instruction `"[ party, actor ]@essif-lab"` will copy all [MRG entries](@) from the (default version) of the [MRG] as it exists in the [scope](@) `essif-lab`. Of course, `essif-lab` must be defined as a [scopetag](@) in one of the entries of the [scopes section](/docs/specs/files/saf#scopes) of the [SAF](@).
The instruction `"[ party, actor ]@essif-lab"` will copy all [MRG entries](@) from the (default version) of the [MRG](@) as it exists in the [scope](@) `essif-lab`. Of course, `essif-lab` must be defined as a [scopetag](@) in one of the entries of the [scopes section](/docs/specs/files/saf#scopes) of the [SAF](@).
:::

<details>
Expand Down
202 changes: 196 additions & 6 deletions docs/specs/syntax/81-handlebars-helper-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ The function of the helper `regularize` is convert human readable text into a [r
{{regularize entry.term}}
// Output: "ex-ample"
```

The helper `regularize` converts the input string into a [regularized text](@), according to the [regularization process](regularized-text#regularization-process@).

## `localize` {#localize}
Expand Down Expand Up @@ -221,11 +222,200 @@ The helper `localize` parses the value it was given as a URL and compares it to

## `ifValue` {#ifvalue}

The function of the helper `ifValue` is to test whether a text equals a specific value. This enables us to conditionally have particular texts (or leave such texts out).
The `ifValue` helper allows you to conditionally display text based on various comparisons. This can be useful for showing or hiding content depending on specific values, statuses, or other conditions.

<Tabs
defaultValue="equals"
values={[
{label: 'equals', value: 'equals'},
{label: 'notEqual', value: 'notEqual'},
{label: 'greaterThan', value: 'greaterThan'},
{label: 'greaterThanOrEqual', value: 'greaterThanOrEqual'},
{label: 'lessThan', value: 'lessThan'},
{label: 'lessThanOrEqual', value: 'lessThanOrEqual'},
{label: 'isNull', value: 'isNull'},
{label: 'isTruthy', value: 'isTruthy'},
{label: 'isFalsy', value: 'isFalsy'},
]}>

<TabItem value="equals">

### `equals`

The `equals` option checks if a value is strictly equal to a specified value. This is useful when you want to display content only if a field matches exactly with the expected value.

#### Example: Display a Warning for Deprecated Terms

If the status of a term is "deprecated," show a warning message.

```ts title="Example Usage of 'equals'"
{{#ifValue entry.status equals="deprecated"}}
**Warning**: this term is deprecated!
{{/ifValue}}
```

- **What This Does**: If `entry.status` is "deprecated", the warning text is displayed.

</TabItem>

<TabItem value="notEqual">

### `notEqual`

The `notEqual` option checks if a value is not equal to the specified value. This is useful for excluding content based on certain conditions.

#### Example: Exclude Active Terms

If a term's status is not "active," display a note.

```ts title="Example Usage of 'notEqual'"
{{#ifValue entry.status notEqual="active"}}
Note: This term is not currently active.
{{/ifValue}}
```

- **What This Does**: If `entry.status` is anything other than "active", the note is displayed.

</TabItem>

<TabItem value="greaterThan">

### `greaterThan`

The `greaterThan` option checks if a numeric value is greater than a specified number. This is useful for comparisons like age, quantity, etc.

#### Example: Age Check for Adults

Show a message if the age is greater than 18.

```ts title="Example Usage of 'greaterThan'"
{{#ifValue entry.age greaterThan=18}}
You are an adult.
{{/ifValue}}
```

- **What This Does**: If `entry.age` is greater than 18, the message "You are an adult." is displayed.

</TabItem>

<TabItem value="greaterThanOrEqual">

```ts title="Examples for 'ifValue'"
// Input (entry.status): "deprecated"
{{#ifValue entry.status equals="deprecated"}}**Warning**: this term is deprecated!{{/ifValue}}
// output: **Warning**: this term is deprecated!
### `greaterThanOrEqual`

The `greaterThanOrEqual` option checks if a numeric value is greater than or equal to a specified number.

#### Example: Age Check for Voting Eligibility

Show a message if the age is 18 or older.

```ts title="Example Usage of 'greaterThanOrEqual'"
{{#ifValue entry.age greaterThanOrEqual=18}}
You are eligible to vote.
{{/ifValue}}
```
This sequence outputs the text "**Warning**: this term is deprecated!" when the [MRG entry](@) had a `status` field whose value was `deprecated`.

- **What This Does**: If `entry.age` is 18 or more, the message "You are eligible to vote." is displayed.

</TabItem>

<TabItem value="lessThan">

### `lessThan`

The `lessThan` option checks if a numeric value is less than a specified number.

#### Example: Age Check for Minors

Show a message if the age is less than 18.

```ts title="Example Usage of 'lessThan'"
{{#ifValue entry.age lessThan=18}}
You are a minor.
{{/ifValue}}
```

- **What This Does**: If `entry.age` is less than 18, the message "You are a minor." is displayed.

</TabItem>

<TabItem value="lessThanOrEqual">

### `lessThanOrEqual`

The `lessThanOrEqual` option checks if a numeric value is less than or equal to a specified number.

#### Example: Age Check for Underage

Show a message if the age is 18 or less.

```ts title="Example Usage of 'lessThanOrEqual'"
{{#ifValue entry.age lessThanOrEqual=18}}
You are underage.
{{/ifValue}}
```

- **What This Does**: If `entry.age` is 18 or less, the message "You are underage." is displayed.

</TabItem>

<TabItem value="isNull">

### `isNull`

The `isNull` option checks if a value is `null` or `undefined`.

#### Example: Check if a Value is Null

Show a message if a term's description is missing.

```ts title="Example Usage of 'isNull'"
{{#ifValue entry.description isNull=true}}
No description available.
{{/ifValue}}
```

- **What This Does**: If `entry.description` is `null` or `undefined`, the message "No description available." is displayed.

</TabItem>

<TabItem value="isTruthy">

### `isTruthy`

The `isTruthy` option checks if a value is "truthy" (non-zero, non-null, non-empty string, etc.).

#### Example: Check if a Feature is Enabled

Show a message if a feature is enabled.

```ts title="Example Usage of 'isTruthy'"
{{#ifValue entry.isEnabled isTruthy=true}}
The feature is enabled.
{{/ifValue}}
```

- **What This Does**: If `entry.isEnabled` is "truthy", the message "The feature is enabled." is displayed.

</TabItem>

<TabItem value="isFalsy">

### `isFalsy`

The `isFalsy` option checks if a value is "falsy" (`0`, `null`, `undefined`, `""`, `false`, etc.).

#### Example: Check if a Feature is Disabled

Show a message if a feature is disabled.

```ts title="Example Usage of 'isFalsy'"
{{#ifValue entry.isEnabled isFalsy=true}}
The feature is disabled.
{{/ifValue}}
```

- **What This Does**: If `entry.isEnabled` is "falsy", the message "The feature is disabled." is displayed.

</TabItem>

</Tabs>
5 changes: 4 additions & 1 deletion docs/specs/tools/13-mrg-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ If a configuration file used, the long version of the parameter must be used (wi
| `-V`, `--version` | n | output the version number of the tool. |
| `-h`, `--help` | n | display help for command. |

The `<action>` parameter can take the following values:
<details>
<summary>`-e`, `--onNotExist` Actions</summary>

| `<action>` | Description |
| :--------- | :---------- |
Expand All @@ -99,6 +100,8 @@ The `<action>` parameter can take the following values:
| `'log'` | a message is written to a log(file) and processing continues. |
| `'ignore'` | processing continues as if nothing happened. |

</details>

## Running the Tool

The current version of the tool simply reads all [MRG](@) files from all [scopes](@) that are specifeid in the [SAF](@).
Expand Down
Loading

0 comments on commit bc0f128

Please sign in to comment.