aboutsummaryrefslogtreecommitdiff
path: root/scripts/apidoc/moduleMethods.ts
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2023-02-01 22:33:15 +0100
committerGitHub <[email protected]>2023-02-01 22:33:15 +0100
commit9c3618d66550b7a72cade402b035ecdbcb485625 (patch)
tree0f6792026c965c745f6763b9ba1b14a3d26f828e /scripts/apidoc/moduleMethods.ts
parentde7ed2e3b823131345995da6ec52c2b0c40c8d6e (diff)
downloadfaker-9c3618d66550b7a72cade402b035ecdbcb485625.tar.xz
faker-9c3618d66550b7a72cade402b035ecdbcb485625.zip
infra(docs): add docs diff script (#1755)
Diffstat (limited to 'scripts/apidoc/moduleMethods.ts')
-rw-r--r--scripts/apidoc/moduleMethods.ts33
1 files changed, 22 insertions, 11 deletions
diff --git a/scripts/apidoc/moduleMethods.ts b/scripts/apidoc/moduleMethods.ts
index b52d4780..bf7b93f9 100644
--- a/scripts/apidoc/moduleMethods.ts
+++ b/scripts/apidoc/moduleMethods.ts
@@ -8,7 +8,8 @@ import {
selectApiMethodSignatures,
selectApiModules,
} from './typedoc';
-import type { PageIndex } from './utils';
+import type { PageAndDiffIndex } from './utils';
+import { diffHash } from './utils';
/**
* Analyzes and writes the documentation for modules and their methods such as `faker.animal.cat()`.
@@ -16,8 +17,10 @@ import type { PageIndex } from './utils';
* @param project The project used to extract the modules.
* @returns The generated pages.
*/
-export function processModuleMethods(project: ProjectReflection): PageIndex {
- const pages: PageIndex = [];
+export function processModuleMethods(
+ project: ProjectReflection
+): PageAndDiffIndex {
+ const pages: PageAndDiffIndex = [];
// Generate module files
for (const module of selectApiModules(project)) {
@@ -33,10 +36,11 @@ export function processModuleMethods(project: ProjectReflection): PageIndex {
* @param module The module to process.
* @returns The generated pages.
*/
-function processModuleMethod(module: DeclarationReflection): PageIndex {
+function processModuleMethod(module: DeclarationReflection): PageAndDiffIndex {
const moduleName = extractModuleName(module);
const moduleFieldName = extractModuleFieldName(module);
console.log(`Processing Module ${moduleName}`);
+ const comment = toBlock(module.comment);
const methods: Method[] = [];
@@ -45,22 +49,29 @@ function processModuleMethod(module: DeclarationReflection): PageIndex {
selectApiMethodSignatures(module)
)) {
console.debug(`- ${methodName}`);
-
methods.push(analyzeSignature(signature, moduleFieldName, methodName));
}
- writeApiDocsModulePage(
- moduleName,
- moduleFieldName,
- toBlock(module.comment),
- methods
- );
+ writeApiDocsModulePage(moduleName, moduleFieldName, comment, methods);
writeApiDocsData(moduleFieldName, methods);
return [
{
text: moduleName,
link: `/api/${moduleFieldName}.html`,
+ diff: methods.reduce(
+ (data, method) => ({
+ ...data,
+ [method.name]: diffHash(method),
+ }),
+ {
+ moduleHash: diffHash({
+ name: moduleName,
+ field: moduleFieldName,
+ comment,
+ }),
+ }
+ ),
},
];
}