aboutsummaryrefslogtreecommitdiff
path: root/test/scripts/apidoc/utils.ts
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2022-04-08 16:50:41 +0200
committerGitHub <[email protected]>2022-04-08 16:50:41 +0200
commit71a9918db88dbb0bebfac2b26888ebf8926a3704 (patch)
tree3af65d16eae6b49fc494530d6409e35a91b5913a /test/scripts/apidoc/utils.ts
parenta5727097b1b39d69df5d426058dd635ed55ca0fb (diff)
downloadfaker-71a9918db88dbb0bebfac2b26888ebf8926a3704.tar.xz
faker-71a9918db88dbb0bebfac2b26888ebf8926a3704.zip
docs: nice literal unions (#811)
Diffstat (limited to 'test/scripts/apidoc/utils.ts')
-rw-r--r--test/scripts/apidoc/utils.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/scripts/apidoc/utils.ts b/test/scripts/apidoc/utils.ts
new file mode 100644
index 00000000..d4d11e8c
--- /dev/null
+++ b/test/scripts/apidoc/utils.ts
@@ -0,0 +1,26 @@
+import type { DeclarationReflection } from 'typedoc';
+import { ReflectionKind } from 'typedoc';
+import { newTypeDocApp, patchProject } from '../../../scripts/apidoc/utils';
+
+/**
+ * Loads the example methods using TypeDoc.
+ */
+export function loadExampleMethods(): Record<string, DeclarationReflection> {
+ const app = newTypeDocApp();
+
+ app.bootstrap({
+ entryPoints: ['test/scripts/apidoc/signature.example.ts'],
+ tsconfig: 'test/scripts/apidoc/tsconfig.json',
+ });
+
+ const project = app.convert();
+
+ patchProject(project);
+
+ const methods: Record<string, DeclarationReflection> = project
+ .getChildrenByKind(ReflectionKind.Class)[0]
+ .getChildrenByKind(ReflectionKind.Method)
+ .reduce((a, v) => ({ ...a, [v.name]: v }), {});
+
+ return methods;
+}