Skip to content

Commit df25d67

Browse files
ST-DDTdemipel8
authored andcommitted
chore(docs): reduce console spam and trim examples from code (#346)
1 parent 9ecdf8a commit df25d67

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

scripts/apidoc.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async function build(): Promise<void> {
118118
const prettyMethodName =
119119
methodName.substring(0, 1).toUpperCase() +
120120
methodName.substring(1).replace(/([A-Z]+)/g, ' $1');
121-
console.log(`- method ${prettyMethodName}`);
121+
console.debug(`- method ${prettyMethodName}`);
122122
const signature = method.signatures[0];
123123

124124
content += `
@@ -154,7 +154,7 @@ async function build(): Promise<void> {
154154
`;
155155

156156
// typeParameters
157-
typeParameters.forEach((parameter, index) => {
157+
typeParameters.forEach((parameter) => {
158158
const parameterName = parameter.name;
159159

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

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

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

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

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

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

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

272268
build().catch(console.error);

0 commit comments

Comments
 (0)