Skip to content

Commit 6e5ed2d

Browse files
committed
Add CONFIGURATION.md
1 parent 200bc71 commit 6e5ed2d

File tree

3 files changed

+151
-16
lines changed

3 files changed

+151
-16
lines changed

CONFIGURATION.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
2+
## Enum
3+
4+
- [ELScalar](#elscalar)
5+
6+
### ELScalar
7+
8+
9+
10+
| Property | Type | Description |
11+
| ---------- | ---------- | ---------- |
12+
| `Bool` | `'bool'` | Equivalent to PHP `bool` |
13+
| `Number` | `'number'` | Equivalent to PHP `int` or `float` |
14+
| `String` | `'string'` | Equivalent to PHP `string` |
15+
| `Null` | `'null'` | Equivalent to PHP `null` |
16+
| `Any` | `'any'` | Equivalent to PHP `mixed` |
17+
18+
19+
## Interfaces
20+
21+
- [ExpressionLanguageConfig](#expressionlanguageconfig)
22+
- [ELType](#eltype)
23+
- [ELIdentifier](#elidentifier)
24+
- [ELFunction](#elfunction)
25+
- [ELParameter](#elparameter)
26+
- [ELKeyword](#elkeyword)
27+
28+
### ExpressionLanguageConfig
29+
30+
The configuration object that is passed to `expressionlanguage` function
31+
32+
| Property | Type | Description |
33+
| ---------- | ---------- | ---------- |
34+
| `types` | `{ [key: string]: ELType; } or undefined` | Type definitions used in `identifiers` and `functions` |
35+
| `identifiers` | `ELIdentifier[] or undefined` | Top-level variables |
36+
| `functions` | `ELFunction[] or undefined` | Top-level functions |
37+
38+
39+
### ELType
40+
41+
42+
43+
| Property | Type | Description |
44+
| ---------- | ---------- | ---------- |
45+
| `identifiers` | `ELIdentifier[] or undefined` | Properties of the object |
46+
| `functions` | `ELFunction[] or undefined` | Methods of the object |
47+
| `info` | `string or undefined` | |
48+
49+
50+
### ELIdentifier
51+
52+
Represents a variable or a property of an object
53+
54+
| Property | Type | Description |
55+
| ---------- | ---------- | ---------- |
56+
| `name` | `string` | |
57+
| `detail` | `string or undefined` | If set, this is shown instead of `type` |
58+
| `info` | `string or undefined` | Text to show in hover tooltip, autocomplete etc. |
59+
| `type` | `string[] or undefined` | All possible types for this identifier |
60+
61+
62+
### ELFunction
63+
64+
Represents a function or a method of an object
65+
66+
| Property | Type | Description |
67+
| ---------- | ---------- | ---------- |
68+
| `name` | `string` | |
69+
| `args` | `ELParameter[] or undefined` | |
70+
| `info` | `string or undefined` | |
71+
| `returnType` | `string[] or undefined` | |
72+
73+
74+
### ELParameter
75+
76+
77+
78+
| Property | Type | Description |
79+
| ---------- | ---------- | ---------- |
80+
| `name` | `string` | |
81+
| `type` | `string[] or undefined` | |
82+
| `info` | `string or undefined` | |
83+
| `optional` | `boolean or undefined` | |
84+
85+
86+
### ELKeyword
87+
88+
89+
90+
| Property | Type | Description |
91+
| ---------- | ---------- | ---------- |
92+
| `name` | `string` | |
93+
| `detail` | `string or undefined` | |
94+
| `info` | `string or undefined` | |
95+
96+
97+
## Types
98+
99+
- [ELTypeName](#eltypename)
100+
101+
### ELTypeName
102+
103+
One of predefined types (`ELScalar`) or a custom type from `ExpressionLanguageConfig.types`
104+
105+
| Type | Type |
106+
| ---------- | ---------- |
107+
| `ELTypeName` | `ELScalar or string` |
108+

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ yarn add @valtzu/codemirror-lang-el
5858

5959
---
6060

61+
### Configuration
62+
63+
See [CONFIGURATION.md](CONFIGURATION.md)
64+
6165
### Example
6266

6367
[Live demo](https://jsfiddle.net/turse2xq/)

src/types.ts

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
1+
// generate CONFIGURATION.md from this file by running "tsdoc --src=src/types.ts --dest=CONFIGURATION.md --noemoji --types"
2+
3+
/**
4+
* The configuration object that is passed to `expressionlanguage` function
5+
*/
6+
export interface ExpressionLanguageConfig {
7+
/** Type definitions used in `identifiers` & `functions` */
8+
types?: { [key: string]: ELType };
9+
/** Top-level variables */
10+
identifiers?: ELIdentifier[];
11+
/** Top-level functions */
12+
functions?: ELFunction[];
13+
}
14+
15+
export interface ELType {
16+
/** Properties of the object */
17+
identifiers?: ELIdentifier[];
18+
/** Methods of the object */
19+
functions?: ELFunction[];
20+
info?: string;
21+
}
22+
123
/**
224
* Represents a variable or a property of an object
325
*/
426
export interface ELIdentifier {
527
name: string;
28+
/** If set, this is shown instead of `type` */
629
detail?: string;
30+
/** Text to show in hover tooltip, autocomplete etc. */
731
info?: string;
8-
type?: string[];
32+
/** All possible types for this identifier */
33+
type?: ELTypeName[];
934
}
1035

1136
/**
@@ -15,38 +40,36 @@ export interface ELFunction {
1540
name: string;
1641
args?: ELParameter[];
1742
info?: string;
18-
returnType?: string[];
43+
returnType?: ELTypeName[];
1944
}
2045

2146
export interface ELParameter {
2247
name: string;
23-
type?: string[];
48+
type?: ELTypeName[];
2449
info?: string;
2550
optional?: boolean;
2651
}
2752

28-
export interface ELType {
29-
identifiers?: ELIdentifier[];
30-
functions?: ELFunction[];
31-
info?: string;
32-
}
33-
34-
export interface ExpressionLanguageConfig {
35-
types?: { [key: string]: ELType };
36-
identifiers?: ELIdentifier[];
37-
functions?: ELFunction[];
38-
}
39-
4053
export interface ELKeyword {
4154
name: string;
4255
detail?: string;
4356
info?: string;
4457
}
4558

4659
export enum ELScalar {
60+
/** Equivalent to PHP `bool` */
4761
Bool = 'bool',
62+
/** Equivalent to PHP `int` or `float` */
4863
Number = 'number',
64+
/** Equivalent to PHP `string` */
4965
String = 'string',
66+
/** Equivalent to PHP `null` */
5067
Null = 'null',
51-
Any = 'any', // not really scalar but meh
68+
/** Equivalent to PHP `mixed` */
69+
Any = 'any',
5270
}
71+
72+
/**
73+
* One of predefined types (`ELScalar`) or a custom type from `ExpressionLanguageConfig.types`
74+
*/
75+
export type ELTypeName = ELScalar | string;

0 commit comments

Comments
 (0)