Skip to content

Commit

Permalink
Attempt to integrate Spec-Up term references
Browse files Browse the repository at this point in the history
Signed-off-by: Rieks <[email protected]>
  • Loading branch information
RieksJ committed Apr 24, 2024
1 parent 17f2447 commit d0e2e60
Show file tree
Hide file tree
Showing 11 changed files with 474 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
mrgt -c tev2-config.yaml
hrgt -f -c tev2-config.yaml
trrt -f -c tev2-config.yaml
trrt -f -c tev2-config-specup.yaml
# Commit generated MRGs to repo, so other projects can use (import) them
- name: Commit MRGs to repository
Expand Down
83 changes: 83 additions & 0 deletions docs/how-to/spec-up-term-references.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: Using Spec-Up Term References
---

# Spec-Up Term References Integration

[TEv2](@tev2) allows customization of the syntax that authors use for [TermRefs](@tev2). In this page, we show what it takes to use the syntax as [defined by Spec-Up](https://identity.foundation/spec-up/), which is a tool that aims to facilitate the writing of technical specifications aimed at standards bodies or industry groups.

## Background: Spec-Up Syntax for Term References

The [Spec-Up syntax for (regular) term references](https://github.com/decentralized-identity/spec-up/blob/master/single-file-test/spec.md#term-references) consists of [[ref: Spec-Up definitions]] (located in a so-called [definition list](https://github.com/decentralized-identity/spec-up/blob/master/single-file-test/spec.md#definition-lists)), and [[ref: Spec-Up term references]], that can be used to refer to such definitions.

Recently, Spec-Up introduced a [syntax for external term references](https://github.com/decentralized-identity/spec-up/blob/master/single-file-test/spec.md#external-term-references), that uses new feature called [[ref: XRefs]]. This feature allows authors to refer to terms that are defined in the text they are writing themselves, but in a text that is curated elsewhere.

## Requirements for using Spec-Up syntax by TEv2 tools

In this [MVE](@), we only support the Spec-Up syntax for [[ref: term references]] and [[ref: XRefs]]. This means that

- we do not use [[ref: Spec-Up definitions]] or [definition lists](https://github.com/decentralized-identity/spec-up/blob/master/single-file-test/spec.md#definition-lists)).
- we use [TEv2 machine readable glossaries](mrg@tev2) to find the definitions of terms that are being referred to.
- [[ref: Spec-Up term references]] are resolved using the default [terminology](@tev2) of the [current scope](@tev2).
- [[ref: Spec-Up XRefs]] are resolved in a similar fashion, using the `{title}` part as a [scopetag](@tev2).

## The TRRT Interpreter for Spec-Up Term References

In order to use Spec-Up [[ref: term references]] and [[ref: XRefs]], we need to write a [TEv2 interpreter](interpreter@tev2) that recognizes them. This can be done by mapping the `{term}` and `{title}` fields of the Spec-Up references to the [named capturing groups](@tev2) specified in the [interpreter profile of the TRRT](trrt#interpreter-profile@tev2), as follows:

| Spec-Up syntax | TEv2 equivalent | Comments |
| -------------- | --------------- | -------- |
| `[[ref: {term}]]` | `[{term}](@)` | A Spec-Up `{term}` maps onto the `showtext` capturing group of a [TEv2 TermRef](term-ref@tev2). |
| `[[xref: {title}, {term}]]` | `[{term}](@{title})` | A Spec-Up `{title}` maps onto the `scopetag` captruing group of a [TEv2 TermRef](term-ref@tev2). |

This leads to the [following regex](https://www.debuggex.com/r/I1gqkMGPKMs9dfeE):

```regex
(?:(?<=[^`])|^)\[\[(?:xref:\s*(?<scopetag>[a-z0-9_-]+),|ref:)\s*(?<showtext>[^\n\],]+)\]\]
```

## Notes:

When applying the regex in a YAML file (e.g. a [TEv2 configuration file](config-file@tev2)), the escape character `\` must be escaped. So the `trrt` section would read as follows:

```yaml
trrt:
interpreter: "(?:(?<=[^`])|^)\\[\\[(?:xref:\\s*(?<scopetag>[a-z0-9_-]+),|ref:)\\s*(?<showtext>[^\n\\],]+)\\]\\]"
converter: html-hovertext-link # style in which TermRefs are to be rendered - change as you like
input: # glob pattern for files to be processed - adjust as necessary
- "**/*.md"
```
If a [[ref: Spec-Up term reference]] or a [[ref: Spec-Up XRef]] are to be rendered in a different way, that means that the [TRRT](@tev2) must be called using another, appropriate [converter](@tev2) (either a [predefined one](trrt#predefined-converters@tev2), or a [customized one](trrt#converter-customization@tev2)).
The following text (below the horizontal line) is a literal quote from the Spec-Up single-file-test spec.md file, showing that [[ref: Spec Up definitions]] are untouched, whereas [[ref: Spec-Up term references]] are converted as we would expect them to.
Note that the [[ref: term references]] for `Term 1`, `Term 2` and `Term 3` will actually work. That is NOT because the [[ref: definitions]] are processed, but because they are defined as [curated texts](@tev2), and therefor they end up in the [TEv2 MRG](mrg@tev2) that is used to dereference them.

-----

### Definition Lists

Many specs may want to include a section for terminology references, and Definition Lists are a great way to do that. Here's how to leverage Spec-Up's automatic term reference features via Definition List markup:

<pre>
[[def: Term 1, Term One]]:
~ This is the first term we will define.

[[def: Term 2, Term Two]]:
~ This is the second term, but not the last.

[[def: Term 3, Term Three]]:
~ This is the last term, because you know what they say: third term's the charm!
</pre>

[[def: Term 1, Term One]]:
~ This is the first term we will define.

[[def: Term 2, Term Two]]:
~ This is the second term, but not the last.

[[def: Term 3, Term Three]]:
~ This is the last term, because you know what they say: third term's the charm!

Now let's refer to some of the terms defined above to show how the auto-linking of terms works: [[ref: Term 1]], [[ref: Term Two]], [[ref: Term 3]]. Additionally, as long as you define your terms using Definition Lists (as seen in the markdown above), you will be able to hover any reference to a term to see a tooltip with its definition.
119 changes: 119 additions & 0 deletions docs/mrgs/mrg.mve.mve-terms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,125 @@ entries:
- "example"
termid: "concept:mve"
vsntag: "mve-terms"
- term: "spec-up-definition"
glossaryTerm: "Definition (Spec-Up style)"
glossaryText: "a construct of the form `[[def: {term}, {alias1}, {alias2}, ... ]] ~ {definition}`, which specifies the mapping between the term `{term}` and a description of the term's meaning (provided by `{definition}`."
glossaryNotes:
- "`{alias1}, {alias2}, ...` is optional syntax that specifies aliases (synomyms) for `{term}`."
- "In [TEv2](@tev2), `{term}` and its aliases would be specified as [form phrases](@tev2)."
- "A recent addition is the use of so-called [[ref: XRefs]], which allows definitions to be used across diffrent files and projects."
formPhrases:
- "spec-up-definition"
- "definition"
- "definitions"
- "definition-s"
- "spec-up-definitions"
- "spec-up-definition-s"
scopetag: "mve"
locator: "spec-up-definition.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/spec-up-definition"
headingids:
- "definition-(spec-up-style)"
- "how-spec-up-uses-definitions-and-term-references"
- "tev2-does-not-use-spec-up-definitions"
- "notes"
termid: "concept:spec-up-definition"
vsntag: "mve-terms"
- term: "spec-up-term-reference"
glossaryTerm: "Term Reference (Spec-Up style)"
glossaryText: "a construct of the form `[[ref: {term}]]`, where `{term}` is (an alias of some) term defined in a [[ref: Spec-Up definition]]."
formPhrases:
- "spec-up-term-reference"
- "term-reference"
- "term-references"
- "term-reference-s"
- "spec-up-term-references"
- "spec-up-term-reference-s"
- "term-reference-spec-up-style"
- "term-references-spec-up-style"
- "term-reference-s-spec-up-style"
- "term-reference-specup-style"
- "term-references-specup-style"
- "term-reference-s-specup-style"
glossaryNotes:
- "In the traditional Spec-Up context, such [[ref: definitions]] would reside in the [definition list](https://github.com/decentralized-identity/spec-up/blob/master/single-file-test/spec.md#definition-lists) of the file in which the [[ref: term reference]] is used. - "
You should use [[ref: "XRefs]] to refer to terms that are defined elsewhere.\""
scopetag: "mve"
locator: "spec-up-term-reference.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/spec-up-term-reference"
headingids:
- "spec-up-term-references"
- "notes"
termid: "concept:spec-up-term-reference"
vsntag: "mve-terms"
- term: "spec-up-xref"
glossaryTerm: "XRef (Spec-Up style)"
glossaryText: "a construct of the form `[[xref: {title} {term}]]`, where `{title}` is a tag that identifies the source of the [[ref: definition]] that defines `{term}`."
glossaryNotes:
- "The `{title}` tags are defined [to be described, link to actual specs thereof]."
- "When an XRef is processed by a [TEv2 tool](@tev2), `{title}` is treated as the equivalent of a [scopetag](@tev2) and/or the default [terminology](@tev2) in the associated [scope](@tev2)."
formPhrases:
- "spec-up-xref"
- "xref"
- "xrefs"
- "xref-s"
- "spec-up-xrefs"
- "spec-up-xref-s"
scopetag: "mve"
locator: "spec-up-xref.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/spec-up-xref"
headingids:
- "spec-up-xrefs"
termid: "concept:spec-up-xref"
vsntag: "mve-terms"
- term: "term-1"
glossaryTerm: "Term 1"
glossaryText: "This is the first term we will define."
formPhrases:
- "term-1"
- "term-one"
glossaryNotes:
- "Like [[ref: Term Two]] and [[ref: Term 3]], this term is defined for illustration purposes only."
scopetag: "mve"
locator: "term-1.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/term-1"
headingids:
- "term-1"
- "notes"
termid: "concept:term-1"
vsntag: "mve-terms"
- term: "term-2"
glossaryTerm: "Term 2"
glossaryText: "This is the second term, but not the last."
formPhrases:
- "term-2"
- "term-two"
glossaryNotes:
- "Like [[ref: Term One]] and [[ref: Term 3]], this term is defined for illustration purposes only."
scopetag: "mve"
locator: "term-2.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/term-2"
headingids:
- "term-2"
- "notes"
termid: "concept:term-2"
vsntag: "mve-terms"
- term: "term-3"
glossaryTerm: "Term 3"
glossaryText: "This is the last term, because you know what they say: third term's the charm!"
formPhrases:
- "term-3"
- "term-three"
glossaryNotes:
- "Like [[ref: Term 1]] and [[ref: Term Two]], this term is defined for illustration purposes only."
scopetag: "mve"
locator: "term-3.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/term-3"
headingids:
- "term-3"
- "notes"
termid: "concept:term-3"
vsntag: "mve-terms"
- title: "Workflow File"
term: "workflow-file"
glossaryTerm: "Workflow file"
Expand Down
119 changes: 119 additions & 0 deletions docs/mrgs/mrg.mve.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,125 @@ entries:
- "example"
termid: "concept:mve"
vsntag: "mve-terms"
- term: "spec-up-definition"
glossaryTerm: "Definition (Spec-Up style)"
glossaryText: "a construct of the form `[[def: {term}, {alias1}, {alias2}, ... ]] ~ {definition}`, which specifies the mapping between the term `{term}` and a description of the term's meaning (provided by `{definition}`."
glossaryNotes:
- "`{alias1}, {alias2}, ...` is optional syntax that specifies aliases (synomyms) for `{term}`."
- "In [TEv2](@tev2), `{term}` and its aliases would be specified as [form phrases](@tev2)."
- "A recent addition is the use of so-called [[ref: XRefs]], which allows definitions to be used across diffrent files and projects."
formPhrases:
- "spec-up-definition"
- "definition"
- "definitions"
- "definition-s"
- "spec-up-definitions"
- "spec-up-definition-s"
scopetag: "mve"
locator: "spec-up-definition.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/spec-up-definition"
headingids:
- "definition-(spec-up-style)"
- "how-spec-up-uses-definitions-and-term-references"
- "tev2-does-not-use-spec-up-definitions"
- "notes"
termid: "concept:spec-up-definition"
vsntag: "mve-terms"
- term: "spec-up-term-reference"
glossaryTerm: "Term Reference (Spec-Up style)"
glossaryText: "a construct of the form `[[ref: {term}]]`, where `{term}` is (an alias of some) term defined in a [[ref: Spec-Up definition]]."
formPhrases:
- "spec-up-term-reference"
- "term-reference"
- "term-references"
- "term-reference-s"
- "spec-up-term-references"
- "spec-up-term-reference-s"
- "term-reference-spec-up-style"
- "term-references-spec-up-style"
- "term-reference-s-spec-up-style"
- "term-reference-specup-style"
- "term-references-specup-style"
- "term-reference-s-specup-style"
glossaryNotes:
- "In the traditional Spec-Up context, such [[ref: definitions]] would reside in the [definition list](https://github.com/decentralized-identity/spec-up/blob/master/single-file-test/spec.md#definition-lists) of the file in which the [[ref: term reference]] is used. - "
You should use [[ref: "XRefs]] to refer to terms that are defined elsewhere.\""
scopetag: "mve"
locator: "spec-up-term-reference.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/spec-up-term-reference"
headingids:
- "spec-up-term-references"
- "notes"
termid: "concept:spec-up-term-reference"
vsntag: "mve-terms"
- term: "spec-up-xref"
glossaryTerm: "XRef (Spec-Up style)"
glossaryText: "a construct of the form `[[xref: {title} {term}]]`, where `{title}` is a tag that identifies the source of the [[ref: definition]] that defines `{term}`."
glossaryNotes:
- "The `{title}` tags are defined [to be described, link to actual specs thereof]."
- "When an XRef is processed by a [TEv2 tool](@tev2), `{title}` is treated as the equivalent of a [scopetag](@tev2) and/or the default [terminology](@tev2) in the associated [scope](@tev2)."
formPhrases:
- "spec-up-xref"
- "xref"
- "xrefs"
- "xref-s"
- "spec-up-xrefs"
- "spec-up-xref-s"
scopetag: "mve"
locator: "spec-up-xref.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/spec-up-xref"
headingids:
- "spec-up-xrefs"
termid: "concept:spec-up-xref"
vsntag: "mve-terms"
- term: "term-1"
glossaryTerm: "Term 1"
glossaryText: "This is the first term we will define."
formPhrases:
- "term-1"
- "term-one"
glossaryNotes:
- "Like [[ref: Term Two]] and [[ref: Term 3]], this term is defined for illustration purposes only."
scopetag: "mve"
locator: "term-1.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/term-1"
headingids:
- "term-1"
- "notes"
termid: "concept:term-1"
vsntag: "mve-terms"
- term: "term-2"
glossaryTerm: "Term 2"
glossaryText: "This is the second term, but not the last."
formPhrases:
- "term-2"
- "term-two"
glossaryNotes:
- "Like [[ref: Term One]] and [[ref: Term 3]], this term is defined for illustration purposes only."
scopetag: "mve"
locator: "term-2.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/term-2"
headingids:
- "term-2"
- "notes"
termid: "concept:term-2"
vsntag: "mve-terms"
- term: "term-3"
glossaryTerm: "Term 3"
glossaryText: "This is the last term, because you know what they say: third term's the charm!"
formPhrases:
- "term-3"
- "term-three"
glossaryNotes:
- "Like [[ref: Term 1]] and [[ref: Term Two]], this term is defined for illustration purposes only."
scopetag: "mve"
locator: "term-3.md"
navurl: "https://tno-terminology-design.github.io/tev2-mve/terms/term-3"
headingids:
- "term-3"
- "notes"
termid: "concept:term-3"
vsntag: "mve-terms"
- title: "Workflow File"
term: "workflow-file"
glossaryTerm: "Workflow file"
Expand Down
46 changes: 46 additions & 0 deletions docs/terms/spec-up-definition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
# Front matter for TEv2 Curated Texts
term: spec-up-definition
glossaryTerm: "Definition (Spec-Up style)"
glossaryText: "a construct of the form `[[def: {term}, {alias1}, {alias2}, ... ]] ~ {definition}`, which specifies the mapping between the term `{term}` and a description of the term's meaning (provided by `{definition}`."
glossaryNotes:
- "`{alias1}, {alias2}, ...` is optional syntax that specifies aliases (synomyms) for `{term}`."
- "In [TEv2](@tev2), `{term}` and its aliases would be specified as [form phrases](@tev2)."
- "A recent addition is the use of so-called [[ref: XRefs]], which allows definitions to be used across diffrent files and projects."
formPhrases: [ "definition{ss}", "spec-up definition{ss}" ]
---

# Definition (Spec-Up style)

A [[ref: Spec-Up Definition]] is a construct of the form `[[def: {term}, {term alias}, ... ]] ~ {definition}`, where

- `{definition}` is a descrition of the meaning of term `{term}`, and
- `{term alias}, ...` is a (comma separated) list of words or phrases that are considered to have the same meaning as `{term}`. They are not necessarily synonyms, but are typically what [TEv2](@tev2) would call [form phrases](@tev2).

## How Spec-Up uses Definitions and Term References

In [Spec-Up's](https://identity.foundation/spec-up/) way of thinking, a specification file contains:

1. a [definition list](https://github.com/decentralized-identity/spec-up/blob/master/single-file-test/spec.md#definition-lists), which contains all [[ref: definitions]] used within the file. It typically sits somewhere at the beginning of the specification file.
2. [[ref: term references]], whose `{term}` part is one of the `{term}`s (or aliases) in a [[ref: definition]].

An example of this is given in the [single-file-test/spec.md file](https://github.com/decentralized-identity/spec-up/blob/master/single-file-test/spec.md#definition-lists) in the [Spec-Up Github repo](https://github.com/decentralized-identity/spec-up/tree/master/).

## TEv2 does NOT use Spec-Up Definitions

The reason for this is that such [[ref: definitions]] only provide the very minimal things that, in the [TEv2](@tev2) vision, people would want to do with them.

The most obvious features that TEv2 provides that are not facilitated by [[ref: Spec-Up definitions]] are:

- the generation of a wide variety of (human readable) glossaries from the [[ref: definitions]];
- generating (persistent) links to the documentation pages of terms;
- extending terminology-features without changing the underlying (programming) code.

## Notes

Terms can still be defined and curated in various ways, but that does require that the curated texts that define terms (regardless of they are [[ref: spec-up definitions]] or specified in another way, e.g., as Wiki pages), are somehow converted in either

- a [TEv2-style machine readable glossary](mrg@tev2), so that [[ref: term references]] can be resolved using the [TEv2 TRRT tool](trrt@tev2), regardless of they are [[ref: Spec-Up term references]] or [TEv2 TermRefs](term-ref@tev2), or
- a set of [TEv2-style curated texts](curated-text@tev2), which can be processed by the [TEv2 MRGT tool](mrgt@tev2) to create such a [TEv2-style machine readable glossary](mrg@tev2).


Loading

0 comments on commit d0e2e60

Please sign in to comment.