Skip to content

Commit

Permalink
chore(tsdocs): disable api reports by default
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed May 21, 2019
1 parent 8f6293a commit 9aa76a9
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 10 deletions.
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions packages/tsdocs/.gitignore

This file was deleted.

8 changes: 7 additions & 1 deletion packages/tsdocs/bin/extract-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('tsdocs', function() {
rootDir: MONOREPO_ROOT,
silent: true,
apiDocsGenerationPath: 'docs/apidocs',
apiReportEnabled: true,
});

const dirs = await fs.readdir(APIDOCS_ROOT);
Expand Down
4 changes: 4 additions & 0 deletions packages/tsdocs/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ export interface ExtractorOptions extends ApiDocsOptions {
* mainEntryPointFilePath
*/
mainEntryPointFilePath?: string;
/**
* A flag to control if `apiReport` should be enabled
*/
apiReportEnabled?: boolean;
}

/**
Expand Down
8 changes: 6 additions & 2 deletions packages/tsdocs/src/monorepo-api-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`),
);
Expand All @@ -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,
Expand Down

0 comments on commit 9aa76a9

Please sign in to comment.