bare-script 3.8.8 → 3.8.9
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/include/args.bare +1 -1
- package/lib/include/baredoc.bare +1 -1
- package/lib/include/dataTable.bare +1 -1
- package/lib/include/diff.bare +1 -1
- package/lib/include/pager.bare +1 -1
- package/lib/include/schemaDoc.bare +134 -0
- package/package.json +1 -1
- package/lib/include/schemaDocApp.bare +0 -149
package/lib/include/args.bare
CHANGED
package/lib/include/baredoc.bare
CHANGED
|
@@ -6,7 +6,7 @@ include <schemaDoc.bare>
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
# $function: baredocMain
|
|
9
|
-
# $group:
|
|
9
|
+
# $group: baredoc.bare
|
|
10
10
|
# $doc: The BareScript library documentation application main entry point
|
|
11
11
|
# $arg url: The library documentation JSON resource URL
|
|
12
12
|
# $arg title: The library title
|
package/lib/include/diff.bare
CHANGED
package/lib/include/pager.bare
CHANGED
|
@@ -1,7 +1,141 @@
|
|
|
1
1
|
# Licensed under the MIT License
|
|
2
2
|
# https://github.com/craigahobbs/bare-script/blob/main/LICENSE
|
|
3
3
|
|
|
4
|
+
include <args.bare>
|
|
4
5
|
include <dataTable.bare>
|
|
6
|
+
include <schemaDoc.bare>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# $function: schemaDocMain
|
|
10
|
+
# $group: schemaDoc.bare
|
|
11
|
+
# $doc: The Schema Markdown documentation viewer main entry point
|
|
12
|
+
# $arg url: Optional (default is null). The Schema Markdown text or JSON resource URL. If null, the Schema Markdown type model is displayed.
|
|
13
|
+
# $arg title: Optional. The schema title.
|
|
14
|
+
# $arg hideNoGroup: Optional (default is false). If true, hide types with no group.
|
|
15
|
+
async function schemaDocMain(url, title, hideNoGroup):
|
|
16
|
+
# Parse arguments
|
|
17
|
+
args = argsParse(schemaDocArguments)
|
|
18
|
+
name = objectGet(args, 'name')
|
|
19
|
+
publish = objectGet(args, 'publish')
|
|
20
|
+
single = objectGet(args, 'single')
|
|
21
|
+
url = objectGet(args, 'url', url)
|
|
22
|
+
title = if(title != null && !objectHas(args, 'url'), title, url)
|
|
23
|
+
|
|
24
|
+
# If no URL was provided, use the Schema Markdown type model schema
|
|
25
|
+
if !url:
|
|
26
|
+
types = schemaTypeModel()
|
|
27
|
+
title = 'The Schema Markdown Type Model'
|
|
28
|
+
else:
|
|
29
|
+
# Fetch the Schema Markdown resource
|
|
30
|
+
types = null
|
|
31
|
+
schemaText = systemFetch(url)
|
|
32
|
+
if schemaText != null:
|
|
33
|
+
if stringEndsWith(url, '.json'):
|
|
34
|
+
schemaJSON = jsonParse(schemaText)
|
|
35
|
+
if schemaJSON != null:
|
|
36
|
+
types = schemaValidateTypeModel(schemaJSON)
|
|
37
|
+
endif
|
|
38
|
+
else:
|
|
39
|
+
types = schemaParse(schemaText)
|
|
40
|
+
endif
|
|
41
|
+
endif
|
|
42
|
+
|
|
43
|
+
# Error?
|
|
44
|
+
if types == null:
|
|
45
|
+
markdownPrint('**Error:** Failed to fetch Schema Markdown resource "' + url + '"')
|
|
46
|
+
return
|
|
47
|
+
endif
|
|
48
|
+
endif
|
|
49
|
+
|
|
50
|
+
# Type page?
|
|
51
|
+
if name:
|
|
52
|
+
# Set the type page title
|
|
53
|
+
documentSetTitle(title + ' - ' + name)
|
|
54
|
+
markdownPrint(argsLink(schemaDocArguments, 'Index', {'name': null}))
|
|
55
|
+
|
|
56
|
+
# Type exist?
|
|
57
|
+
if !objectHas(types, name):
|
|
58
|
+
markdownPrint('', '**Error:** Unknown type "' + name + '"')
|
|
59
|
+
return
|
|
60
|
+
endif
|
|
61
|
+
|
|
62
|
+
# Render the type's documentation
|
|
63
|
+
markdownPrint(schemaDocMarkdown(types, name))
|
|
64
|
+
return
|
|
65
|
+
endif
|
|
66
|
+
|
|
67
|
+
# Render the index page title
|
|
68
|
+
documentSetTitle(title)
|
|
69
|
+
markdownPrint('# ' + markdownEscape(title))
|
|
70
|
+
|
|
71
|
+
# Render the single page toggle
|
|
72
|
+
if !publish:
|
|
73
|
+
markdownPrint('', argsLink(schemaDocArguments, if(single, 'Multi Page', 'Single Page'), {'single': !single}))
|
|
74
|
+
endif
|
|
75
|
+
|
|
76
|
+
# Group the types
|
|
77
|
+
groups = {}
|
|
78
|
+
typeNames = arraySort(objectKeys(types))
|
|
79
|
+
typeGroups = {'action': 'Actions', 'enum': 'Enums', 'struct': 'Structs', 'typedef': 'Typedefs'}
|
|
80
|
+
for typeName in typeNames:
|
|
81
|
+
type = objectGet(types, typeName)
|
|
82
|
+
group = objectGet(objectGet(type, arrayGet(objectKeys(type), 0)), 'docGroup')
|
|
83
|
+
|
|
84
|
+
# No group? Use the type's default group.
|
|
85
|
+
if group == null:
|
|
86
|
+
if hideNoGroup:
|
|
87
|
+
continue
|
|
88
|
+
endif
|
|
89
|
+
group = objectGet(typeGroups, arrayGet(objectKeys(type), 0))
|
|
90
|
+
endif
|
|
91
|
+
|
|
92
|
+
# Add the type to the group
|
|
93
|
+
if !objectHas(groups, group):
|
|
94
|
+
objectSet(groups, group, [])
|
|
95
|
+
endif
|
|
96
|
+
arrayPush(objectGet(groups, group), type)
|
|
97
|
+
endfor
|
|
98
|
+
groupNames = arraySort(objectKeys(groups))
|
|
99
|
+
|
|
100
|
+
# The table of contents
|
|
101
|
+
if single:
|
|
102
|
+
markdownPrint('', '## Table of Contents', '')
|
|
103
|
+
for groupName in groupNames:
|
|
104
|
+
markdownPrint('- ' + argsLink(schemaDocArguments, groupName, null, false, groupName))
|
|
105
|
+
endfor
|
|
106
|
+
endif
|
|
107
|
+
|
|
108
|
+
# Render the index groups
|
|
109
|
+
for groupName in groupNames:
|
|
110
|
+
if single:
|
|
111
|
+
markdownPrint('', '---')
|
|
112
|
+
endif
|
|
113
|
+
markdownPrint('', '## ' + markdownEscape(groupName))
|
|
114
|
+
if single && !publish:
|
|
115
|
+
markdownPrint('', argsLink(schemaDocArguments, 'Back to top', null, false, '_top'))
|
|
116
|
+
endif
|
|
117
|
+
|
|
118
|
+
# Render the group type links
|
|
119
|
+
groupTypes = objectGet(groups, groupName)
|
|
120
|
+
for groupType in groupTypes:
|
|
121
|
+
groupTypeName = objectGet(objectGet(groupType, arrayGet(objectKeys(groupType), 0)), 'name')
|
|
122
|
+
if single:
|
|
123
|
+
markdownPrint('', schemaDocMarkdown(types, groupTypeName, {'headerPrefix': '###', 'hideReferenced': true}))
|
|
124
|
+
else:
|
|
125
|
+
markdownPrint('', argsLink(schemaDocArguments, groupTypeName, {'name': groupTypeName}, false, '_top'))
|
|
126
|
+
endif
|
|
127
|
+
endfor
|
|
128
|
+
endfor
|
|
129
|
+
endfunction
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# The Schema Markdown documentation viewer arguments
|
|
133
|
+
schemaDocArguments = argsValidate([ \
|
|
134
|
+
{'name': 'name'}, \
|
|
135
|
+
{'name': 'publish', 'type': 'bool', 'default': false}, \
|
|
136
|
+
{'name': 'single', 'type': 'bool', 'default': false}, \
|
|
137
|
+
{'name': 'url', 'global': 'vURL'} \
|
|
138
|
+
])
|
|
5
139
|
|
|
6
140
|
|
|
7
141
|
# $function: schemaDocMarkdown
|
package/package.json
CHANGED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
# Licensed under the MIT License
|
|
2
|
-
# https://github.com/craigahobbs/bare-script/blob/main/LICENSE
|
|
3
|
-
|
|
4
|
-
include <args.bare>
|
|
5
|
-
include <schemaDoc.bare>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# $function: schemaDocAppMain
|
|
9
|
-
# $group: schemaDocApp.bare
|
|
10
|
-
# $doc: The Schema Markdown documentation viewer main entry point
|
|
11
|
-
# $arg url: Optional (default is null). The Schema Markdown text or JSON resource URL. If null, the Schema Markdown type model is displayed.
|
|
12
|
-
# $arg title: Optional. The schema title.
|
|
13
|
-
# $arg hideNoGroup: Optional (default is false). If true, hide types with no group.
|
|
14
|
-
async function schemaDocAppMain(url, title, hideNoGroup):
|
|
15
|
-
# Parse arguments
|
|
16
|
-
args = argsParse(schemaDocAppArguments)
|
|
17
|
-
name = objectGet(args, 'name')
|
|
18
|
-
url = objectGet(args, 'url', url)
|
|
19
|
-
title = if(title != null && !objectHas(args, 'url'), title, url)
|
|
20
|
-
|
|
21
|
-
# If no URL was provided, use the Schema Markdown type model schema
|
|
22
|
-
if url == null || url == '':
|
|
23
|
-
types = schemaTypeModel()
|
|
24
|
-
title = 'The Schema Markdown Type Model'
|
|
25
|
-
else:
|
|
26
|
-
# Fetch the Schema Markdown resource
|
|
27
|
-
types = null
|
|
28
|
-
schemaText = systemFetch(url)
|
|
29
|
-
if schemaText != null:
|
|
30
|
-
if stringEndsWith(url, '.json'):
|
|
31
|
-
schemaJSON = jsonParse(schemaText)
|
|
32
|
-
if schemaJSON != null:
|
|
33
|
-
types = schemaValidateTypeModel(schemaJSON)
|
|
34
|
-
endif
|
|
35
|
-
else:
|
|
36
|
-
types = schemaParse(schemaText)
|
|
37
|
-
endif
|
|
38
|
-
endif
|
|
39
|
-
|
|
40
|
-
# Error?
|
|
41
|
-
if types == null:
|
|
42
|
-
markdownPrint('**Error:** Failed to fetch Schema Markdown resource "' + url + '"')
|
|
43
|
-
return
|
|
44
|
-
endif
|
|
45
|
-
endif
|
|
46
|
-
|
|
47
|
-
# Render the page
|
|
48
|
-
if name != null:
|
|
49
|
-
schemaDocAppTypePage(types, title, name)
|
|
50
|
-
else:
|
|
51
|
-
schemaDocAppIndexPage(args, types, title, hideNoGroup)
|
|
52
|
-
endif
|
|
53
|
-
endfunction
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
# The Schema Markdown documentation viewer arguments
|
|
57
|
-
schemaDocAppArguments = argsValidate([ \
|
|
58
|
-
{'name': 'name'}, \
|
|
59
|
-
{'name': 'publish', 'type': 'bool', 'default': false}, \
|
|
60
|
-
{'name': 'single', 'type': 'bool', 'default': false}, \
|
|
61
|
-
{'name': 'url', 'global': 'vURL'} \
|
|
62
|
-
])
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
# Render the Schema Markdown documentation viewer index page
|
|
66
|
-
function schemaDocAppIndexPage(args, types, title, hideNoGroup):
|
|
67
|
-
publish = objectGet(args, 'publish')
|
|
68
|
-
single = objectGet(args, 'single')
|
|
69
|
-
|
|
70
|
-
# Set the page title
|
|
71
|
-
documentSetTitle(title)
|
|
72
|
-
markdownPrint('# ' + markdownEscape(title))
|
|
73
|
-
|
|
74
|
-
# Render the single page toggle
|
|
75
|
-
if !publish:
|
|
76
|
-
markdownPrint('', argsLink(schemaDocAppArguments, if(single, 'Multi Page', 'Single Page'), {'single': !single}))
|
|
77
|
-
endif
|
|
78
|
-
|
|
79
|
-
# Group the types
|
|
80
|
-
groups = {}
|
|
81
|
-
typeNames = arraySort(objectKeys(types))
|
|
82
|
-
typeGroups = {'action': 'Actions', 'enum': 'Enums', 'struct': 'Structs', 'typedef': 'Typedefs'}
|
|
83
|
-
for typeName in typeNames:
|
|
84
|
-
type = objectGet(types, typeName)
|
|
85
|
-
group = objectGet(objectGet(type, arrayGet(objectKeys(type), 0)), 'docGroup')
|
|
86
|
-
|
|
87
|
-
# No group? Use the type's default group.
|
|
88
|
-
if group == null:
|
|
89
|
-
if hideNoGroup:
|
|
90
|
-
continue
|
|
91
|
-
endif
|
|
92
|
-
group = objectGet(typeGroups, arrayGet(objectKeys(type), 0))
|
|
93
|
-
endif
|
|
94
|
-
|
|
95
|
-
# Add the type to the group
|
|
96
|
-
if !objectHas(groups, group):
|
|
97
|
-
objectSet(groups, group, [])
|
|
98
|
-
endif
|
|
99
|
-
arrayPush(objectGet(groups, group), type)
|
|
100
|
-
endfor
|
|
101
|
-
groupNames = arraySort(objectKeys(groups))
|
|
102
|
-
|
|
103
|
-
# The table of contents
|
|
104
|
-
if single:
|
|
105
|
-
markdownPrint('', '## Table of Contents', '')
|
|
106
|
-
for groupName in groupNames:
|
|
107
|
-
markdownPrint('- ' + argsLink(schemaDocAppArguments, groupName, null, false, groupName))
|
|
108
|
-
endfor
|
|
109
|
-
endif
|
|
110
|
-
|
|
111
|
-
# Render the index groups
|
|
112
|
-
for groupName in groupNames:
|
|
113
|
-
if single:
|
|
114
|
-
markdownPrint('', '---')
|
|
115
|
-
endif
|
|
116
|
-
markdownPrint('', '## ' + markdownEscape(groupName))
|
|
117
|
-
if single && !publish:
|
|
118
|
-
markdownPrint('', argsLink(schemaDocAppArguments, 'Back to top', null, false, '_top'))
|
|
119
|
-
endif
|
|
120
|
-
|
|
121
|
-
# Render the group type links
|
|
122
|
-
groupTypes = objectGet(groups, groupName)
|
|
123
|
-
for groupType in groupTypes:
|
|
124
|
-
groupTypeName = objectGet(objectGet(groupType, arrayGet(objectKeys(groupType), 0)), 'name')
|
|
125
|
-
if single:
|
|
126
|
-
markdownPrint('', schemaDocMarkdown(types, groupTypeName, {'headerPrefix': '###', 'hideReferenced': true}))
|
|
127
|
-
else:
|
|
128
|
-
markdownPrint('', argsLink(schemaDocAppArguments, groupTypeName, {'name': groupTypeName}, false, '_top'))
|
|
129
|
-
endif
|
|
130
|
-
endfor
|
|
131
|
-
endfor
|
|
132
|
-
endfunction
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
# Render the Schema Markdown documentation viewer type page
|
|
136
|
-
function schemaDocAppTypePage(types, title, typeName):
|
|
137
|
-
# Set the page title
|
|
138
|
-
documentSetTitle(title + ' - ' + typeName)
|
|
139
|
-
markdownPrint(argsLink(schemaDocAppArguments, 'Index', {'name': null}))
|
|
140
|
-
|
|
141
|
-
# Type exist?
|
|
142
|
-
if !objectHas(types, typeName):
|
|
143
|
-
markdownPrint('', '**Error:** Unknown type "' + typeName + '"')
|
|
144
|
-
return
|
|
145
|
-
endif
|
|
146
|
-
|
|
147
|
-
# Render the type's documentation
|
|
148
|
-
markdownPrint(schemaDocMarkdown(types, typeName))
|
|
149
|
-
endfunction
|