aboutsummaryrefslogtreecommitdiff
path: root/test/scripts
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2022-08-25 21:19:54 +0200
committerGitHub <[email protected]>2022-08-25 21:19:54 +0200
commita734ca027239f97081a352821f7fc5137b13bfb5 (patch)
tree617d67ec0ef12005af43cb6705f1cf32c336f1c1 /test/scripts
parent13ad646cce4e0e447396e0bafa42c3378a52b522 (diff)
downloadfaker-a734ca027239f97081a352821f7fc5137b13bfb5.tar.xz
faker-a734ca027239f97081a352821f7fc5137b13bfb5.zip
docs: properly handle multiple `@see` tags (#1270)
Diffstat (limited to 'test/scripts')
-rw-r--r--test/scripts/apidoc/examplesAndDeprecations.spec.ts5
-rw-r--r--test/scripts/apidoc/signature.debug.ts19
-rw-r--r--test/scripts/apidoc/signature.example.ts10
-rw-r--r--test/scripts/apidoc/signature.expected.json13
4 files changed, 39 insertions, 8 deletions
diff --git a/test/scripts/apidoc/examplesAndDeprecations.spec.ts b/test/scripts/apidoc/examplesAndDeprecations.spec.ts
index 2f457b4b..83443c52 100644
--- a/test/scripts/apidoc/examplesAndDeprecations.spec.ts
+++ b/test/scripts/apidoc/examplesAndDeprecations.spec.ts
@@ -8,6 +8,7 @@ import { selectDirectMethods } from '../../../scripts/apidoc/directMethods';
import { selectApiModules } from '../../../scripts/apidoc/moduleMethods';
import {
extractRawExamples,
+ extractSeeAlsos,
extractTagContent,
isDeprecated,
} from '../../../scripts/apidoc/utils';
@@ -111,8 +112,8 @@ describe('examples and deprecations', () => {
}
// Verify @see tag
- extractTagContent('@see', signature).forEach((link) => {
- if (link.startsWith('faker')) {
+ extractSeeAlsos(signature).forEach((link) => {
+ if (link.startsWith('faker.')) {
// Expected @see faker.xxx.yyy()
expect(link, 'Expect method reference to contain ()').toContain('(');
expect(link, 'Expect method reference to contain ()').toContain(')');
diff --git a/test/scripts/apidoc/signature.debug.ts b/test/scripts/apidoc/signature.debug.ts
index e3451d09..f805ca54 100644
--- a/test/scripts/apidoc/signature.debug.ts
+++ b/test/scripts/apidoc/signature.debug.ts
@@ -2,15 +2,22 @@
* This file exists, because vitest doesn't allow me to debug code outside of src and test.
* And it's easier to test these features independently from the main project.
*/
-import { analyzeSignature } from '../../../scripts/apidoc/signature';
+import {
+ analyzeSignature,
+ initMarkdownRenderer,
+} from '../../../scripts/apidoc/signature';
import { loadExampleMethods } from './utils';
/* Run with `pnpm tsx test/scripts/apidoc/signature.debug.ts` */
const methods = loadExampleMethods();
-Object.entries(methods).forEach(([name, method]) => {
- console.log('Analyzing: ', name);
- const result = analyzeSignature(method.signatures[0], null, method.name);
- console.log('Result: ', result);
-});
+initMarkdownRenderer()
+ .then(() => {
+ Object.entries(methods).forEach(([name, method]) => {
+ console.log('Analyzing: ', name);
+ const result = analyzeSignature(method.signatures[0], null, method.name);
+ console.log('Result: ', result);
+ });
+ })
+ .catch(console.error);
diff --git a/test/scripts/apidoc/signature.example.ts b/test/scripts/apidoc/signature.example.ts
index f709100e..b11d40a5 100644
--- a/test/scripts/apidoc/signature.example.ts
+++ b/test/scripts/apidoc/signature.example.ts
@@ -230,4 +230,14 @@ export class SignatureTest {
methodWithDeprecated(): number {
return 0;
}
+
+ /**
+ * Test with multiple see markers.
+ *
+ * @see test.apidoc.methodWithExample()
+ * @see test.apidoc.methodWithDeprecated()
+ */
+ methodWithMultipleSeeMarkers(): number {
+ return 0;
+ }
}
diff --git a/test/scripts/apidoc/signature.expected.json b/test/scripts/apidoc/signature.expected.json
index bf045234..4aaa97b5 100644
--- a/test/scripts/apidoc/signature.expected.json
+++ b/test/scripts/apidoc/signature.expected.json
@@ -68,6 +68,19 @@
"deprecated": false,
"seeAlsos": []
},
+ "methodWithMultipleSeeMarkers": {
+ "name": "methodWithMultipleSeeMarkers",
+ "title": "Method With Multiple See Markers",
+ "description": "<p>Test with multiple see markers.</p>\n",
+ "parameters": [],
+ "returns": "number",
+ "examples": "<div class=\"language-ts\"><button class=\"copy\"></button><span class=\"lang\">ts</span><pre v-pre><code><span class=\"line\"><span style=\"color: #A6ACCD\">faker</span><span style=\"color: #89DDFF\">.</span><span style=\"color: #82AAFF\">methodWithMultipleSeeMarkers</span><span style=\"color: #A6ACCD\">(): number</span></span>\n<span class=\"line\"></span></code></pre>\n</div>",
+ "deprecated": false,
+ "seeAlsos": [
+ "test.apidoc.methodWithExample()",
+ "test.apidoc.methodWithDeprecated()"
+ ]
+ },
"multiParamMethod": {
"name": "multiParamMethod",
"title": "Multi Param Method",