From 9dbfd894d2b99f616961d182860bb56320bb0474 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Sun, 30 Jan 2022 22:32:32 +0100 Subject: [PATCH] chore(docs): reduce console spam and trim examples from code (#346) --- scripts/apidoc.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/scripts/apidoc.ts b/scripts/apidoc.ts index f07e5e06004..c93020c8b17 100644 --- a/scripts/apidoc.ts +++ b/scripts/apidoc.ts @@ -118,7 +118,7 @@ async function build(): Promise { 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 += ` @@ -154,7 +154,7 @@ async function build(): Promise { `; // typeParameters - typeParameters.forEach((parameter, index) => { + typeParameters.forEach((parameter) => { const parameterName = parameter.name; signatureTypeParameters.push(parameterName); @@ -220,10 +220,8 @@ async function build(): Promise { 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 = @@ -232,8 +230,7 @@ async function build(): Promise { .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'; @@ -249,10 +246,10 @@ async function build(): Promise { // 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. @@ -266,7 +263,6 @@ async function build(): Promise { }); writeFileSync(pathDocsApiPages, apiPagesContent); - console.log('Updated api-pages.mjs'); } build().catch(console.error);