schema-markdown 1.2.10 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -9
- package/lib/parser.js +3 -2
- package/lib/schema.js +11 -11
- package/lib/typeModel.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -78,22 +78,56 @@ try {
|
|
|
78
78
|
~~~
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
##
|
|
81
|
+
## Schema Documentation
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
[
|
|
85
|
-
|
|
83
|
+
You can document a schema with BareScript's
|
|
84
|
+
[schemaDoc application](https://craigahobbs.github.io/bare-script/library/#var.vGroup='schemaDoc.bare')
|
|
85
|
+
running on the
|
|
86
|
+
[MarkdownUp application](https://craigahobbs.github.io/markdown-up/).
|
|
86
87
|
|
|
88
|
+
If your
|
|
89
|
+
[type model JSON file](https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Types')
|
|
90
|
+
or
|
|
91
|
+
[Schema Markdown file](https://craigahobbs.github.io/schema-markdown-js/language/)
|
|
92
|
+
is publicly visible, you can use the BareScript model application with the `var.vURL` query argument:
|
|
93
|
+
|
|
94
|
+
<https://craigahobbs.github.io/bare-script/model/#var.vURL='https://craigahobbs.github.io/bare-script/library/model.json'>
|
|
95
|
+
|
|
96
|
+
**Note:** Schema Markdown files use the `.smd` file extension.
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Self-Hosting Schema Documentation
|
|
100
|
+
|
|
101
|
+
You can host the schemaDoc application yourself by downloading the
|
|
102
|
+
[MarkdownUp Application HTML stub](https://craigahobbs.github.io/markdown-up/#host-markdown-web-pages).
|
|
103
|
+
|
|
104
|
+
~~~sh
|
|
105
|
+
curl -O https://craigahobbs.github.io/markdown-up/extra/index.html
|
|
87
106
|
~~~
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
107
|
+
|
|
108
|
+
Replace the MarkdownUp application creation line:
|
|
109
|
+
|
|
110
|
+
~~~javascript
|
|
111
|
+
const app = new MarkdownUp(window);
|
|
92
112
|
~~~
|
|
93
113
|
|
|
94
|
-
|
|
114
|
+
With the following:
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
const app = new MarkdownUp(window, {
|
|
118
|
+
'markdownText': `\
|
|
119
|
+
~~~markdown-script
|
|
120
|
+
include <schemaDoc.bare>
|
|
95
121
|
|
|
122
|
+
schemaDocMain('model.json', 'My Model')
|
|
96
123
|
~~~
|
|
124
|
+
`
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
To view locally, start a local static web server:
|
|
129
|
+
|
|
130
|
+
~~~ sh
|
|
97
131
|
python3 -m http.server
|
|
98
132
|
~~~
|
|
99
133
|
|
package/lib/parser.js
CHANGED
|
@@ -56,10 +56,11 @@ const rLineSplit = /\r?\n/;
|
|
|
56
56
|
*
|
|
57
57
|
* @param {string|string[]} text - The Schema Markdown text
|
|
58
58
|
* @param {Object} [options = {}] - The options object
|
|
59
|
-
* @param {Object} [options.types={}] - The
|
|
59
|
+
* @param {Object} [options.types={}] - The
|
|
60
|
+
* [type model]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Types'}
|
|
60
61
|
* @param {string} [options.filename=''] - The name of file being parsed (for error messages)
|
|
61
62
|
* @param {boolean} [options.validate=true] - If true, validate after parsing
|
|
62
|
-
* @returns {Object} The [type model]{@link https://craigahobbs.github.io/
|
|
63
|
+
* @returns {Object} The [type model]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Types'}
|
|
63
64
|
* @throws [SchemaMarkdownParserError]{@link module:lib/parser.SchemaMarkdownParserError}
|
|
64
65
|
*/
|
|
65
66
|
export function parseSchemaMarkdown(text, {types = {}, filename = '', validate = true} = {}) {
|
package/lib/schema.js
CHANGED
|
@@ -10,10 +10,10 @@ import {validateTypeModelErrors} from './schemaUtil.js';
|
|
|
10
10
|
/**
|
|
11
11
|
* Get a user type's referenced type model
|
|
12
12
|
*
|
|
13
|
-
* @param {Object} types - The [type model]{@link https://craigahobbs.github.io/
|
|
13
|
+
* @param {Object} types - The [type model]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Types'}
|
|
14
14
|
* @param {string} typeName - The type name
|
|
15
15
|
* @param {Object} [referencedTypes=null] - Optional map of referenced user type name to user type model
|
|
16
|
-
* @returns {Object} The referenced [type model]{@link https://craigahobbs.github.io/
|
|
16
|
+
* @returns {Object} The referenced [type model]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Types'}
|
|
17
17
|
*/
|
|
18
18
|
export function getReferencedTypes(types, typeName, referencedTypes = {}) {
|
|
19
19
|
return getReferencedTypesHelper(types, {'user': typeName}, referencedTypes);
|
|
@@ -120,7 +120,7 @@ export class ValidationError extends Error {
|
|
|
120
120
|
* Type-validate a value using a user type model. Container values are duplicated since some member types are
|
|
121
121
|
* transformed during validation.
|
|
122
122
|
*
|
|
123
|
-
* @param {Object} types - The [type model]{@link https://craigahobbs.github.io/
|
|
123
|
+
* @param {Object} types - The [type model]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Types'}
|
|
124
124
|
* @param {string} typeName - The type name
|
|
125
125
|
* @param {Object} value - The value object to validate
|
|
126
126
|
* @param {?string} [memberFqn=null] - The fully-qualified member name
|
|
@@ -455,10 +455,10 @@ function validateAttr(type, attr, value, memberFqn) {
|
|
|
455
455
|
/**
|
|
456
456
|
* Get the struct's members (inherited members first)
|
|
457
457
|
*
|
|
458
|
-
* @param {Object} types - The [type model]{@link https://craigahobbs.github.io/
|
|
459
|
-
* @param {Object} struct - The [struct model]{@link https://craigahobbs.github.io/
|
|
458
|
+
* @param {Object} types - The [type model]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Types'}
|
|
459
|
+
* @param {Object} struct - The [struct model]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Struct'}
|
|
460
460
|
* @returns {Array<Object>} The array of
|
|
461
|
-
* [struct member models]{@link https://craigahobbs.github.io/
|
|
461
|
+
* [struct member models]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='StructMember'}
|
|
462
462
|
*/
|
|
463
463
|
export function getStructMembers(types, struct) {
|
|
464
464
|
// No base structs?
|
|
@@ -488,10 +488,10 @@ export function getStructMembers(types, struct) {
|
|
|
488
488
|
/**
|
|
489
489
|
* Get the enum's values (inherited values first)
|
|
490
490
|
*
|
|
491
|
-
* @param {Object} types - The [type model]{@link https://craigahobbs.github.io/
|
|
492
|
-
* @param {Object} enum_ - The [enum model]{@link https://craigahobbs.github.io/
|
|
491
|
+
* @param {Object} types - The [type model]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Types'}
|
|
492
|
+
* @param {Object} enum_ - The [enum model]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Enum'}
|
|
493
493
|
* @returns {Array<Object>} The array of
|
|
494
|
-
* [enum value models]{@link https://craigahobbs.github.io/
|
|
494
|
+
* [enum value models]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='EnumValue'}
|
|
495
495
|
*/
|
|
496
496
|
export function getEnumValues(types, enum_) {
|
|
497
497
|
// No base enums?
|
|
@@ -521,8 +521,8 @@ export function getEnumValues(types, enum_) {
|
|
|
521
521
|
/**
|
|
522
522
|
* Validate a type model's types object
|
|
523
523
|
*
|
|
524
|
-
* @param {Object} types - The [type model]{@link https://craigahobbs.github.io/
|
|
525
|
-
* @returns {Object} The validated [type model]{@link https://craigahobbs.github.io/
|
|
524
|
+
* @param {Object} types - The [type model]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Types'}
|
|
525
|
+
* @returns {Object} The validated [type model]{@link https://craigahobbs.github.io/bare-script/model/#var.vURL=''&var.vName='Types'}
|
|
526
526
|
* @throws [ValidationError]{@link module:lib/schema.ValidationError}
|
|
527
527
|
*/
|
|
528
528
|
export function validateTypeModel(types) {
|
package/lib/typeModel.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "schema-markdown",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.12",
|
|
5
5
|
"description": "A schema definition and validation library",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"schema",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"c8": "~10.1",
|
|
28
|
-
"eslint": "~9.
|
|
28
|
+
"eslint": "~9.39",
|
|
29
29
|
"jsdoc": "~4.0"
|
|
30
30
|
}
|
|
31
31
|
}
|