@travetto/doc 5.0.0-rc.1 → 5.0.0-rc.2
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/package.json +3 -3
- package/src/jsx.ts +1 -1
- package/src/mapping/mod-mapping.ts +1 -1
- package/src/render/context.ts +7 -4
- package/src/render/html.ts +3 -3
- package/src/render/markdown.ts +3 -3
- package/src/render/renderer.ts +6 -5
- package/src/util/file.ts +2 -1
- package/src/util/run.ts +4 -5
- package/support/cli.doc.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/doc",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.2",
|
|
4
4
|
"description": "Documentation support for the Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"directory": "module/doc"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@travetto/
|
|
27
|
+
"@travetto/runtime": "^5.0.0-rc.2",
|
|
28
28
|
"@types/prismjs": "^1.26.4",
|
|
29
29
|
"prismjs": "^1.29.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@travetto/cli": "^5.0.0-rc.
|
|
32
|
+
"@travetto/cli": "^5.0.0-rc.2"
|
|
33
33
|
},
|
|
34
34
|
"peerDependenciesMeta": {
|
|
35
35
|
"@travetto/cli": {
|
package/src/jsx.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createElement, JSXElement, JSXComponentFunction as CompFn } from '@travetto/doc/jsx-runtime';
|
|
2
|
-
import { TypedObject } from '@travetto/
|
|
2
|
+
import { TypedObject } from '@travetto/runtime';
|
|
3
3
|
|
|
4
4
|
import { LIB_MAPPING } from './mapping/lib-mapping';
|
|
5
5
|
import { MOD_MAPPING } from './mapping/mod-mapping';
|
|
@@ -32,7 +32,7 @@ export const MOD_MAPPING = {
|
|
|
32
32
|
description: 'Rest authentication session integration support for the Travetto framework'
|
|
33
33
|
},
|
|
34
34
|
Base: {
|
|
35
|
-
name: '@travetto/
|
|
35
|
+
name: '@travetto/runtime', folder: '@travetto/runtime', displayName: 'Base',
|
|
36
36
|
description: 'Environment config and common utilities for travetto applications.'
|
|
37
37
|
},
|
|
38
38
|
Cache: {
|
package/src/render/context.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
1
3
|
import { createElement, JSXRuntimeTag } from '@travetto/doc/jsx-runtime';
|
|
2
4
|
|
|
3
|
-
import {
|
|
5
|
+
import { PackageUtil } from '@travetto/manifest';
|
|
6
|
+
import { Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
4
7
|
|
|
5
8
|
import { JSXElementByFn, c } from '../jsx';
|
|
6
9
|
import { DocResolveUtil, ResolvedCode, ResolvedRef, ResolvedSnippetLink } from '../util/resolve';
|
|
@@ -37,7 +40,7 @@ export class RenderContext {
|
|
|
37
40
|
|
|
38
41
|
const manifestPkg = PackageUtil.readPackage(RuntimeIndex.getModule('@travetto/manifest')!.sourcePath);
|
|
39
42
|
|
|
40
|
-
this.file = path.
|
|
43
|
+
this.file = path.resolve(file);
|
|
41
44
|
this.baseUrl = baseUrl;
|
|
42
45
|
this.repoRoot = repoRoot;
|
|
43
46
|
this.travettoBaseUrl = repoRoot.includes('travetto.github') ? repoRoot : manifestPkg.travetto!.doc!.baseUrl!;
|
|
@@ -105,7 +108,7 @@ export class RenderContext {
|
|
|
105
108
|
* Resolve code link
|
|
106
109
|
*/
|
|
107
110
|
async resolveCodeLink(node: JSXElementByFn<'CodeLink'>): Promise<ResolvedSnippetLink> {
|
|
108
|
-
const src = typeof node.props.src === 'string' ? node.props.src :
|
|
111
|
+
const src = typeof node.props.src === 'string' ? node.props.src : Runtime.getSource(node.props.src);
|
|
109
112
|
return DocResolveUtil.resolveCodeLink(src, node.props.startRe);
|
|
110
113
|
}
|
|
111
114
|
|
|
@@ -113,7 +116,7 @@ export class RenderContext {
|
|
|
113
116
|
* Resolve code/config
|
|
114
117
|
*/
|
|
115
118
|
async resolveCode(node: JSXElementByFn<'Code' | 'Config'>): Promise<ResolvedCode> {
|
|
116
|
-
const src = typeof node.props.src === 'string' ? node.props.src :
|
|
119
|
+
const src = typeof node.props.src === 'string' ? node.props.src : Runtime.getSource(node.props.src);
|
|
117
120
|
return node.props.startRe ?
|
|
118
121
|
DocResolveUtil.resolveSnippet(src, node.props.startRe, node.props.endRe, node.props.outline) :
|
|
119
122
|
DocResolveUtil.resolveCode(src, node.props.language, node.props.outline);
|
package/src/render/html.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
|
|
3
3
|
import { JSXElement } from '@travetto/doc/jsx-runtime';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
5
|
+
import { PackageUtil } from '@travetto/manifest';
|
|
6
6
|
|
|
7
7
|
import { highlight } from './code-highlight';
|
|
8
8
|
import { RenderProvider, RenderState } from '../types';
|
|
@@ -145,7 +145,7 @@ yarn add ${el.props.pkg}
|
|
|
145
145
|
Header: async ({ props }) => `<h1>${props.title} ${props.description ? `\n<small>${props.description}</small>\n` : ''}</h1>\n`,
|
|
146
146
|
|
|
147
147
|
StdHeader: async state => {
|
|
148
|
-
const mod = state.el.props.mod ??
|
|
148
|
+
const mod = state.el.props.mod ?? Runtime.main.name;
|
|
149
149
|
const pkg = PackageUtil.readPackage(RuntimeIndex.getModule(mod)!.sourcePath);
|
|
150
150
|
const title = pkg.travetto?.displayName ?? pkg.name;
|
|
151
151
|
const desc = pkg.description;
|
package/src/render/markdown.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
-
import {
|
|
3
|
-
import { PackageUtil
|
|
2
|
+
import { Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
3
|
+
import { PackageUtil } from '@travetto/manifest';
|
|
4
4
|
|
|
5
5
|
import { RenderProvider } from '../types';
|
|
6
6
|
import { c, getComponentName } from '../jsx';
|
|
@@ -109,7 +109,7 @@ ${context.cleanText(content.text)}
|
|
|
109
109
|
Header: async ({ props }) => `# ${props.title}\n${props.description ? `## ${props.description}\n` : ''}\n`,
|
|
110
110
|
|
|
111
111
|
StdHeader: async state => {
|
|
112
|
-
const mod = state.el.props.mod ??
|
|
112
|
+
const mod = state.el.props.mod ?? Runtime.main.name;
|
|
113
113
|
const pkg = PackageUtil.readPackage(RuntimeIndex.getModule(mod)!.sourcePath);
|
|
114
114
|
const title = pkg.travetto?.displayName ?? pkg.name;
|
|
115
115
|
const desc = pkg.description;
|
package/src/render/renderer.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
|
|
3
|
-
import { type ManifestContext, PackageUtil
|
|
3
|
+
import { type ManifestContext, PackageUtil } from '@travetto/manifest';
|
|
4
4
|
import { isJSXElement, JSXElement, JSXFragmentType } from '@travetto/doc/jsx-runtime';
|
|
5
|
+
import { Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
5
6
|
|
|
6
7
|
import { EMPTY_ELEMENT, getComponentName, JSXElementByFn, c } from '../jsx';
|
|
7
8
|
import { DocumentShape, RenderProvider, RenderState } from '../types';
|
|
@@ -93,11 +94,11 @@ export class DocRenderer {
|
|
|
93
94
|
case 'bigint':
|
|
94
95
|
case 'boolean': return `${node}`;
|
|
95
96
|
default: {
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
const title = (await DocFileUtil.isDecorator(node.name,
|
|
97
|
+
const source = typeof node === 'function' ? Runtime.getSource(node) : undefined;
|
|
98
|
+
if (source && typeof node === 'function') {
|
|
99
|
+
const title = (await DocFileUtil.isDecorator(node.name, source)) ? `@${node.name}` : node.name;
|
|
99
100
|
const el = this.#support.createElement('CodeLink', {
|
|
100
|
-
src:
|
|
101
|
+
src: source,
|
|
101
102
|
startRe: new RegExp(`(class|function)\\s+(${node.name})`),
|
|
102
103
|
title
|
|
103
104
|
});
|
package/src/util/file.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
-
import { ManifestModuleUtil
|
|
4
|
+
import { ManifestModuleUtil } from '@travetto/manifest';
|
|
5
|
+
import { RuntimeIndex } from '@travetto/runtime';
|
|
5
6
|
|
|
6
7
|
const ESLINT_PATTERN = /\s*\/\/ eslint.*$/g;
|
|
7
8
|
const ENV_KEY = /Env.([^.]+)[.]key/g;
|
package/src/util/run.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import util from 'node:util';
|
|
3
3
|
import { spawn, ChildProcess } from 'node:child_process';
|
|
4
|
+
import path from 'node:path';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
-
import { Env, ExecUtil, RuntimeContext } from '@travetto/base';
|
|
6
|
+
import { Env, ExecUtil, Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
7
7
|
|
|
8
8
|
export const COMMON_DATE = new Date('2029-03-14T00:00:00.000').getTime();
|
|
9
9
|
|
|
@@ -47,7 +47,7 @@ export class DocRunUtil {
|
|
|
47
47
|
|
|
48
48
|
/** Build cwd from config */
|
|
49
49
|
static cwd(cfg: RunConfig): string {
|
|
50
|
-
return path.
|
|
50
|
+
return path.resolve(cfg.module ? RuntimeIndex.getModule(cfg.module)?.sourcePath! : Runtime.mainSourcePath);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
@@ -58,7 +58,7 @@ export class DocRunUtil {
|
|
|
58
58
|
text = util.stripVTControlCharacters(text.trim())
|
|
59
59
|
.replaceAll(cwd, '.')
|
|
60
60
|
.replaceAll(os.tmpdir(), '/tmp')
|
|
61
|
-
.replaceAll(
|
|
61
|
+
.replaceAll(Runtime.workspace.path, '<workspace-root>')
|
|
62
62
|
.replace(/[/]tmp[/][a-z_A-Z0-9\/\-]+/g, '/tmp/<temp-folder>')
|
|
63
63
|
.replace(/^(\s*framework:\s*')(\d+[.]\d+)[^']*('[,]?\s*)$/gm, (_, pre, ver, post) => `${pre}${ver}.x${post}`)
|
|
64
64
|
.replace(/^(\s*nodeVersion:\s*'v)(\d+)[^']*('[,]?\s*)$/gm, (_, pre, ver, post) => `${pre}${ver}.x.x${post}`)
|
|
@@ -90,7 +90,6 @@ export class DocRunUtil {
|
|
|
90
90
|
...Env.TRV_CLI_IPC.export(undefined),
|
|
91
91
|
...Env.TRV_MANIFEST.export(''),
|
|
92
92
|
...Env.TRV_BUILD.export('none'),
|
|
93
|
-
...Env.TRV_BUILD_REENTRANT.export(true),
|
|
94
93
|
...Env.TRV_ROLE.export(undefined),
|
|
95
94
|
...Env.TRV_MODULE.export(config.module ?? ''),
|
|
96
95
|
...(config.envName ? Env.TRV_ENV.export(config.envName) : {}),
|
package/support/cli.doc.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { spawn } from 'node:child_process';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
|
|
5
5
|
import { PackageUtil } from '@travetto/manifest';
|
|
6
|
-
import { ExecUtil, Env, watchCompiler,
|
|
6
|
+
import { ExecUtil, Env, watchCompiler, Runtime } from '@travetto/runtime';
|
|
7
7
|
import { CliCommandShape, CliCommand, CliValidationError, CliUtil } from '@travetto/cli';
|
|
8
8
|
import { MinLength } from '@travetto/schema';
|
|
9
9
|
|
|
@@ -32,7 +32,7 @@ export class DocCommand implements CliCommandShape {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
preBind(): void {
|
|
35
|
-
const workspacePkg = PackageUtil.readPackage(
|
|
35
|
+
const workspacePkg = PackageUtil.readPackage(Runtime.workspace.path);
|
|
36
36
|
this.outputs = workspacePkg.travetto?.doc?.outputs ?? ['README.md'];
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -56,7 +56,7 @@ export class DocCommand implements CliCommandShape {
|
|
|
56
56
|
for await (const { action, file } of watchCompiler({ restartOnExit: true })) {
|
|
57
57
|
if (action === 'update' && file === this.input) {
|
|
58
58
|
const proc = spawn('npx', ['trv', ...args], {
|
|
59
|
-
cwd:
|
|
59
|
+
cwd: Runtime.mainSourcePath,
|
|
60
60
|
shell: false,
|
|
61
61
|
env: { ...process.env, ...Env.TRV_QUIET.export(true) },
|
|
62
62
|
stdio: 'inherit'
|
|
@@ -68,7 +68,7 @@ export class DocCommand implements CliCommandShape {
|
|
|
68
68
|
|
|
69
69
|
async render(): Promise<void> {
|
|
70
70
|
const { DocRenderer } = await import('../src/render/renderer');
|
|
71
|
-
const ctx = await DocRenderer.get(this.input,
|
|
71
|
+
const ctx = await DocRenderer.get(this.input, Runtime);
|
|
72
72
|
const outputs = this.outputs.map(output =>
|
|
73
73
|
output.includes('.') ? [path.extname(output).replace('.', ''), path.resolve(output)] :
|
|
74
74
|
[output, null] as const
|