Skip to content

Commit 49bbb18

Browse files
committed
docs: ng19 typedoc fixes
1 parent d5ed28f commit 49bbb18

File tree

19 files changed

+1360
-766
lines changed

19 files changed

+1360
-766
lines changed

.eslintrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@
212212
"types": "prefer-import"
213213
}
214214
],
215-
"@typescript-eslint/type-annotation-spacing": "error",
216215
"@typescript-eslint/unified-signatures": "error",
217216
"arrow-body-style": "error",
218217
"arrow-parens": ["off", "always"],

libs/core/project.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"compile-typedoc": {
1313
"executor": "@fundamental-ngx/nx-plugin:compile-typedoc",
1414
"options": {
15-
"outputPath": "libs/docs/typedoc/core"
15+
"outputPath": "libs/docs/typedoc/core",
16+
"tsConfig": "libs/core/tsconfig.typedoc.json"
1617
},
1718
"outputs": ["{options.outputPath}"]
1819
},

libs/core/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"files": [],
44
"include": [],
55
"references": [
6+
{
7+
"path": "./tsconfig.typedoc.json"
8+
},
69
{
710
"path": "./tsconfig.lib.json"
811
},

libs/core/tsconfig.typedoc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"target": "ES2022",
6+
"declaration": true,
7+
"declarationMap": true,
8+
"types": [],
9+
"lib": ["dom", "es2018"],
10+
"useDefineForClassFields": false,
11+
"jsx": "react",
12+
"jsxFactory": "JSX.createElement",
13+
"jsxFragmentFactory": "JSX.Fragment"
14+
},
15+
"angularCompilerOptions": {
16+
"skipTemplateCodegen": true,
17+
"strictMetadataEmit": true,
18+
"enableResourceInlining": true
19+
},
20+
"files": ["./index.ts"]
21+
}

libs/cx/project.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"compile-typedoc": {
1313
"executor": "@fundamental-ngx/nx-plugin:compile-typedoc",
1414
"options": {
15-
"outputPath": "libs/docs/typedoc/cx"
15+
"outputPath": "libs/docs/typedoc/cx",
16+
"tsConfig": "libs/cx/tsconfig.typedoc.json"
1617
},
1718
"outputs": ["{options.outputPath}"]
1819
},

libs/cx/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"files": [],
44
"include": [],
55
"references": [
6+
{
7+
"path": "./tsconfig.typedoc.json"
8+
},
69
{
710
"path": "./tsconfig.lib.json"
811
},

libs/cx/tsconfig.typedoc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"target": "ES2022",
6+
"declaration": true,
7+
"declarationMap": true,
8+
"types": [],
9+
"lib": ["dom", "es2018"],
10+
"useDefineForClassFields": false,
11+
"jsx": "react",
12+
"jsxFactory": "JSX.createElement",
13+
"jsxFragmentFactory": "JSX.Fragment"
14+
},
15+
"angularCompilerOptions": {
16+
"skipTemplateCodegen": true,
17+
"strictMetadataEmit": true,
18+
"enableResourceInlining": true
19+
},
20+
"files": ["./index.ts"]
21+
}

libs/nx-plugin/src/executors/compile-typedoc/executor.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default async function compileTypedocs(_options: CompileTypedocExecutorSc
2525
},
2626
context
2727
);
28-
const { tsConfig } = readTargetOptions({ project: context.projectName as string, target: 'build' }, context);
28+
const tsConfig: string = _options.tsConfig || readTargetOptions({ project: context.projectName as string, target: 'build' }, context).tsConfig;
2929
const ngPackageJsonFiles = fastGlobSync(projectPath + '/**/*/ng-package.json');
3030
const entryPoints = ngPackageJsonFiles.map((f) => {
3131
const json = JSON.parse(readFileSync(f, 'utf-8'));
@@ -44,11 +44,6 @@ export default async function compileTypedocs(_options: CompileTypedocExecutorSc
4444
plugin: ['typedoc-plugin-merge-modules'],
4545
mergeModulesRenameDefaults: true,
4646
mergeModulesMergeMode: 'project',
47-
compilerOptions: {
48-
jsx: 'react',
49-
jsxFactory: 'JSX.createElement',
50-
jsxFragmentFactory: 'JSX.Fragment'
51-
},
5247
theme: 'fd-typedoc'
5348
} as unknown as Partial<TypeDocOptions>);
5449
app.options.addReader(new TSConfigReader());
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export interface CompileTypedocExecutorSchema {
22
outputPath: string;
3+
tsConfig?: string;
34
}

libs/nx-plugin/src/executors/compile-typedoc/schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
"outputPath": {
99
"type": "string",
1010
"description": "Path to the output directory"
11+
},
12+
"tsConfig": {
13+
"type": "string",
14+
"description": "Path to the tsconfig file. If not provided, the executor will pick the 'build' target's tsConfig"
1115
}
1216
},
1317
"required": []

libs/nx-plugin/src/executors/compile-typedoc/theme/index.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import {
33
DeclarationHierarchy,
44
DeclarationReflection,
55
DefaultThemeRenderContext,
6-
DocumentReflection,
76
JSX,
87
PageEvent,
98
Reflection,
109
RenderTemplate,
1110
SignatureReflection,
12-
SomeType
11+
Type
1312
} from 'typedoc';
1413
import { index } from './partials';
1514
import { comment } from './partials/comment';
@@ -26,18 +25,13 @@ import { reflectionTemplate } from './partials/reflection';
2625
import { type } from './partials/type';
2726

2827
export class FdThemeContext extends DefaultThemeRenderContext {
28+
override analytics = () => <></>;
2929
override footer = () => <></>;
3030
override header = () => <></>;
3131
override sidebar = () => <></>;
3232
override pageSidebar = () => <></>;
3333
override toolbar = () => <></>;
34-
override member = (props: DeclarationReflection | DocumentReflection) => {
35-
if (props instanceof DeclarationReflection || props instanceof SignatureReflection) {
36-
return member(this, props);
37-
}
38-
// Handle DocumentReflection accordingly, if needed
39-
return <>{JSON.stringify(props)}</>; // Example placeholder for handling DocumentReflection
40-
};
34+
override member = (props: DeclarationReflection) => member(this, props);
4135
override memberSignatures = (props: DeclarationReflection) => memberSignatures(this, props);
4236
comment = (props: Reflection) => comment(props);
4337
override commentTags = (props: Reflection) => commentTags(this, props);
@@ -53,7 +47,7 @@ export class FdThemeContext extends DefaultThemeRenderContext {
5347

5448
override memberGetterSetter = (props: DeclarationReflection) => memberGetterSetter(this, props);
5549

56-
override type = (tp: SomeType | undefined) => type(this, tp);
50+
override type = (tp: Type | undefined) => type(this, tp);
5751

5852
override reflectionTemplate = (props: PageEvent<ContainerReflection>) => reflectionTemplate(this, props);
5953
}

libs/nx-plugin/src/executors/compile-typedoc/theme/partials/member.declaration.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import { DeclarationReflection, DefaultThemeRenderContext, JSX } from 'typedoc';
1+
import { DeclarationReflection, DefaultThemeRenderContext, JSX, ReflectionType } from 'typedoc';
22
import { getKindClass, hasTypeParameters, renderTypeParametersSignature, wbr } from '../utils';
33

44
export function memberDeclaration(context: DefaultThemeRenderContext, props: DeclarationReflection) {
5+
function renderTypeDeclaration(type: ReflectionType) {
6+
return (
7+
<div class="tsd-type-declaration">
8+
<h4>Type declaration</h4>
9+
{context.parameter(type.declaration)}
10+
</div>
11+
);
12+
}
13+
14+
const visitor = { reflection: renderTypeDeclaration };
15+
516
return (
617
<>
718
<div class="tsd-signature tsd-kind-icon">
@@ -27,7 +38,14 @@ export function memberDeclaration(context: DefaultThemeRenderContext, props: Dec
2738

2839
{hasTypeParameters(props) && context.typeParameters(props.typeParameters)}
2940

30-
{props.type && context.typeDeclaration(props.type)}
41+
{props.type?.visit<JSX.Children>({
42+
reflection: renderTypeDeclaration,
43+
array: (arr) => arr.elementType.visit(visitor),
44+
intersection: (int) => int.types.map((t) => t.visit(visitor)),
45+
union: (union) => union.types.map((t) => t.visit(visitor)),
46+
reference: (ref) => ref.typeArguments?.map((t) => t.visit(visitor)),
47+
tuple: (ref) => ref.elements.map((t) => t.visit(visitor))
48+
})}
3149

3250
{context.commentTags(props)}
3351

libs/nx-plugin/src/executors/compile-typedoc/theme/partials/member.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DeclarationReflection, DefaultThemeRenderContext, JSX } from 'typedoc';
1+
import { DeclarationReflection, DefaultThemeRenderContext, JSX, ReferenceReflection } from 'typedoc';
22
import { classNames, getDisplayName, reflectionFlags, wbr } from '../utils';
33

44
export function member(context: DefaultThemeRenderContext, props: DeclarationReflection) {
@@ -26,7 +26,9 @@ export function member(context: DefaultThemeRenderContext, props: DeclarationRef
2626
? context.memberSignatures(props)
2727
: props.hasGetterOrSetter()
2828
? context.memberGetterSetter(props)
29-
: context.memberDeclaration(props)}
29+
: props instanceof ReferenceReflection
30+
? context.memberReference(props)
31+
: context.memberDeclaration(props)}
3032

3133
{props.groups?.map((item) => item.children.map((item) => !item.hasOwnDocument && context.member(item)))}
3234
</section>

libs/nx-plugin/src/executors/compile-typedoc/theme/partials/reflection.tsx

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import {
55
JSX,
66
PageEvent,
77
ReflectionKind,
8-
SignatureReflection
8+
ReflectionType
99
} from 'typedoc';
10-
import { classNames, fixedMarkdown, getKindClass, hasTypeParameters } from '../utils';
10+
import { classNames, fixedMarkdown, hasTypeParameters } from '../utils';
1111

1212
export function reflectionTemplate(context: DefaultThemeRenderContext, props: PageEvent<ContainerReflection>) {
1313
if (
@@ -62,12 +62,23 @@ export function reflectionTemplate(context: DefaultThemeRenderContext, props: Pa
6262
{!!props.model.signatures && (
6363
<section class="tsd-panel">{context.memberSignatures(props.model)}</section>
6464
)}
65-
{!!props.model.indexSignatures?.length && (
65+
{!!props.model.indexSignature && (
6666
<section class={classNames({ 'tsd-panel': true }, context.getReflectionClasses(props.model))}>
67-
<h4 class="tsd-before-signature">{context.i18n.theme_indexable()}</h4>
68-
<ul class="tsd-signatures">
69-
{props.model.indexSignatures.map((index) => renderIndexSignature(context, index))}
70-
</ul>
67+
<h4 class="tsd-before-signature">Indexable</h4>
68+
<div class="tsd-signature">
69+
<span class="tsd-signature-symbol">[</span>
70+
{props.model.indexSignature.parameters!.map((item) => (
71+
<>
72+
{item.name}: {context.type(item.type)}
73+
</>
74+
))}
75+
<span class="tsd-signature-symbol">]: </span>
76+
{context.type(props.model.indexSignature.type)}
77+
</div>
78+
{context.commentSummary(props.model.indexSignature)}
79+
{context.commentTags(props.model.indexSignature)}
80+
{props.model.indexSignature?.type instanceof ReflectionType &&
81+
context.parameter(props.model.indexSignature.type.declaration)}
7182
</section>
7283
)}
7384
{/* {!props.model.signatures && context.memberSources(props.model)} */}
@@ -78,24 +89,3 @@ export function reflectionTemplate(context: DefaultThemeRenderContext, props: Pa
7889
</>
7990
);
8091
}
81-
82-
function renderIndexSignature(context: DefaultThemeRenderContext, index: SignatureReflection) {
83-
return (
84-
<li class="tsd-index-signature">
85-
<div class="tsd-signature">
86-
{index.flags.isReadonly && <span class="tsd-signature-keyword">readonly </span>}
87-
<span class="tsd-signature-symbol">[</span>
88-
{index.parameters!.map((item) => (
89-
<>
90-
<span class={getKindClass(item)}>{item.name}</span>: {context.type(item.type)}
91-
</>
92-
))}
93-
<span class="tsd-signature-symbol">]: </span>
94-
{context.type(index.type)}
95-
</div>
96-
{context.commentSummary(index)}
97-
{context.commentTags(index)}
98-
{context.typeDetailsIfUseful(index.type)}
99-
</li>
100-
);
101-
}

0 commit comments

Comments
 (0)