From e1b9c2d4ecb92a3277534f7028738b62c08c8009 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Wed, 23 Jan 2019 20:17:14 +0100 Subject: [PATCH] build: remove unused dgeni package configurations (#14909) * Removes some configuration parts of the Dgeni docs package which are overwritten by Bazel using the `apiDocsPackage`. Globs do not work within Bazel. --- tools/dgeni/BUILD.bazel | 1 - tools/dgeni/bazel-bin.ts | 6 ++- tools/dgeni/{index.ts => docs-package.ts} | 54 ++--------------------- tools/dgeni/tsconfig.json | 11 ----- 4 files changed, 9 insertions(+), 63 deletions(-) rename tools/dgeni/{index.ts => docs-package.ts} (71%) diff --git a/tools/dgeni/BUILD.bazel b/tools/dgeni/BUILD.bazel index 18cd7fe9e5e..d31a6d59f3e 100644 --- a/tools/dgeni/BUILD.bazel +++ b/tools/dgeni/BUILD.bazel @@ -19,7 +19,6 @@ ts_library( srcs = glob(["**/*.ts"]), deps = [ "@matdeps//@types/node", - "@matdeps//@types/glob", "@matdeps//dgeni", "@matdeps//dgeni-packages", "//tools/highlight-files:sources", diff --git a/tools/dgeni/bazel-bin.ts b/tools/dgeni/bazel-bin.ts index ef1d918b394..589bfa74889 100644 --- a/tools/dgeni/bazel-bin.ts +++ b/tools/dgeni/bazel-bin.ts @@ -3,7 +3,7 @@ import {ReadTypeScriptModules} from 'dgeni-packages/typescript/processors/readTy import {TsParser} from 'dgeni-packages/typescript/services/TsParser'; import {readFileSync} from 'fs'; import {join, relative} from 'path'; -import {apiDocsPackage} from './index'; +import {apiDocsPackage} from './docs-package'; /** * Determines the command line arguments for the current Bazel action. Since this action can @@ -52,6 +52,10 @@ if (require.main === module) { // custom processors (such as the `entry-point-grouper) to compute entry-point paths. readTypeScriptModules.basePath = packagePath; + // Initialize the "tsParser" path mappings. These will be passed to the TypeScript program + // and therefore use the same syntax as the "paths" option in a tsconfig. + tsParser.options.paths = {}; + // For each package we want to setup all entry points in Dgeni so that their API // will be generated. Packages and their associated entry points are passed in pairs. // The first argument will be always the package name, and the second argument will be a diff --git a/tools/dgeni/index.ts b/tools/dgeni/docs-package.ts similarity index 71% rename from tools/dgeni/index.ts rename to tools/dgeni/docs-package.ts index 195203457a2..eeba3997229 100644 --- a/tools/dgeni/index.ts +++ b/tools/dgeni/docs-package.ts @@ -8,31 +8,13 @@ import {FilterDuplicateExports} from './processors/filter-duplicate-exports'; import {MergeInheritedProperties} from './processors/merge-inherited-properties'; import {EntryPointGrouper} from './processors/entry-point-grouper'; import {ReadTypeScriptModules} from 'dgeni-packages/typescript/processors/readTypeScriptModules'; -import {TsParser} from 'dgeni-packages/typescript/services/TsParser'; import {TypeFormatFlags} from 'dgeni-packages/node_modules/typescript'; -import {sync as globSync} from 'glob'; -import * as path from 'path'; // Dgeni packages that the Material docs package depends on. const jsdocPackage = require('dgeni-packages/jsdoc'); const nunjucksPackage = require('dgeni-packages/nunjucks'); const typescriptPackage = require('dgeni-packages/typescript'); -// Project configuration. -const projectRootDir = path.resolve(__dirname, '../..'); -const sourceDir = path.resolve(projectRootDir, 'src'); -const outputDir = path.resolve(projectRootDir, 'dist/docs/api'); -const templateDir = path.resolve(__dirname, './templates'); - -/** List of CDK packages that need to be documented. */ -const cdkPackages = globSync(path.join(sourceDir, 'cdk', '*/')) - .filter(packagePath => !packagePath.endsWith('testing/')) - .map(packagePath => path.basename(packagePath)); - -/** List of Material packages that need to be documented. */ -const materialPackages = globSync(path.join(sourceDir, 'lib', '*/')) - .map(packagePath => path.basename(packagePath)); - /** * Dgeni package for the Angular Material docs. This just defines the package, but doesn't * generate the docs yet. @@ -71,11 +53,9 @@ apiDocsPackage.processor(new EntryPointGrouper()); apiDocsPackage.config((log: any) => log.level = 'info'); // Configure the processor for reading files from the file system. -apiDocsPackage.config((readFilesProcessor: any, writeFilesProcessor: any) => { - readFilesProcessor.basePath = sourceDir; - readFilesProcessor.$enabled = false; // disable for now as we are using readTypeScriptModules - - writeFilesProcessor.outputFolder = outputDir; +apiDocsPackage.config((readFilesProcessor: any) => { + // Disable we currently only use the "readTypeScriptModules" processor + readFilesProcessor.$enabled = false; }); // Patches Dgeni's log service to not print warnings about unresolved mixin base symbols. @@ -104,32 +84,9 @@ apiDocsPackage.config((checkAnchorLinksProcessor: any) => { }); // Configure the processor for understanding TypeScript. -apiDocsPackage.config((readTypeScriptModules: ReadTypeScriptModules, tsParser: TsParser) => { - readTypeScriptModules.basePath = sourceDir; +apiDocsPackage.config((readTypeScriptModules: ReadTypeScriptModules) => { readTypeScriptModules.ignoreExportsMatching = [/^_/]; readTypeScriptModules.hidePrivateMembers = true; - - const typescriptPathMap: any = {}; - - cdkPackages.forEach(packageName => { - typescriptPathMap[`@angular/cdk/${packageName}`] = [`./cdk/${packageName}/index.ts`]; - }); - - materialPackages.forEach(packageName => { - typescriptPathMap[`@angular/material/${packageName}`] = [`./lib/${packageName}/index.ts`]; - }); - - // Add proper path mappings to the TSParser service of Dgeni. This ensures that properties - // from mixins (e.g. color, disabled) are showing up properly in the docs. - tsParser.options.paths = typescriptPathMap; - tsParser.options.baseUrl = sourceDir; - - // Entry points for docs generation. All publicly exported symbols found through these - // files will have docs generated. - readTypeScriptModules.sourceFiles = [ - ...cdkPackages.map(packageName => `./cdk/${packageName}/index.ts`), - ...materialPackages.map(packageName => `./lib/${packageName}/index.ts`) - ]; }); apiDocsPackage.config((tsHost: Host) => { @@ -148,9 +105,6 @@ apiDocsPackage.config((tsHost: Host) => { // Configure processor for finding nunjucks templates. apiDocsPackage.config((templateFinder: any, templateEngine: any) => { - // Where to find the templates for the doc rendering - templateFinder.templateFolders = [templateDir]; - // Standard patterns for matching docs to templates templateFinder.templatePatterns = [ '${ doc.template }', diff --git a/tools/dgeni/tsconfig.json b/tools/dgeni/tsconfig.json index 8670f62807f..28d0aca264e 100644 --- a/tools/dgeni/tsconfig.json +++ b/tools/dgeni/tsconfig.json @@ -1,26 +1,15 @@ { "compilerOptions": { - "experimentalDecorators": true, "noUnusedParameters": true, "noUnusedLocals": true, "lib": ["es2015", "dom", "es2016.array.include"], - "module": "commonjs", "moduleResolution": "node", - "outDir": "../../dist/tools/dgeni", "strictNullChecks": true, "strictFunctionTypes": true, "noImplicitThis": true, - "noEmitOnError": true, "noImplicitAny": true, - "target": "es5", "types": [ "node" ] - }, - "files": [ - "index.ts" - ], - "bazelOptions": { - "suppressTsconfigOverrideWarnings": true } }