@travetto/doc 8.0.0-alpha.2 → 8.0.0-alpha.21
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 +41 -31
- package/__index__.ts +3 -3
- package/package.json +5 -3
- package/src/jsx.ts +53 -19
- package/src/mapping/library.ts +7 -4
- package/src/mapping/module.ts +177 -61
- package/src/render/code-highlight.ts +3 -5
- package/src/render/context.ts +28 -13
- package/src/render/html.ts +63 -22
- package/src/render/markdown.ts +37 -11
- package/src/render/renderer.ts +26 -24
- package/src/types.ts +7 -8
- package/src/util/file.ts +37 -37
- package/src/util/package.ts +19 -13
- package/src/util/resolve.ts +11 -12
- package/src/util/run.ts +14 -10
- package/src/util/types.ts +1 -1
- package/support/cli.doc.ts +12 -11
- package/support/jsx-runtime.ts +26 -15
package/src/mapping/module.ts
CHANGED
|
@@ -1,222 +1,338 @@
|
|
|
1
1
|
export const MODULES = {
|
|
2
2
|
Auth: {
|
|
3
|
-
name: '@travetto/auth',
|
|
4
|
-
|
|
3
|
+
name: '@travetto/auth',
|
|
4
|
+
folder: '@travetto/auth',
|
|
5
|
+
displayName: 'Authentication',
|
|
6
|
+
description: 'Authentication support for the Travetto framework'
|
|
5
7
|
},
|
|
6
8
|
AuthModel: {
|
|
7
|
-
name: '@travetto/auth-model',
|
|
9
|
+
name: '@travetto/auth-model',
|
|
10
|
+
folder: '@travetto/auth-model',
|
|
11
|
+
displayName: 'Authentication Model',
|
|
8
12
|
description: 'Authentication model support for the Travetto framework'
|
|
9
13
|
},
|
|
10
14
|
AuthSession: {
|
|
11
|
-
name: '@travetto/auth-session',
|
|
15
|
+
name: '@travetto/auth-session',
|
|
16
|
+
folder: '@travetto/auth-session',
|
|
17
|
+
displayName: 'Auth Session',
|
|
12
18
|
description: 'Session provider for the travetto auth module.'
|
|
13
19
|
},
|
|
14
20
|
AuthWeb: {
|
|
15
|
-
name: '@travetto/auth-web',
|
|
21
|
+
name: '@travetto/auth-web',
|
|
22
|
+
folder: '@travetto/auth-web',
|
|
23
|
+
displayName: 'Web Auth',
|
|
16
24
|
description: 'Web authentication integration support for the Travetto framework'
|
|
17
25
|
},
|
|
18
26
|
AuthWebPassport: {
|
|
19
|
-
name: '@travetto/auth-web-passport',
|
|
27
|
+
name: '@travetto/auth-web-passport',
|
|
28
|
+
folder: '@travetto/auth-web-passport',
|
|
29
|
+
displayName: 'Web Auth Passport',
|
|
20
30
|
description: 'Web authentication integration support for the Travetto framework'
|
|
21
31
|
},
|
|
22
32
|
AuthWebSession: {
|
|
23
|
-
name: '@travetto/auth-web-session',
|
|
33
|
+
name: '@travetto/auth-web-session',
|
|
34
|
+
folder: '@travetto/auth-web-session',
|
|
35
|
+
displayName: 'Web Auth Session',
|
|
24
36
|
description: 'Web authentication session integration support for the Travetto framework'
|
|
25
37
|
},
|
|
26
38
|
Cache: {
|
|
27
|
-
name: '@travetto/cache',
|
|
39
|
+
name: '@travetto/cache',
|
|
40
|
+
folder: '@travetto/cache',
|
|
41
|
+
displayName: 'Caching',
|
|
28
42
|
description: 'Caching functionality with decorators for declarative use.'
|
|
29
43
|
},
|
|
30
44
|
Cli: {
|
|
31
|
-
name: '@travetto/cli',
|
|
45
|
+
name: '@travetto/cli',
|
|
46
|
+
folder: '@travetto/cli',
|
|
47
|
+
displayName: 'Command Line Interface',
|
|
32
48
|
description: 'CLI infrastructure for Travetto framework'
|
|
33
49
|
},
|
|
34
50
|
Compiler: {
|
|
35
|
-
name: '@travetto/compiler',
|
|
51
|
+
name: '@travetto/compiler',
|
|
52
|
+
folder: '@travetto/compiler',
|
|
53
|
+
displayName: 'Compiler',
|
|
36
54
|
description: 'The compiler infrastructure for the Travetto framework'
|
|
37
55
|
},
|
|
38
56
|
Config: {
|
|
39
|
-
name: '@travetto/config',
|
|
57
|
+
name: '@travetto/config',
|
|
58
|
+
folder: '@travetto/config',
|
|
59
|
+
displayName: 'Configuration',
|
|
40
60
|
description: 'Configuration support'
|
|
41
61
|
},
|
|
42
62
|
Context: {
|
|
43
|
-
name: '@travetto/context',
|
|
63
|
+
name: '@travetto/context',
|
|
64
|
+
folder: '@travetto/context',
|
|
65
|
+
displayName: 'Async Context',
|
|
44
66
|
description: 'Async-aware state management, maintaining context across asynchronous calls.'
|
|
45
67
|
},
|
|
46
68
|
Di: {
|
|
47
|
-
name: '@travetto/di',
|
|
69
|
+
name: '@travetto/di',
|
|
70
|
+
folder: '@travetto/di',
|
|
71
|
+
displayName: 'Dependency Injection',
|
|
48
72
|
description: 'Dependency registration/management and injection support.'
|
|
49
73
|
},
|
|
50
74
|
Doc: {
|
|
51
|
-
name: '@travetto/doc',
|
|
75
|
+
name: '@travetto/doc',
|
|
76
|
+
folder: '@travetto/doc',
|
|
77
|
+
displayName: 'Documentation',
|
|
52
78
|
description: 'Documentation support for the Travetto framework'
|
|
53
79
|
},
|
|
54
80
|
Email: {
|
|
55
|
-
name: '@travetto/email',
|
|
81
|
+
name: '@travetto/email',
|
|
82
|
+
folder: '@travetto/email',
|
|
83
|
+
displayName: 'Email',
|
|
56
84
|
description: 'Email transmission module.'
|
|
57
85
|
},
|
|
58
86
|
EmailCompiler: {
|
|
59
|
-
name: '@travetto/email-compiler',
|
|
87
|
+
name: '@travetto/email-compiler',
|
|
88
|
+
folder: '@travetto/email-compiler',
|
|
89
|
+
displayName: 'Email Compilation Support',
|
|
60
90
|
description: 'Email compiling module'
|
|
61
91
|
},
|
|
62
92
|
EmailInky: {
|
|
63
|
-
name: '@travetto/email-inky',
|
|
93
|
+
name: '@travetto/email-inky',
|
|
94
|
+
folder: '@travetto/email-inky',
|
|
95
|
+
displayName: 'Email Inky Templates',
|
|
64
96
|
description: 'Email Inky templating module'
|
|
65
97
|
},
|
|
66
98
|
EmailNodemailer: {
|
|
67
|
-
name: '@travetto/email-nodemailer',
|
|
99
|
+
name: '@travetto/email-nodemailer',
|
|
100
|
+
folder: '@travetto/email-nodemailer',
|
|
101
|
+
displayName: 'Email Nodemailer Support',
|
|
68
102
|
description: 'Email transmission module.'
|
|
69
103
|
},
|
|
70
|
-
|
|
71
|
-
name: '@travetto/
|
|
72
|
-
|
|
104
|
+
Lint: {
|
|
105
|
+
name: '@travetto/lint',
|
|
106
|
+
folder: '@travetto/lint',
|
|
107
|
+
displayName: 'Lint Support',
|
|
108
|
+
description: 'Lint Support'
|
|
73
109
|
},
|
|
74
110
|
Image: {
|
|
75
|
-
name: '@travetto/image',
|
|
111
|
+
name: '@travetto/image',
|
|
112
|
+
folder: '@travetto/image',
|
|
113
|
+
displayName: 'Image',
|
|
76
114
|
description: 'Image support, resizing, and optimization'
|
|
77
115
|
},
|
|
116
|
+
LlmSupport: {
|
|
117
|
+
name: '@travetto/llm-support',
|
|
118
|
+
folder: '@travetto/llm-support',
|
|
119
|
+
displayName: 'LLM Support',
|
|
120
|
+
description: 'Task-oriented synthesized LLM guidance for Travetto modules.'
|
|
121
|
+
},
|
|
78
122
|
Log: {
|
|
79
|
-
name: '@travetto/log',
|
|
123
|
+
name: '@travetto/log',
|
|
124
|
+
folder: '@travetto/log',
|
|
125
|
+
displayName: 'Logging',
|
|
80
126
|
description: 'Logging framework that integrates at the console.log level.'
|
|
81
127
|
},
|
|
82
128
|
Manifest: {
|
|
83
|
-
name: '@travetto/manifest',
|
|
129
|
+
name: '@travetto/manifest',
|
|
130
|
+
folder: '@travetto/manifest',
|
|
131
|
+
displayName: 'Manifest',
|
|
84
132
|
description: 'Support for project indexing, manifesting, along with file watching'
|
|
85
133
|
},
|
|
86
134
|
Model: {
|
|
87
|
-
name: '@travetto/model',
|
|
135
|
+
name: '@travetto/model',
|
|
136
|
+
folder: '@travetto/model',
|
|
137
|
+
displayName: 'Data Modeling Support',
|
|
88
138
|
description: 'Datastore abstraction for core operations.'
|
|
89
139
|
},
|
|
90
140
|
ModelDynamodb: {
|
|
91
|
-
name: '@travetto/model-dynamodb',
|
|
141
|
+
name: '@travetto/model-dynamodb',
|
|
142
|
+
folder: '@travetto/model-dynamodb',
|
|
143
|
+
displayName: 'DynamoDB Model Support',
|
|
92
144
|
description: 'DynamoDB backing for the travetto model module.'
|
|
93
145
|
},
|
|
94
146
|
ModelElasticsearch: {
|
|
95
|
-
name: '@travetto/model-elasticsearch',
|
|
147
|
+
name: '@travetto/model-elasticsearch',
|
|
148
|
+
folder: '@travetto/model-elasticsearch',
|
|
149
|
+
displayName: 'Elasticsearch Model Source',
|
|
96
150
|
description: 'Elasticsearch backing for the travetto model module, with real-time modeling support for Elasticsearch mappings.'
|
|
97
151
|
},
|
|
98
152
|
ModelFile: {
|
|
99
|
-
name: '@travetto/model-file',
|
|
153
|
+
name: '@travetto/model-file',
|
|
154
|
+
folder: '@travetto/model-file',
|
|
155
|
+
displayName: 'File Model Support',
|
|
100
156
|
description: 'File system backing for the travetto model module.'
|
|
101
157
|
},
|
|
102
158
|
ModelFirestore: {
|
|
103
|
-
name: '@travetto/model-firestore',
|
|
159
|
+
name: '@travetto/model-firestore',
|
|
160
|
+
folder: '@travetto/model-firestore',
|
|
161
|
+
displayName: 'Firestore Model Support',
|
|
104
162
|
description: 'Firestore backing for the travetto model module.'
|
|
105
163
|
},
|
|
164
|
+
ModelIndexed: {
|
|
165
|
+
name: '@travetto/model-indexed',
|
|
166
|
+
folder: '@travetto/model-indexed',
|
|
167
|
+
displayName: 'Data Model Indexing Support',
|
|
168
|
+
description: 'Basic indexing support for model sources that support it.'
|
|
169
|
+
},
|
|
106
170
|
ModelMemory: {
|
|
107
|
-
name: '@travetto/model-memory',
|
|
171
|
+
name: '@travetto/model-memory',
|
|
172
|
+
folder: '@travetto/model-memory',
|
|
173
|
+
displayName: 'Memory Model Support',
|
|
108
174
|
description: 'Memory backing for the travetto model module.'
|
|
109
175
|
},
|
|
110
176
|
ModelMongo: {
|
|
111
|
-
name: '@travetto/model-mongo',
|
|
177
|
+
name: '@travetto/model-mongo',
|
|
178
|
+
folder: '@travetto/model-mongo',
|
|
179
|
+
displayName: 'MongoDB Model Support',
|
|
112
180
|
description: 'Mongo backing for the travetto model module.'
|
|
113
181
|
},
|
|
114
182
|
ModelMysql: {
|
|
115
|
-
name: '@travetto/model-mysql',
|
|
183
|
+
name: '@travetto/model-mysql',
|
|
184
|
+
folder: '@travetto/model-mysql',
|
|
185
|
+
displayName: 'MySQL Model Service',
|
|
116
186
|
description: 'MySQL backing for the travetto model module, with real-time modeling support for SQL schemas.'
|
|
117
187
|
},
|
|
118
188
|
ModelPostgres: {
|
|
119
|
-
name: '@travetto/model-postgres',
|
|
189
|
+
name: '@travetto/model-postgres',
|
|
190
|
+
folder: '@travetto/model-postgres',
|
|
191
|
+
displayName: 'PostgreSQL Model Service',
|
|
120
192
|
description: 'PostgreSQL backing for the travetto model module, with real-time modeling support for SQL schemas.'
|
|
121
193
|
},
|
|
122
194
|
ModelQuery: {
|
|
123
|
-
name: '@travetto/model-query',
|
|
195
|
+
name: '@travetto/model-query',
|
|
196
|
+
folder: '@travetto/model-query',
|
|
197
|
+
displayName: 'Data Model Querying',
|
|
124
198
|
description: 'Datastore abstraction for advanced query support.'
|
|
125
199
|
},
|
|
126
200
|
ModelQueryLanguage: {
|
|
127
|
-
name: '@travetto/model-query-language',
|
|
201
|
+
name: '@travetto/model-query-language',
|
|
202
|
+
folder: '@travetto/model-query-language',
|
|
203
|
+
displayName: 'Data Model Query Language',
|
|
128
204
|
description: 'Datastore query language.'
|
|
129
205
|
},
|
|
130
206
|
ModelRedis: {
|
|
131
|
-
name: '@travetto/model-redis',
|
|
207
|
+
name: '@travetto/model-redis',
|
|
208
|
+
folder: '@travetto/model-redis',
|
|
209
|
+
displayName: 'Redis Model Support',
|
|
132
210
|
description: 'Redis backing for the travetto model module.'
|
|
133
211
|
},
|
|
134
212
|
ModelS3: {
|
|
135
|
-
name: '@travetto/model-s3',
|
|
213
|
+
name: '@travetto/model-s3',
|
|
214
|
+
folder: '@travetto/model-s3',
|
|
215
|
+
displayName: 'S3 Model Support',
|
|
136
216
|
description: 'S3 backing for the travetto model module.'
|
|
137
217
|
},
|
|
138
218
|
ModelSql: {
|
|
139
|
-
name: '@travetto/model-sql',
|
|
219
|
+
name: '@travetto/model-sql',
|
|
220
|
+
folder: '@travetto/model-sql',
|
|
221
|
+
displayName: 'SQL Model Service',
|
|
140
222
|
description: 'SQL backing for the travetto model module, with real-time modeling support for SQL schemas.'
|
|
141
223
|
},
|
|
142
224
|
ModelSqlite: {
|
|
143
|
-
name: '@travetto/model-sqlite',
|
|
225
|
+
name: '@travetto/model-sqlite',
|
|
226
|
+
folder: '@travetto/model-sqlite',
|
|
227
|
+
displayName: 'SQLite Model Service',
|
|
144
228
|
description: 'SQLite backing for the travetto model module, with real-time modeling support for SQL schemas.'
|
|
145
229
|
},
|
|
146
230
|
Openapi: {
|
|
147
|
-
name: '@travetto/openapi',
|
|
231
|
+
name: '@travetto/openapi',
|
|
232
|
+
folder: '@travetto/openapi',
|
|
233
|
+
displayName: 'OpenAPI Specification',
|
|
148
234
|
description: 'OpenAPI integration support for the Travetto framework'
|
|
149
235
|
},
|
|
150
236
|
Pack: {
|
|
151
|
-
name: '@travetto/pack',
|
|
237
|
+
name: '@travetto/pack',
|
|
238
|
+
folder: '@travetto/pack',
|
|
239
|
+
displayName: 'Pack',
|
|
152
240
|
description: 'Code packing utilities'
|
|
153
241
|
},
|
|
154
242
|
Registry: {
|
|
155
|
-
name: '@travetto/registry',
|
|
243
|
+
name: '@travetto/registry',
|
|
244
|
+
folder: '@travetto/registry',
|
|
245
|
+
displayName: 'Registry',
|
|
156
246
|
description: 'Patterns and utilities for handling registration of metadata and functionality for run-time use'
|
|
157
247
|
},
|
|
158
248
|
Repo: {
|
|
159
|
-
name: '@travetto/repo',
|
|
249
|
+
name: '@travetto/repo',
|
|
250
|
+
folder: '@travetto/repo',
|
|
251
|
+
displayName: 'Repo',
|
|
160
252
|
description: 'Monorepo utilities'
|
|
161
253
|
},
|
|
162
254
|
Runtime: {
|
|
163
|
-
name: '@travetto/runtime',
|
|
255
|
+
name: '@travetto/runtime',
|
|
256
|
+
folder: '@travetto/runtime',
|
|
257
|
+
displayName: 'Runtime',
|
|
164
258
|
description: 'Runtime for travetto applications.'
|
|
165
259
|
},
|
|
166
|
-
Scaffold: {
|
|
167
|
-
name: '@travetto/scaffold', folder: '@travetto/scaffold', displayName: 'App Scaffold',
|
|
168
|
-
description: 'App Scaffold for the Travetto framework'
|
|
169
|
-
},
|
|
170
260
|
Schema: {
|
|
171
|
-
name: '@travetto/schema',
|
|
261
|
+
name: '@travetto/schema',
|
|
262
|
+
folder: '@travetto/schema',
|
|
263
|
+
displayName: 'Schema',
|
|
172
264
|
description: 'Data type registry for runtime validation, reflection and binding.'
|
|
173
265
|
},
|
|
174
266
|
SchemaFaker: {
|
|
175
|
-
name: '@travetto/schema-faker',
|
|
267
|
+
name: '@travetto/schema-faker',
|
|
268
|
+
folder: '@travetto/schema-faker',
|
|
269
|
+
displayName: 'Schema Faker',
|
|
176
270
|
description: 'Data generation for schema-registered objects.'
|
|
177
271
|
},
|
|
178
272
|
Terminal: {
|
|
179
|
-
name: '@travetto/terminal',
|
|
273
|
+
name: '@travetto/terminal',
|
|
274
|
+
folder: '@travetto/terminal',
|
|
275
|
+
displayName: 'Terminal',
|
|
180
276
|
description: 'General terminal support'
|
|
181
277
|
},
|
|
182
278
|
Test: {
|
|
183
|
-
name: '@travetto/test',
|
|
279
|
+
name: '@travetto/test',
|
|
280
|
+
folder: '@travetto/test',
|
|
281
|
+
displayName: 'Testing',
|
|
184
282
|
description: 'Declarative test framework'
|
|
185
283
|
},
|
|
186
284
|
TodoApp: {
|
|
187
|
-
name: '@travetto/todo-app',
|
|
285
|
+
name: '@travetto/todo-app',
|
|
286
|
+
folder: '@travetto/todo-app',
|
|
287
|
+
displayName: 'Todo Application',
|
|
188
288
|
description: ''
|
|
189
289
|
},
|
|
190
290
|
Transformer: {
|
|
191
|
-
name: '@travetto/transformer',
|
|
291
|
+
name: '@travetto/transformer',
|
|
292
|
+
folder: '@travetto/transformer',
|
|
293
|
+
displayName: 'Transformation',
|
|
192
294
|
description: 'Functionality for AST transformations, with transformer registration, and general utils'
|
|
193
295
|
},
|
|
194
296
|
Web: {
|
|
195
|
-
name: '@travetto/web',
|
|
297
|
+
name: '@travetto/web',
|
|
298
|
+
folder: '@travetto/web',
|
|
299
|
+
displayName: 'Web API',
|
|
196
300
|
description: 'Declarative support for creating Web Applications'
|
|
197
301
|
},
|
|
198
302
|
WebAwsLambda: {
|
|
199
|
-
name: '@travetto/web-aws-lambda',
|
|
303
|
+
name: '@travetto/web-aws-lambda',
|
|
304
|
+
folder: '@travetto/web-aws-lambda',
|
|
305
|
+
displayName: 'Web AWS Lambda',
|
|
200
306
|
description: 'Web APIs entry point support for AWS Lambdas.'
|
|
201
307
|
},
|
|
202
308
|
WebConnect: {
|
|
203
|
-
name: '@travetto/web-connect',
|
|
309
|
+
name: '@travetto/web-connect',
|
|
310
|
+
folder: '@travetto/web-connect',
|
|
311
|
+
displayName: 'Web Connect Support',
|
|
204
312
|
description: 'Web integration for Connect-Like Resources'
|
|
205
313
|
},
|
|
206
314
|
WebHttp: {
|
|
207
|
-
name: '@travetto/web-http',
|
|
315
|
+
name: '@travetto/web-http',
|
|
316
|
+
folder: '@travetto/web-http',
|
|
317
|
+
displayName: 'Web HTTP Server Support',
|
|
208
318
|
description: 'Web HTTP Server Support'
|
|
209
319
|
},
|
|
210
320
|
WebRpc: {
|
|
211
|
-
name: '@travetto/web-rpc',
|
|
321
|
+
name: '@travetto/web-rpc',
|
|
322
|
+
folder: '@travetto/web-rpc',
|
|
323
|
+
displayName: 'Web RPC Support',
|
|
212
324
|
description: 'RPC support for a Web Application'
|
|
213
325
|
},
|
|
214
326
|
WebUpload: {
|
|
215
|
-
name: '@travetto/web-upload',
|
|
327
|
+
name: '@travetto/web-upload',
|
|
328
|
+
folder: '@travetto/web-upload',
|
|
329
|
+
displayName: 'Web Upload Support',
|
|
216
330
|
description: 'Provides integration between the travetto asset and web module.'
|
|
217
331
|
},
|
|
218
332
|
Worker: {
|
|
219
|
-
name: '@travetto/worker',
|
|
333
|
+
name: '@travetto/worker',
|
|
334
|
+
folder: '@travetto/worker',
|
|
335
|
+
displayName: 'Worker',
|
|
220
336
|
description: 'Process management utilities, with a focus on inter-process communication'
|
|
221
337
|
}
|
|
222
338
|
};
|
|
@@ -33,12 +33,11 @@ export function highlight(text: string, lang: string): string | undefined {
|
|
|
33
33
|
indent: 0
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
text = text
|
|
37
|
-
.replace(/&#(\d+);/g, (_, code) => String.fromCharCode(code))
|
|
38
|
-
.replace(/&[a-z][^;]*;/g, a => tokenMapping[a] || a);
|
|
36
|
+
text = text.replace(/&#(\d+);/g, (_, code) => String.fromCharCode(code)).replace(/&[a-z][^;]*;/g, a => tokenMapping[a] || a);
|
|
39
37
|
|
|
40
38
|
try {
|
|
41
|
-
return prismJs
|
|
39
|
+
return prismJs
|
|
40
|
+
.highlight(text, prismJs.languages[lang], lang)
|
|
42
41
|
.replace(/(@\s*<span[^>]*)function("\s*>)/g, (a, pre, post) => `${pre}meta${post}`)
|
|
43
42
|
.replace(/[{}]/g, a => `{{'${a}'}}`);
|
|
44
43
|
} catch (error) {
|
|
@@ -49,4 +48,3 @@ export function highlight(text: string, lang: string): string | undefined {
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
|
-
|
package/src/render/context.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
|
|
3
|
+
import { CliCommandRegistryIndex } from '@travetto/cli';
|
|
3
4
|
import { PackageUtil } from '@travetto/manifest';
|
|
4
|
-
import { castTo, RuntimeIndex } from '@travetto/runtime';
|
|
5
|
+
import { type Class, castTo, RuntimeIndex } from '@travetto/runtime';
|
|
6
|
+
import { SchemaRegistryIndex } from '@travetto/schema';
|
|
5
7
|
|
|
6
|
-
import {
|
|
8
|
+
import { createElement, JSXRuntimeTag } from '../../support/jsx-runtime.ts';
|
|
9
|
+
import { c, d, type JSXElementByFn } from '../jsx.ts';
|
|
7
10
|
import { DocResolveUtil, type ResolvedCode, type ResolvedRef, type ResolvedSnippetLink } from '../util/resolve.ts';
|
|
8
11
|
import { DocRunUtil } from '../util/run.ts';
|
|
9
|
-
import { createElement, JSXRuntimeTag } from '../../support/jsx-runtime.ts';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Render Context
|
|
13
15
|
*/
|
|
14
16
|
export class RenderContext {
|
|
15
|
-
|
|
16
17
|
#executeCache: Record<string, string> = {};
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -36,7 +37,6 @@ export class RenderContext {
|
|
|
36
37
|
repoRoot: string;
|
|
37
38
|
|
|
38
39
|
constructor(file: string, baseUrl: string, repoRoot: string) {
|
|
39
|
-
|
|
40
40
|
const manifestPkg = PackageUtil.readPackage(RuntimeIndex.getModule('@travetto/manifest')!.sourcePath);
|
|
41
41
|
|
|
42
42
|
this.file = path.resolve(file);
|
|
@@ -62,9 +62,10 @@ export class RenderContext {
|
|
|
62
62
|
/**
|
|
63
63
|
* Generate link location
|
|
64
64
|
*/
|
|
65
|
-
link(text: string, line?: number | { [key: string]: unknown
|
|
65
|
+
link(text: string, line?: number | { [key: string]: unknown; line?: number }): string {
|
|
66
66
|
const num = typeof line === 'number' ? line : line?.line;
|
|
67
|
-
return `${text
|
|
67
|
+
return `${text
|
|
68
|
+
.replace(this.repoRoot, this.baseUrl)
|
|
68
69
|
.replace(/.*@travetto\//, `${this.travettoBaseUrl}/module/`)}${num && num > 1 ? `#L${num}` : ''}`;
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -79,7 +80,12 @@ export class RenderContext {
|
|
|
79
80
|
* Get a consistent anchor id
|
|
80
81
|
*/
|
|
81
82
|
getAnchorId(a: string): string {
|
|
82
|
-
return a
|
|
83
|
+
return a
|
|
84
|
+
.toLowerCase()
|
|
85
|
+
.replace(/<[^>]+>/g, ' ')
|
|
86
|
+
.replace(/[^a-z0-9]+/g, ' ')
|
|
87
|
+
.trim()
|
|
88
|
+
.replace(/ /g, '-');
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
/**
|
|
@@ -93,7 +99,16 @@ export class RenderContext {
|
|
|
93
99
|
|
|
94
100
|
const { cmd, args = [], config = {} } = node.props;
|
|
95
101
|
const result = await DocRunUtil.run(cmd, args, config);
|
|
96
|
-
return this.#executeCache[key] = result;
|
|
102
|
+
return (this.#executeCache[key] = result);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Resolve CLI command metadata for a class from cli:schema output.
|
|
107
|
+
*/
|
|
108
|
+
resolveCliCommandFromClass(commandClass: Class): { name: string; description?: string } {
|
|
109
|
+
const { name } = CliCommandRegistryIndex.get(commandClass);
|
|
110
|
+
const { description } = SchemaRegistryIndex.getConfig(commandClass);
|
|
111
|
+
return { name, description };
|
|
97
112
|
}
|
|
98
113
|
|
|
99
114
|
/**
|
|
@@ -114,9 +129,9 @@ export class RenderContext {
|
|
|
114
129
|
* Resolve code/config
|
|
115
130
|
*/
|
|
116
131
|
async resolveCode(node: JSXElementByFn<'Code' | 'Config'>): Promise<ResolvedCode> {
|
|
117
|
-
return node.props.startRe
|
|
118
|
-
DocResolveUtil.resolveSnippet(node.props.src, node.props.startRe, node.props.endRe, node.props.outline)
|
|
119
|
-
DocResolveUtil.resolveCode(node.props.src, node.props.language, node.props.outline);
|
|
132
|
+
return node.props.startRe
|
|
133
|
+
? DocResolveUtil.resolveSnippet(node.props.src, node.props.startRe, node.props.endRe, node.props.outline)
|
|
134
|
+
: DocResolveUtil.resolveCode(node.props.src, node.props.language, node.props.outline);
|
|
120
135
|
}
|
|
121
136
|
|
|
122
137
|
/**
|
|
@@ -126,4 +141,4 @@ export class RenderContext {
|
|
|
126
141
|
// @ts-expect-error
|
|
127
142
|
return castTo(createElement(c[name], props));
|
|
128
143
|
}
|
|
129
|
-
}
|
|
144
|
+
}
|
package/src/render/html.ts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import markdown from 'markdown-it';
|
|
4
|
+
|
|
5
|
+
import { HELP_FLAG } from '@travetto/cli';
|
|
4
6
|
import { PackageUtil } from '@travetto/manifest';
|
|
7
|
+
import { CodecUtil, Runtime, RuntimeError, RuntimeIndex } from '@travetto/runtime';
|
|
5
8
|
|
|
6
|
-
import {
|
|
7
|
-
import type { RenderProvider, RenderState } from '../types.ts';
|
|
9
|
+
import type { JSXElement } from '../../support/jsx-runtime.ts';
|
|
8
10
|
import { c, getComponentName } from '../jsx.ts';
|
|
9
|
-
import { MODULES } from '../mapping/module.ts';
|
|
10
11
|
import { LIBRARIES } from '../mapping/library.ts';
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import type { JSXElement } from '../../support/jsx-runtime.ts';
|
|
12
|
+
import { MODULES } from '../mapping/module.ts';
|
|
13
|
+
import type { RenderProvider, RenderState } from '../types.ts';
|
|
14
14
|
import { PackageDocUtil } from '../util/package.ts';
|
|
15
|
+
import { DocResolveUtil } from '../util/resolve.ts';
|
|
16
|
+
import { highlight } from './code-highlight.ts';
|
|
17
|
+
import type { RenderContext } from './context.ts';
|
|
15
18
|
|
|
16
19
|
const ESCAPE_ENTITIES: Record<string, string> = { '<': '<', '>': '>', '&': '&', '{': "{{'{'}}", '}': "{{'}'}}" };
|
|
17
20
|
const ENTITY_REGEX = new RegExp(`[${Object.keys(ESCAPE_ENTITIES).join('')}]`, 'gm');
|
|
21
|
+
const md = new markdown({ html: false });
|
|
18
22
|
|
|
19
23
|
const stdInline = async ({ recurse, node }: RenderState<JSXElement, RenderContext>): Promise<string> =>
|
|
20
24
|
`<${node.type}>${await recurse()}</${node.type}>`;
|
|
@@ -36,14 +40,23 @@ export const Html: RenderProvider<RenderContext> = {
|
|
|
36
40
|
},
|
|
37
41
|
br: async () => '<br><br>\n',
|
|
38
42
|
hr: async () => '<hr>\n',
|
|
39
|
-
strong: stdInline,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
strong: stdInline,
|
|
44
|
+
em: stdInline,
|
|
45
|
+
h2: stdFull,
|
|
46
|
+
h3: stdFull,
|
|
47
|
+
h4: stdFull,
|
|
48
|
+
li: std,
|
|
49
|
+
ol: stdFull,
|
|
50
|
+
ul: stdFull,
|
|
51
|
+
table: stdFull,
|
|
52
|
+
thead: std,
|
|
53
|
+
tr: std,
|
|
54
|
+
td: std,
|
|
55
|
+
tbody: std,
|
|
43
56
|
Execution: async ({ context, node, props, createState }) => {
|
|
44
57
|
const output = await context.execute(node);
|
|
45
|
-
const displayCmd =
|
|
46
|
-
`${node.props.cmd} ${(node.props.args ?? []).join(' ')}`;
|
|
58
|
+
const displayCmd =
|
|
59
|
+
props.config?.formatCommand?.(props.cmd, props.args ?? []) ?? `${node.props.cmd} ${(node.props.args ?? []).join(' ')}`;
|
|
47
60
|
const sub = createState('Terminal', {
|
|
48
61
|
language: 'bash',
|
|
49
62
|
title: props.title,
|
|
@@ -51,10 +64,39 @@ export const Html: RenderProvider<RenderContext> = {
|
|
|
51
64
|
});
|
|
52
65
|
return Html.Terminal(sub);
|
|
53
66
|
},
|
|
67
|
+
CliHelpExecution: async ({ context, props, createState }) => {
|
|
68
|
+
const config = context.resolveCliCommandFromClass(props.commandClass);
|
|
69
|
+
const { name: command } = config;
|
|
70
|
+
return Html.Execution(
|
|
71
|
+
createState('Execution', {
|
|
72
|
+
title: `Showing help for ${command}`,
|
|
73
|
+
cmd: 'trv',
|
|
74
|
+
args: [command, HELP_FLAG],
|
|
75
|
+
config: { ...props.config }
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
CliHelpDescription: async ({ context, props }) => {
|
|
80
|
+
const config = context.resolveCliCommandFromClass(props.commandClass);
|
|
81
|
+
let text = config.description ?? '';
|
|
82
|
+
if (props.short) {
|
|
83
|
+
text = CodecUtil.readFirstLine(text);
|
|
84
|
+
}
|
|
85
|
+
return md.render(text);
|
|
86
|
+
},
|
|
87
|
+
CliHelpSection: async ({ context, props, recurse }) => {
|
|
88
|
+
const config = context.resolveCliCommandFromClass(props.commandClass);
|
|
89
|
+
const { name: command } = config;
|
|
90
|
+
const title = `CLI - ${command}`;
|
|
91
|
+
return `\n<h2 id="${context.getAnchorId(title)}">${title}</h2>\n\n${await recurse()}`;
|
|
92
|
+
},
|
|
54
93
|
Install: async ({ context, node }) => {
|
|
55
|
-
const highlighted = highlight(
|
|
94
|
+
const highlighted = highlight(
|
|
95
|
+
`
|
|
56
96
|
${PackageDocUtil.getInstallInstructions(node.props.pkg, true)}
|
|
57
|
-
`,
|
|
97
|
+
`,
|
|
98
|
+
'bash'
|
|
99
|
+
);
|
|
58
100
|
|
|
59
101
|
return `\n
|
|
60
102
|
<figure class="install">
|
|
@@ -74,7 +116,7 @@ ${PackageDocUtil.getInstallInstructions(node.props.pkg, true)}
|
|
|
74
116
|
const content = await context.resolveCode(node);
|
|
75
117
|
let link: string = '';
|
|
76
118
|
if ('src' in props && content.file) {
|
|
77
|
-
let linkCtx: { file: string
|
|
119
|
+
let linkCtx: { file: string; line?: number } = { file: content.file! };
|
|
78
120
|
if (props.startRe) {
|
|
79
121
|
linkCtx = await DocResolveUtil.resolveCodeLink(linkCtx.file, props.startRe);
|
|
80
122
|
}
|
|
@@ -121,11 +163,10 @@ ${PackageDocUtil.getInstallInstructions(node.props.pkg, true)}
|
|
|
121
163
|
`<a class="anchor-link" routerLink="." fragment="${context.getAnchorId(props.href)}">${props.title}</a>`,
|
|
122
164
|
|
|
123
165
|
File: state => Html.Ref(state),
|
|
124
|
-
Ref: async ({ context, props }) =>
|
|
125
|
-
`<a target="_blank" class="source-link" href="${context.link(props.href, props)}">${props.title}</a>`,
|
|
166
|
+
Ref: async ({ context, props }) => `<a target="_blank" class="source-link" href="${context.link(props.href, props)}">${props.title}</a>`,
|
|
126
167
|
Image: async ({ context, props }) => {
|
|
127
|
-
if (!/^https?:/.test(props.href) && !(await fs.stat(props.href
|
|
128
|
-
throw new
|
|
168
|
+
if (!/^https?:/.test(props.href) && !(await fs.stat(props.href, { throwIfNoEntry: false }))) {
|
|
169
|
+
throw new RuntimeError(`${props.href} is not a valid location`);
|
|
129
170
|
}
|
|
130
171
|
return `<img src="${context.link(props.href, props)}" alt="${props.title}">`;
|
|
131
172
|
},
|
|
@@ -151,10 +192,10 @@ ${PackageDocUtil.getInstallInstructions(node.props.pkg, true)}
|
|
|
151
192
|
if (state.node.props.install !== false) {
|
|
152
193
|
const sub = state.createState('Install', {
|
|
153
194
|
title: pkg.name,
|
|
154
|
-
pkg: pkg.name
|
|
195
|
+
pkg: pkg.name
|
|
155
196
|
});
|
|
156
197
|
install = await Html.Install(sub);
|
|
157
198
|
}
|
|
158
199
|
return `<h1>${title}${desc ? `\n<small>${desc}</small>\n` : ''}</h1>\n${install}\n`;
|
|
159
200
|
}
|
|
160
|
-
};
|
|
201
|
+
};
|