bare-script 3.8.9 → 3.8.11

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/lib/data.js CHANGED
@@ -443,7 +443,7 @@ export function aggregateData(data, aggregation) {
443
443
 
444
444
  // The aggregation model
445
445
  export const aggregationTypes = parseSchemaMarkdown(`\
446
- group "Aggregation"
446
+ group "data"
447
447
 
448
448
 
449
449
  # A data aggregation specification
@@ -90,14 +90,31 @@ async function baredocMain(url, title, menuLinks, groupURLs):
90
90
  return
91
91
  endif
92
92
 
93
+ # Fetch the group content URLs
94
+ groupContent = {}
95
+ if groupURLs != null:
96
+ # Fetch the content URLs
97
+ groupURLArray = []
98
+ groupNames = arraySort(objectKeys(groupURLs))
99
+ for groupName in groupNames:
100
+ arrayPush(groupURLArray, objectGet(groupURLs, groupName))
101
+ endfor
102
+ groupContentArray = systemFetch(groupURLArray)
103
+
104
+ # Assign the group contents
105
+ for groupName, ixGroupName in groupNames:
106
+ objectSet(groupContent, groupName, arrayGet(groupContentArray, ixGroupName))
107
+ endfor
108
+ endif
109
+
93
110
  # Render the page
94
111
  title = if(title != null && !objectHas(args, 'url'), title, url)
95
112
  if group != null:
96
- baredocGroupPage(args, title, groupURLs, groups, group)
113
+ baredocGroupPage(args, title, groupURLs, groupContent, groups, group)
97
114
  elif single:
98
- baredocSinglePage(args, title, menuLinks, groupURLs, groups)
115
+ baredocSinglePage(args, title, menuLinks, groupURLs, groupContent, groups)
99
116
  else:
100
- baredocIndexPage(args, title, menuLinks, groupURLs, groups)
117
+ baredocIndexPage(args, title, menuLinks, groupURLs, groupContent, groups)
101
118
  endif
102
119
  endfunction
103
120
 
@@ -122,7 +139,7 @@ endfunction
122
139
 
123
140
 
124
141
  # Render a library documentation index page
125
- async function baredocIndexPage(args, title, menuLinks, groupURLs, groups):
142
+ function baredocIndexPage(args, title, menuLinks, groupURLs, groupContent, groups):
126
143
  publish = objectGet(args, 'publish')
127
144
 
128
145
  # Render the menu and title
@@ -139,9 +156,9 @@ async function baredocIndexPage(args, title, menuLinks, groupURLs, groups):
139
156
  markdownPrint('# ' + markdownEscape(title))
140
157
 
141
158
  # Render the index Markdown, if any
142
- if groupURLs != null && objectHas(groupURLs, ''):
159
+ if objectHas(groupContent, ''):
143
160
  rootURL = objectGet(groupURLs, '')
144
- rootMarkdown = systemFetch(rootURL)
161
+ rootMarkdown = objectGet(groupContent, '')
145
162
  markdownPrint('', if(rootMarkdown != null, rootMarkdown, '**Error:** Failed to load "' + markdownEscape(rootURL) + '"'))
146
163
  endif
147
164
 
@@ -159,7 +176,7 @@ endfunction
159
176
 
160
177
 
161
178
  # Render the single-page library documentation
162
- async function baredocSinglePage(args, title, menuLinks, groupURLs, groups):
179
+ function baredocSinglePage(args, title, menuLinks, groupURLs, groupContent, groups):
163
180
  publish = objectGet(args, 'publish')
164
181
 
165
182
  # Render the menu and title
@@ -176,9 +193,9 @@ async function baredocSinglePage(args, title, menuLinks, groupURLs, groups):
176
193
  markdownPrint('# ' + markdownEscape(title))
177
194
 
178
195
  # Render the index Markdown, if any
179
- if groupURLs != null && objectHas(groupURLs, ''):
196
+ if objectHas(groupContent, ''):
180
197
  rootURL = objectGet(groupURLs, '')
181
- rootMarkdown = systemFetch(rootURL)
198
+ rootMarkdown = objectGet(groupContent, '')
182
199
  markdownPrint('', if(rootMarkdown != null, rootMarkdown, '**Error:** Failed to load "' + markdownEscape(rootURL) + '"'))
183
200
  endif
184
201
 
@@ -196,13 +213,13 @@ async function baredocSinglePage(args, title, menuLinks, groupURLs, groups):
196
213
  # Render the library function index
197
214
  for groupName in arraySort(objectKeys(groups)):
198
215
  markdownPrint('', '---', '')
199
- baredocGroupPage(args, title, groupURLs, groups, groupName)
216
+ baredocGroupPage(args, title, groupURLs, groupContent, groups, groupName)
200
217
  endfor
201
218
  endfunction
202
219
 
203
220
 
204
221
  # Render a library documentation group page
205
- async function baredocGroupPage(args, title, groupURLs, groups, groupName):
222
+ function baredocGroupPage(args, title, groupURLs, groupContent, groups, groupName):
206
223
  publish = objectGet(args, 'publish')
207
224
  single = objectGet(args, 'single')
208
225
  baseHeader = if(single, '##', '#')
@@ -227,11 +244,10 @@ async function baredocGroupPage(args, title, groupURLs, groups, groupName):
227
244
  markdownPrint('', argsLink(baredocArguments, 'Back to top', null, false, '_top'))
228
245
  endif
229
246
 
230
-
231
247
  # Render the group Markdown, if any
232
- if groupURLs != null && objectHas(groupURLs, groupName):
248
+ if objectHas(groupContent, groupName):
233
249
  groupURL = objectGet(groupURLs, groupName)
234
- groupMarkdown = systemFetch(groupURL)
250
+ groupMarkdown = objectGet(groupContent, groupName)
235
251
  markdownPrint('', if(groupMarkdown != null, groupMarkdown, '**Error:** Failed to load "' + markdownEscape(groupURL) + '"'))
236
252
  endif
237
253
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  # The line chart model
6
6
  dataLineChartTypes = schemaParse( \
7
- 'group "Line Chart"', \
7
+ 'group "data"', \
8
8
  '', \
9
9
  '', \
10
10
  '# A line chart model', \
@@ -441,6 +441,16 @@ endfunction
441
441
  #
442
442
 
443
443
 
444
+ # $function: markdownElements
445
+ # $group: Markdown
446
+ # $doc: Generate an element model from a Markdown model
447
+ # $arg markdownModel: The [Markdown model](https://craigahobbs.github.io/markdown-model/model/#var.vName='Markdown')
448
+ # $arg generic: Optional (default is false). If true, render markdown elements in a generic context.
449
+ # $return: The rendered Markdown [element model](https://github.com/craigahobbs/element-model#readme)
450
+ function markdownElements():
451
+ endfunction
452
+
453
+
444
454
  # $function: markdownEscape
445
455
  # $group: markdownUp.bare: markdown
446
456
  # $doc: Escape text for inclusion in Markdown text
@@ -509,35 +519,6 @@ function markdownTitle():
509
519
  endfunction
510
520
 
511
521
 
512
- #
513
- # Schema functions
514
- #
515
-
516
-
517
- # $function: schemaElements
518
- # $group: markdownUp.bare: schema
519
- # $doc: Get a schema type's documentation [element model](https://github.com/craigahobbs/element-model#readme).
520
- # $doc: Render the element model with the [elementModelRender](#var.vName='elementModelRender') function.
521
- # $arg types: The [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
522
- # $arg typeName: The type name
523
- # $arg actionURLs: Optional (default is null). The
524
- # $arg actionURLs: [action URL overrides](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='ActionURL').
525
- # $arg actionCustom: Optional (default is false). If true, the action has a custom response.
526
- # $return: The schema type's documentation [element model](https://github.com/craigahobbs/element-model#readme)
527
- function schemaElements(types, typeName):
528
- userType = objectGet(types, typeName)
529
- userTypeKey = arrayGet(objectKeys(userType), 0)
530
- if userTypeKey == 'struct' && objectGet(objectGet(userType, 'struct'), 'union'):
531
- userTypeKey = 'union'
532
- endif
533
- return [ \
534
- [ \
535
- {'html': 'h1', 'elem': {'text': userTypeKey + ' ' + typeName}} \
536
- ] \
537
- ]
538
- endfunction
539
-
540
-
541
522
  #
542
523
  # Session storage functions
543
524
  #
@@ -141,10 +141,10 @@ schemaDocArguments = argsValidate([ \
141
141
  # $function: schemaDocMarkdown
142
142
  # $group: schemaDoc.bare
143
143
  # $doc: Generate the Schema Markdown user type documentation as an array of Markdown text lines
144
- # $arg types: The [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
144
+ # $arg types: The [type model](https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL='')
145
145
  # $arg typeName: The type name
146
146
  # $arg options: Optional (default is null). The options object with optional members:
147
- # $arg options: - **actionURLs** - The [action URLs](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='ActionURL') override
147
+ # $arg options: - **actionURLs** - The [action URLs](https://craigahobbs.github.io/bare-script/model/#var.vName='ActionURL'&var.vURL='') override
148
148
  # $arg options: - **actionCustom** - If true, the action has a custom response (default is false)
149
149
  # $arg options: - **headerPrefix** - The top-level header prefix string (default is "#")
150
150
  # $arg options: - **hideReferenced** - If true, referenced types are not rendered (default is false)
@@ -31,6 +31,7 @@ unittestMockState = objectCopy(unittestMockStateDefault)
31
31
  # $arg data: Optional (default is null). The map of function name to mock function data.
32
32
  # $arg data: The following functions make use of mock data:
33
33
  # $arg data: - **documentInputValue** - map of id to return value
34
+ # $arg data: - **markdownElements** - array of return values
34
35
  # $arg data: - **markdownParse** - array of return values
35
36
  # $arg data: - **markdownTitle** - array of return values
36
37
  # $arg data: - **systemFetch** - map of URL to response text
@@ -80,15 +81,13 @@ function unittestMockAll(data):
80
81
  unittestMockOne('localStorageSet', unittestMock_localStorageSet)
81
82
 
82
83
  # Markdown
84
+ unittestMockOne('markdownElements', systemPartial(unittestMock_markdownElements, if(data != null, objectGet(data, 'markdownElements'))))
83
85
  unittestMockOne('markdownEscape', unittestMock_markdownEscape)
84
86
  unittestMockOne('markdownHeaderId', unittestMock_markdownHeaderId)
85
87
  unittestMockOne('markdownParse', systemPartial(unittestMock_markdownParse, if(data != null, objectGet(data, 'markdownParse'))))
86
88
  unittestMockOneGeneric('markdownPrint')
87
89
  unittestMockOne('markdownTitle', systemPartial(unittestMock_markdownTitle, if(data != null, objectGet(data, 'markdownTitle'))))
88
90
 
89
- # Schema
90
- unittestMockOne('schemaElements', unittestMock_schemaElements)
91
-
92
91
  # Session Storage
93
92
  unittestMockOne('sessionStorageClear', unittestMock_sessionStorageClear)
94
93
  unittestMockOne('sessionStorageGet', unittestMock_sessionStorageGet)
@@ -287,6 +286,15 @@ endfunction
287
286
  #
288
287
 
289
288
 
289
+ function unittestMock_markdownElements(data, args...):
290
+ # Record the mocked function call
291
+ arrayPush(unittestMockCalls, ['markdownElements', args])
292
+
293
+ # Return the mocked markdownElements response
294
+ return if(data != null, arrayShift(data))
295
+ endfunction
296
+
297
+
290
298
  function unittestMock_markdownEscape(text):
291
299
  return regexReplace(unittestMock_markdownEscapeRegex, text, '\\$1')
292
300
  endfunction
@@ -326,25 +334,6 @@ function unittestMock_markdownTitle(data, args...):
326
334
  endfunction
327
335
 
328
336
 
329
- #
330
- # Schema functions
331
- #
332
-
333
-
334
- function unittestMock_schemaElements(types, typeName):
335
- userType = objectGet(types, typeName)
336
- userTypeKey = arrayGet(objectKeys(userType), 0)
337
- if userTypeKey == 'struct' && objectGet(objectGet(userType, 'struct'), 'union'):
338
- userTypeKey = 'union'
339
- endif
340
- return [ \
341
- [ \
342
- {'html': 'h1', 'elem': {'text': userTypeKey + ' ' + typeName}} \
343
- ] \
344
- ]
345
- endfunction
346
-
347
-
348
337
  #
349
338
  # Session Storage functions
350
339
  #
package/lib/library.js CHANGED
@@ -1427,7 +1427,7 @@ function regexMatchGroups(match) {
1427
1427
 
1428
1428
  // The regex match model
1429
1429
  export const regexMatchTypes = parseSchemaMarkdown(`\
1430
- group "RegexMatch"
1430
+ group "regex"
1431
1431
 
1432
1432
 
1433
1433
  # A regex match model
@@ -1522,7 +1522,7 @@ const regexSplitArgs = valueArgsModel([
1522
1522
  // $doc: Parse the [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/) text
1523
1523
  // $arg lines...: The [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/)
1524
1524
  // $arg lines...: text lines (may contain nested arrays of un-split lines)
1525
- // $return: The schema's [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
1525
+ // $return: The schema's [type model](https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL='')
1526
1526
  function schemaParse(lines) {
1527
1527
  return parseSchemaMarkdown(lines);
1528
1528
  }
@@ -1533,9 +1533,9 @@ function schemaParse(lines) {
1533
1533
  // $doc: Parse the [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/) text with options
1534
1534
  // $arg lines: The array of [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/)
1535
1535
  // $arg lines: text lines (may contain nested arrays of un-split lines)
1536
- // $arg types: Optional. The [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types').
1536
+ // $arg types: Optional. The [type model](https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL='').
1537
1537
  // $arg filename: Optional (default is ""). The file name.
1538
- // $return: The schema's [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
1538
+ // $return: The schema's [type model](https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL='')
1539
1539
  function schemaParseEx(args) {
1540
1540
  const [lines, typesArg, filename] = valueArgsValidate(schemaParseExArgs, args);
1541
1541
  const linesType = valueType(lines);
@@ -1556,8 +1556,8 @@ const schemaParseExArgs = valueArgsModel([
1556
1556
 
1557
1557
  // $function: schemaTypeModel
1558
1558
  // $group: schema
1559
- // $doc: Get the [Schema Markdown Type Model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
1560
- // $return: The [Schema Markdown Type Model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
1559
+ // $doc: Get the [Schema Markdown Type Model](https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL='')
1560
+ // $return: The [Schema Markdown Type Model](https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL='')
1561
1561
  function schemaTypeModel() {
1562
1562
  return typeModel;
1563
1563
  }
@@ -1566,7 +1566,7 @@ function schemaTypeModel() {
1566
1566
  // $function: schemaValidate
1567
1567
  // $group: schema
1568
1568
  // $doc: Validate an object to a schema type
1569
- // $arg types: The [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
1569
+ // $arg types: The [type model](https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL='')
1570
1570
  // $arg typeName: The type name
1571
1571
  // $arg value: The object to validate
1572
1572
  // $return: The validated object or null if validation fails
@@ -1585,9 +1585,9 @@ const schemaValidateArgs = valueArgsModel([
1585
1585
 
1586
1586
  // $function: schemaValidateTypeModel
1587
1587
  // $group: schema
1588
- // $doc: Validate a [Schema Markdown Type Model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
1589
- // $arg types: The [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types') to validate
1590
- // $return: The validated [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
1588
+ // $doc: Validate a [Schema Markdown Type Model](https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL='')
1589
+ // $arg types: The [type model](https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL='') to validate
1590
+ // $return: The validated [type model](https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL='')
1591
1591
  function schemaValidateTypeModel(args) {
1592
1592
  const [types] = valueArgsValidate(schemaValidateTypeModelArgs, args);
1593
1593
  return validateTypeModel(types);
@@ -1972,7 +1972,7 @@ async function systemFetch([url = null], options) {
1972
1972
 
1973
1973
  // The aggregation model
1974
1974
  export const systemFetchTypes = parseSchemaMarkdown(`\
1975
- group "SystemFetch"
1975
+ group "system"
1976
1976
 
1977
1977
 
1978
1978
  # A fetch request model
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bare-script",
4
- "version": "3.8.9",
4
+ "version": "3.8.11",
5
5
  "description": "BareScript; a lightweight scripting and expression language",
6
6
  "keywords": [
7
7
  "expression",