@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.
@@ -1,222 +1,338 @@
1
1
  export const MODULES = {
2
2
  Auth: {
3
- name: '@travetto/auth', folder: '@travetto/auth', displayName: 'Authentication',
4
- description: 'Authentication scaffolding for the Travetto framework'
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', folder: '@travetto/auth-model', displayName: 'Authentication 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', folder: '@travetto/auth-session', displayName: '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', folder: '@travetto/auth-web', displayName: 'Web Auth',
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', folder: '@travetto/auth-web-passport', displayName: 'Web Auth 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', folder: '@travetto/auth-web-session', displayName: 'Web Auth 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', folder: '@travetto/cache', displayName: 'Caching',
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', folder: '@travetto/cli', displayName: 'Command Line Interface',
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', folder: '@travetto/compiler', displayName: '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', folder: '@travetto/config', displayName: 'Configuration',
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', folder: '@travetto/context', displayName: 'Async 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', folder: '@travetto/di', displayName: 'Dependency Injection',
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', folder: '@travetto/doc', displayName: 'Documentation',
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', folder: '@travetto/email', displayName: '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', folder: '@travetto/email-compiler', displayName: 'Email Compilation Support',
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', folder: '@travetto/email-inky', displayName: 'Email Inky Templates',
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', folder: '@travetto/email-nodemailer', displayName: 'Email Nodemailer Support',
99
+ name: '@travetto/email-nodemailer',
100
+ folder: '@travetto/email-nodemailer',
101
+ displayName: 'Email Nodemailer Support',
68
102
  description: 'Email transmission module.'
69
103
  },
70
- Eslint: {
71
- name: '@travetto/eslint', folder: '@travetto/eslint', displayName: 'ES Linting Rules',
72
- description: 'ES Linting Rules'
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', folder: '@travetto/image', displayName: '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', folder: '@travetto/log', displayName: 'Logging',
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', folder: '@travetto/manifest', displayName: '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', folder: '@travetto/model', displayName: 'Data Modeling Support',
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', folder: '@travetto/model-dynamodb', displayName: 'DynamoDB Model Support',
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', folder: '@travetto/model-elasticsearch', displayName: 'Elasticsearch Model Source',
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', folder: '@travetto/model-file', displayName: 'File Model Support',
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', folder: '@travetto/model-firestore', displayName: 'Firestore Model Support',
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', folder: '@travetto/model-memory', displayName: 'Memory Model Support',
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', folder: '@travetto/model-mongo', displayName: 'MongoDB Model Support',
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', folder: '@travetto/model-mysql', displayName: 'MySQL Model Service',
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', folder: '@travetto/model-postgres', displayName: 'PostgreSQL Model Service',
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', folder: '@travetto/model-query', displayName: 'Data Model Querying',
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', folder: '@travetto/model-query-language', displayName: 'Data 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', folder: '@travetto/model-redis', displayName: 'Redis Model Support',
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', folder: '@travetto/model-s3', displayName: 'S3 Model Support',
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', folder: '@travetto/model-sql', displayName: 'SQL Model Service',
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', folder: '@travetto/model-sqlite', displayName: 'SQLite Model Service',
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', folder: '@travetto/openapi', displayName: 'OpenAPI Specification',
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', folder: '@travetto/pack', displayName: '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', folder: '@travetto/registry', displayName: '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', folder: '@travetto/repo', displayName: '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', folder: '@travetto/runtime', displayName: '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', folder: '@travetto/schema', displayName: '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', folder: '@travetto/schema-faker', displayName: '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', folder: '@travetto/terminal', displayName: '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', folder: '@travetto/test', displayName: 'Testing',
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', folder: '@travetto/todo-app', displayName: 'Todo Application',
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', folder: '@travetto/transformer', displayName: 'Transformation',
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', folder: '@travetto/web', displayName: 'Web API',
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', folder: '@travetto/web-aws-lambda', displayName: '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', folder: '@travetto/web-connect', displayName: 'Web Connect Support',
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', folder: '@travetto/web-http', displayName: 'Web HTTP Server Support',
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', folder: '@travetto/web-rpc', displayName: 'Web RPC Support',
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', folder: '@travetto/web-upload', displayName: 'Web Upload Support',
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', folder: '@travetto/worker', displayName: '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.highlight(text, prismJs.languages[lang], lang)
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
-
@@ -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 { type JSXElementByFn, c, d } from '../jsx.ts';
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, line?: number }): string {
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.replace(this.repoRoot, this.baseUrl)
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.toLowerCase().replace(/<[^>]+>/g, ' ').replace(/[^a-z0-9]+/g, ' ').trim().replace(/ /g, '-');
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
+ }
@@ -1,20 +1,24 @@
1
1
  import fs from 'node:fs/promises';
2
2
 
3
- import { Runtime, RuntimeIndex } from '@travetto/runtime';
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 { highlight } from './code-highlight.ts';
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 type { RenderContext } from './context.ts';
12
- import { DocResolveUtil } from '../util/resolve.ts';
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> = { '<': '&lt;', '>': '&gt;', '&': '&amp;', '{': "{{'{'}}", '}': "{{'}'}}" };
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, em: stdInline,
40
- h2: stdFull, h3: stdFull, h4: stdFull,
41
- li: std, ol: stdFull, ul: stdFull,
42
- table: stdFull, thead: std, tr: std, td: std, tbody: std,
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 = props.config?.formatCommand?.(props.cmd, props.args ?? []) ??
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
- `, 'bash');
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, line?: number } = { file: content.file! };
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).catch(() => false))) {
128
- throw new Error(`${props.href} is not a valid location`);
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
+ };