diff --git a/.gitignore b/.gitignore index 01c90b87fe6b..ab1492530c26 100644 --- a/.gitignore +++ b/.gitignore @@ -12,9 +12,14 @@ benchmark/dist **/package .sandbox packages/cli/generators/datasource/connectors.json -docs/site/readmes -docs/apidocs/reports-temp -docs/apidocs/models +packages/tsdocs/fixtures/monorepo/docs +/docs/site/readmes +/docs/apidocs/reports-temp +/docs/apidocs/models + +# TBD: Exclude api reports from git for now +/docs/apidocs/reports +/docs/site/apidocs # Exclude all files under sandbox except README.md and example /sandbox/* diff --git a/.prettierignore b/.prettierignore index 8ecc31b576f9..8c7cb3809a3b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,7 +3,7 @@ /docs/apidocs /docs/site/apidocs packages/cli/generators/*/templates -packages/tsdocs/fixtures +packages/tsdocs/fixtures/monorepo/docs **/.sandbox packages/*/dist examples/*/dist diff --git a/docs/package.json b/docs/package.json index 32d787a107b2..f05032bc71e8 100644 --- a/docs/package.json +++ b/docs/package.json @@ -17,7 +17,7 @@ "scripts": { "build:apidocs": "lb-apidocs --html-file=index.html", "prepack": "node ./bin/copy-readmes", - "clean": "lb-clean loopback-docs*.tgz package api-docs site/readmes" + "clean": "lb-clean loopback-docs*.tgz package api-docs apidocs site/readmes site/apidocs" }, "devDependencies": { "@loopback/build": "^1.5.4" diff --git a/packages/tsdocs/.gitignore b/packages/tsdocs/.gitignore deleted file mode 100644 index 00d5c5d6e1b7..000000000000 --- a/packages/tsdocs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/fixtures/monorepo/docs - diff --git a/packages/tsdocs/bin/extract-apis.js b/packages/tsdocs/bin/extract-apis.js index ec8e6833e352..878c603611f7 100644 --- a/packages/tsdocs/bin/extract-apis.js +++ b/packages/tsdocs/bin/extract-apis.js @@ -8,11 +8,17 @@ * Run api-extractor against the monorepo */ const runExtractorForMonorepo = require('..').runExtractorForMonorepo; + const silent = process.argv.includes('--silent'); const dryRun = process.argv.includes('--dry-run'); +/** + * The option to control if reports are generated by api-extractor + */ +const apiReportEnabled = process.argv.includes('--report'); + async function main() { - await runExtractorForMonorepo({silent, dryRun}); + await runExtractorForMonorepo({silent, dryRun, apiReportEnabled}); } main(); diff --git a/packages/tsdocs/src/__tests__/acceptance/tsdocs.acceptance.ts b/packages/tsdocs/src/__tests__/acceptance/tsdocs.acceptance.ts index 80bd1163658b..a47238072a97 100644 --- a/packages/tsdocs/src/__tests__/acceptance/tsdocs.acceptance.ts +++ b/packages/tsdocs/src/__tests__/acceptance/tsdocs.acceptance.ts @@ -29,6 +29,7 @@ describe('tsdocs', function() { rootDir: MONOREPO_ROOT, silent: true, apiDocsGenerationPath: 'docs/apidocs', + apiReportEnabled: true, }); const dirs = await fs.readdir(APIDOCS_ROOT); diff --git a/packages/tsdocs/src/helper.ts b/packages/tsdocs/src/helper.ts index 884c0e037e89..4c9ce44c1aed 100644 --- a/packages/tsdocs/src/helper.ts +++ b/packages/tsdocs/src/helper.ts @@ -161,6 +161,10 @@ export interface ExtractorOptions extends ApiDocsOptions { * mainEntryPointFilePath */ mainEntryPointFilePath?: string; + /** + * A flag to control if `apiReport` should be enabled + */ + apiReportEnabled?: boolean; } /** diff --git a/packages/tsdocs/src/monorepo-api-extractor.ts b/packages/tsdocs/src/monorepo-api-extractor.ts index 1d6894a7e0e7..28a0fd8fe466 100644 --- a/packages/tsdocs/src/monorepo-api-extractor.ts +++ b/packages/tsdocs/src/monorepo-api-extractor.ts @@ -89,8 +89,12 @@ function setupApiDocsDirs(lernaRootDir: string, options: ExtractorOptions) { /* istanbul ignore if */ if (options.dryRun) return; const apiDocsExtractionPath = options.apiDocsExtractionPath!; - fs.ensureDirSync(path.join(lernaRootDir, `${apiDocsExtractionPath}/reports`)); + fs.emptyDirSync(path.join(lernaRootDir, `${apiDocsExtractionPath}/models`)); + + if (!options.apiReportEnabled) return; + + fs.ensureDirSync(path.join(lernaRootDir, `${apiDocsExtractionPath}/reports`)); fs.emptyDirSync( path.join(lernaRootDir, `${apiDocsExtractionPath}/reports-temp`), ); @@ -112,7 +116,7 @@ function createRawExtractorConfig( projectFolder: pkg.location, mainEntryPointFilePath: entryPoint, apiReport: { - enabled: true, + enabled: !!options.apiReportEnabled, reportFolder: path.join(pkg.rootPath, `${apiDocsExtractionPath}/reports`), reportTempFolder: path.join( pkg.rootPath,