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