bare-script 2.2.13 → 2.2.14

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/bareDoc.js CHANGED
@@ -121,34 +121,46 @@ export function parseBareDoc(files) {
121
121
  func = {'name': textTrim};
122
122
  funcs[textTrim] = func;
123
123
  }
124
- } else {
125
- // arg keyword?
126
- const matchArg = line.match(rArg);
127
- if (matchArg !== null) {
128
- const {name, text} = matchArg.groups;
129
- const textTrim = text.trim();
130
-
131
- // Keyword used outside of function?
132
- if (func === null) {
133
- errors.push(`${file}:${ixLine + 1}: Function argument "${name}" outside function`);
134
- continue;
135
- }
136
124
 
137
- // Add the function arg documentation line - don't add leading blank lines
138
- let args = func.args ?? null;
139
- let arg = (args !== null ? args.find((argFind) => argFind.name === name) : null) ?? null;
140
- if (arg !== null || textTrim !== '') {
141
- if (args === null) {
142
- args = [];
143
- func.args = args;
144
- }
145
- if (arg === null) {
146
- arg = {'name': name, 'doc': []};
147
- args.push(arg);
148
- }
149
- arg.doc.push(text);
125
+ continue;
126
+ }
127
+
128
+ // arg keyword?
129
+ const matchArg = line.match(rArg);
130
+ if (matchArg !== null) {
131
+ const {name, text} = matchArg.groups;
132
+ const textTrim = text.trim();
133
+
134
+ // Keyword used outside of function?
135
+ if (func === null) {
136
+ errors.push(`${file}:${ixLine + 1}: Function argument "${name}" outside function`);
137
+ continue;
138
+ }
139
+
140
+ // Add the function arg documentation line - don't add leading blank lines
141
+ let args = func.args ?? null;
142
+ let arg = (args !== null ? args.find((argFind) => argFind.name === name) : null) ?? null;
143
+ if (arg !== null || textTrim !== '') {
144
+ if (args === null) {
145
+ args = [];
146
+ func.args = args;
150
147
  }
148
+ if (arg === null) {
149
+ arg = {'name': name, 'doc': []};
150
+ args.push(arg);
151
+ }
152
+ arg.doc.push(text);
151
153
  }
154
+
155
+ continue;
156
+ }
157
+
158
+ // Unknown documentation comment?
159
+ const matchUnknown = line.match(rUnknown);
160
+ if (matchUnknown !== null) {
161
+ const {unknown} = matchUnknown.groups;
162
+ errors.push(`${file}:${ixLine + 1}: Invalid documentation comment "${unknown}"`);
163
+ continue;
152
164
  }
153
165
  }
154
166
  }
@@ -185,5 +197,6 @@ export function parseBareDoc(files) {
185
197
 
186
198
  // Library documentation regular expressions
187
199
  const rKey = /^\s*(?:\/\/|#)\s*\$(?<key>function|group|doc|return):\s?(?<text>.*)$/;
188
- const rArg = /^\s*(?:\/\/|#)\s*\$arg\s+(?<name>[A-Za-z_][A-Za-z0-9_]*):\s?(?<text>.*)$/;
200
+ const rArg = /^\s*(?:\/\/|#)\s*\$arg\s+(?<name>[A-Za-z_][A-Za-z0-9_]*(?:\.\.\.)?):\s?(?<text>.*)$/;
201
+ const rUnknown = /^\s*(?:\/\/|#)\s*\$(?<unknown>[^:]+):/;
189
202
  const rSplit = /\r?\n/;
package/lib/library.js CHANGED
@@ -89,9 +89,9 @@ export const scriptFunctions = {
89
89
  // $function: arrayNew
90
90
  // $group: Array
91
91
  // $doc: Create a new array
92
- // $arg args: The new array's values
92
+ // $arg values...: The new array's values
93
93
  // $return: The new array
94
- 'arrayNew': (args) => args,
94
+ 'arrayNew': (values) => values,
95
95
 
96
96
  // $function: arrayNewSize
97
97
  // $group: Array
@@ -112,7 +112,7 @@ export const scriptFunctions = {
112
112
  // $group: Array
113
113
  // $doc: Add one or more values to the end of the array
114
114
  // $arg array: The array
115
- // $arg values: The values to add to the end of the array
115
+ // $arg values...: The values to add to the end of the array
116
116
  // $return: The array
117
117
  'arrayPush': ([array, ...values]) => {
118
118
  if (Array.isArray(array)) {
@@ -213,7 +213,7 @@ export const scriptFunctions = {
213
213
  // $function: dataParseCSV
214
214
  // $group: Data
215
215
  // $doc: Parse CSV text to a data array
216
- // $arg text: The CSV text
216
+ // $arg text...: The CSV text
217
217
  // $return: The data array
218
218
  'dataParseCSV': (text) => {
219
219
  const data = parseCSV(text);
@@ -481,15 +481,15 @@ export const scriptFunctions = {
481
481
 
482
482
  // $function: mathMax
483
483
  // $group: Math
484
- // $doc: Compute the maximum value of all arguments
485
- // $arg values: All arguments
484
+ // $doc: Compute the maximum value
485
+ // $arg values...: The values
486
486
  // $return: The maximum value
487
487
  'mathMax': (values) => Math.max(...values),
488
488
 
489
489
  // $function: mathMin
490
490
  // $group: Math
491
- // $doc: Compute the minimum value of all arguments
492
- // $arg values: All arguments
491
+ // $doc: Compute the minimum value
492
+ // $arg values...: The values
493
493
  // $return: The minimum value
494
494
  'mathMin': (values) => Math.min(...values),
495
495
 
@@ -648,7 +648,7 @@ export const scriptFunctions = {
648
648
  // $function: objectNew
649
649
  // $group: Object
650
650
  // $doc: Create a new object
651
- // $arg keyValues: The object's initial key and value arguments
651
+ // $arg keyValues...: The object's initial key and value pairs
652
652
  // $return: The new object
653
653
  'objectNew': (keyValues) => {
654
654
  const object = {};
@@ -729,8 +729,8 @@ export const scriptFunctions = {
729
729
  // $function: schemaParse
730
730
  // $group: Schema
731
731
  // $doc: Parse the [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/) text
732
- // $arg lines: The [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/)
733
- // $arg lines: text lines (may contain nested arrays of un-split lines)
732
+ // $arg lines...: The [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/)
733
+ // $arg lines...: text lines (may contain nested arrays of un-split lines)
734
734
  // $return: The schema's [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
735
735
  'schemaParse': (lines) => parseSchemaMarkdown(lines),
736
736
 
@@ -789,9 +789,9 @@ export const scriptFunctions = {
789
789
 
790
790
  // $function: stringFromCharCode
791
791
  // $group: String
792
- // $doc: Create a string from the character code arguments
793
- // $arg charCodes: The character codes
794
- // $return: The new string
792
+ // $doc: Create a string of characters from character codes
793
+ // $arg charCodes...: The character codes
794
+ // $return: The string of characters
795
795
  'stringFromCharCode': (charCodes) => String.fromCharCode(...charCodes),
796
796
 
797
797
  // $function: stringIndexOf
@@ -991,7 +991,7 @@ export const scriptFunctions = {
991
991
  // $doc: Return a new function which behaves like "func" called with "args".
992
992
  // $doc: If additional arguments are passed to the returned function, they are appended to "args".
993
993
  // $arg func: The function
994
- // $arg args: The function arguments
994
+ // $arg args...: The function arguments
995
995
  // $return: The new function called with "args"
996
996
  'systemPartial': ([func, ...args]) => (argsExtra, options) => func([...args, ...argsExtra], options),
997
997
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bare-script",
4
- "version": "2.2.13",
4
+ "version": "2.2.14",
5
5
  "description": "BareScript; a lightweight scripting and expression language",
6
6
  "keywords": [
7
7
  "expression",