Skip to content

Commit

Permalink
chore(docs): reduce console spam and trim examples from code (faker-j…
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored and demipel8 committed Mar 11, 2022
1 parent 7f968af commit 9eec7e3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions scripts/apidoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async function build(): Promise<void> {
const prettyMethodName =
methodName.substring(0, 1).toUpperCase() +
methodName.substring(1).replace(/([A-Z]+)/g, ' $1');
console.log(`- method ${prettyMethodName}`);
console.debug(`- method ${prettyMethodName}`);
const signature = method.signatures[0];

content += `
Expand Down Expand Up @@ -154,7 +154,7 @@ async function build(): Promise<void> {
`;

// typeParameters
typeParameters.forEach((parameter, index) => {
typeParameters.forEach((parameter) => {
const parameterName = parameter.name;

signatureTypeParameters.push(parameterName);
Expand Down Expand Up @@ -220,10 +220,8 @@ async function build(): Promise<void> {

content += `faker.${lowerModuleName}.${methodName}()`;
content += (example ? ` // => ${example}` : '') + '\n';
} catch {
console.log(
`Failed to call: faker.${lowerModuleName}${methodName}()`
);
} catch (error) {
// Ignore the error => hide the example call + result.
}
}
const examples =
Expand All @@ -232,8 +230,7 @@ async function build(): Promise<void> {
.map((tag) => tag.text.trimEnd()) || [];

if (examples.length !== 0) {
console.log('Example-Length:', examples);
content += examples.join('\n') + '\n';
content += examples.join('\n').trim() + '\n';
}

content += '````\n\n';
Expand All @@ -249,10 +246,10 @@ async function build(): Promise<void> {
// Write to disk

writeFileSync(resolve(pathOutputDir, lowerModuleName + '.md'), content);
console.log(`Done Module ${moduleName}`);
}

// Write api-pages.mjs
console.log('Updating api-pages.mjs');
modulesPages.sort((a, b) => a.text.localeCompare(b.text));
let apiPagesContent = `
// This file is automatically generated.
Expand All @@ -266,7 +263,6 @@ async function build(): Promise<void> {
});

writeFileSync(pathDocsApiPages, apiPagesContent);
console.log('Updated api-pages.mjs');
}

build().catch(console.error);

0 comments on commit 9eec7e3

Please sign in to comment.