Skip to content

Commit

Permalink
Move valuetype doc into own category
Browse files Browse the repository at this point in the history
  • Loading branch information
georg-schwarz committed Jul 27, 2023
1 parent 07bb669 commit 1d8b7ab
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 47 deletions.
2 changes: 0 additions & 2 deletions apps/docs/docs/user/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg
#
# SPDX-License-Identifier: AGPL-3.0-only

builtin-valuetypes.md
2 changes: 1 addition & 1 deletion apps/docs/docs/user/constraint-types/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Constraint Types",
"position": 4,
"position": 5,
"link": {
"type": "generated-index",
"description": "These constraints are shipped with Jayvee and are available right out of the box."
Expand Down
54 changes: 14 additions & 40 deletions apps/docs/docs/user/core-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,55 +81,29 @@ In the example above, the `url` property of type `text` is defined by the corres
A `ValueType` is the definition of a data type of the processed data.
Some `Blocks` use `ValueTypes` to define logic (like filtering or assessing the data type in a data sink).
We differentiate the following types of `ValueTypes`:
- `Built-in ValueTypes` come with the basic version of Jayvee. See [Built-in Valuetypes](./builtin-valuetypes).
- `Built-in ValueTypes` come with the basic version of Jayvee. See [Built-in Valuetypes](./valuetypes/builtin-valuetypes).
- `Primitive ValueTypes` can be defined by the user to model domain-specific data types and represent a single value.
`Constraints` can be added to a `Primitive ValueType` (see [below](#constraints)).
`Constraints` can be added to a `Primitive ValueType`.
See [Primitive Valuetypes](./valuetypes/primitive-valuetypes).
- `Compound ValueTypes`: UPCOMING.

### Constraints

`Constraints` for `ValueTypes` declare the validity criteria that each concrete value is checked against.

#### Syntax 1: Expression syntax

The syntax of expression-based `Constraints` uses an expression that evaluates to `true` or `false` for the given `value`. The type of the values the expression is working in is indicated ofter the keyword `on`:

```jayvee
valuetype GasFillLevel oftype integer {
constraints: [ GasFillLevelRange ];
}
constraint GasFillLevelRange on decimal:
value >= 0 and value <= 100;
```

Refer to the [Expression documentation](./expressions.md) for further reading on expressions.


#### Syntax 2: Block-like syntax

The syntax of `Constraints` is similar to the syntax of `Blocks`.
The availability of property keys and their respective `ValueTypes` is determined by the type of the `Constraint` - indicated by the identifier after the keyword `oftype`:
## Transforms
`Transforms` are used to transform data from one `ValueType` to a different one. For more details, see [Transforms](./transforms.md).

```jayvee
constraint GasFillLevelRange oftype RangeConstraint {
lowerBound: 0;
lowerBoundInclusive: true;
upperBound: 100;
upperBoundInclusive: true;
}
```

Note that the type of `Constraint` also determines its applicability to `ValueTypes`.
For instance, a `RangeConstraint` can only be applied to the numerical types `integer` and `decimal`.

### Primitive ValueTypes

`Primitive ValueTypes` are based on `Built-in ValueTypes` and use a collection of constraints to restrict the range of valid values.
Such constraints are implicitly connected via a logical `AND` relation.
Note that the `Constraints` need to be applicable to the base-type of the `ValueType` - indicated by the identifier after the keyword `oftype`:
transform CelsiusToKelvin {
from tempCelsius oftype decimal;
to tempKelvin oftype decimal;
```jayvee
valuetype GasFillLevel oftype integer {
constraints: [ GasFillLevelRange ];
tempKelvin: tempCelsius + 273.15;
}
```

### Transforms
`Transforms` are used to transform data from one `ValueType` to a different one. For more details, see [Transforms](./transforms.md)
```
2 changes: 1 addition & 1 deletion apps/docs/docs/user/expressions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 5
sidebar_position: 6
---

# Expressions
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/docs/user/runtime-parameters.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 5
sidebar_position: 8
---

# Runtime Parameters
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/docs/user/transforms.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 7
---

# Transforms
Expand Down
5 changes: 5 additions & 0 deletions apps/docs/docs/user/valuetypes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg
#
# SPDX-License-Identifier: AGPL-3.0-only

builtin-valuetypes.md
8 changes: 8 additions & 0 deletions apps/docs/docs/user/valuetypes/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Valuetypes",
"position": 4,
"link": {
"type": "generated-index",
"description": "Jayvee supports these different kinds of valuetypes."
}
}
3 changes: 3 additions & 0 deletions apps/docs/docs/user/valuetypes/_category_.json.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg

SPDX-License-Identifier: AGPL-3.0-only
3 changes: 3 additions & 0 deletions apps/docs/docs/user/valuetypes/primitive-valuetypes.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg

SPDX-License-Identifier: AGPL-3.0-only
48 changes: 48 additions & 0 deletions apps/docs/docs/user/valuetypes/primitive-valuetypes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
sidebar_position: 2
---
# Primitive ValueTypes

`Primitive ValueTypes` are based on `Built-in ValueTypes` and use a collection of constraints to restrict the range of valid values.
Such constraints are implicitly connected via a logical `AND` relation.
Note that the `Constraints` need to be applicable to the base-type of the `ValueType` - indicated by the identifier after the keyword `oftype`:

```jayvee
valuetype GasFillLevel oftype integer {
constraints: [ GasFillLevelRange ];
}
```


## Constraints

`Constraints` for `ValueTypes` declare the validity criteria that each concrete value is checked against.

### Syntax 1: Expression syntax

The syntax of expression-based `Constraints` uses an expression that evaluates to `true` or `false` for the given `value`. The type of the values the expression is working in is indicated ofter the keyword `on`:

```jayvee
constraint GasFillLevelRange on decimal:
value >= 0 and value <= 100;
```

Refer to the [Expression documentation](./expressions.md) for further reading on expressions.


### Syntax 2: Block-like syntax

The syntax of `Constraints` is similar to the syntax of `Blocks`.
The availability of property keys and their respective `ValueTypes` is determined by the type of the `Constraint` - indicated by the identifier after the keyword `oftype`:

```jayvee
constraint GasFillLevelRange oftype RangeConstraint {
lowerBound: 0;
lowerBoundInclusive: true;
upperBound: 100;
upperBoundInclusive: true;
}
```

Note that the type of `Constraint` also determines its applicability to `ValueTypes`.
For instance, a `RangeConstraint` can only be applied to the numerical types `integer` and `decimal`.
2 changes: 1 addition & 1 deletion apps/docs/generator/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function generateConstraintTypeDocs(rootPath: string): void {
}

function generateValueTypeDocs(rootPath: string): void {
const docsPath = join(rootPath, 'apps', 'docs', 'docs', 'user');
const docsPath = join(rootPath, 'apps', 'docs', 'docs', 'user', 'valuetypes');
const userDocBuilder = new UserDocGenerator();
const valueTypeDoc =
userDocBuilder.generateValueTypesDoc(PrimitiveValuetypes);
Expand Down
1 change: 1 addition & 0 deletions apps/docs/generator/src/user-doc-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ block ExampleTableInterpreter oftype TableInterpreter {

return builder.build();
}

generateBlockTypeDoc(metaInf: BlockMetaInformation): string {
const builder = new UserDocMarkdownBuilder()
.docTitle(metaInf.type)
Expand Down

0 comments on commit 1d8b7ab

Please sign in to comment.