Skip to content

Commit 0c9d5d4

Browse files
devversionandrewseguin
authored andcommitted
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.
1 parent a06dad1 commit 0c9d5d4

File tree

4 files changed

+9
-63
lines changed

4 files changed

+9
-63
lines changed

tools/dgeni/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ ts_library(
1919
srcs = glob(["**/*.ts"]),
2020
deps = [
2121
"@matdeps//@types/node",
22-
"@matdeps//@types/glob",
2322
"@matdeps//dgeni",
2423
"@matdeps//dgeni-packages",
2524
"//tools/highlight-files:sources",

tools/dgeni/bazel-bin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {ReadTypeScriptModules} from 'dgeni-packages/typescript/processors/readTy
33
import {TsParser} from 'dgeni-packages/typescript/services/TsParser';
44
import {readFileSync} from 'fs';
55
import {join, relative} from 'path';
6-
import {apiDocsPackage} from './index';
6+
import {apiDocsPackage} from './docs-package';
77

88
/**
99
* Determines the command line arguments for the current Bazel action. Since this action can
@@ -52,6 +52,10 @@ if (require.main === module) {
5252
// custom processors (such as the `entry-point-grouper) to compute entry-point paths.
5353
readTypeScriptModules.basePath = packagePath;
5454

55+
// Initialize the "tsParser" path mappings. These will be passed to the TypeScript program
56+
// and therefore use the same syntax as the "paths" option in a tsconfig.
57+
tsParser.options.paths = {};
58+
5559
// For each package we want to setup all entry points in Dgeni so that their API
5660
// will be generated. Packages and their associated entry points are passed in pairs.
5761
// The first argument will be always the package name, and the second argument will be a

tools/dgeni/index.ts renamed to tools/dgeni/docs-package.ts

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,13 @@ import {FilterDuplicateExports} from './processors/filter-duplicate-exports';
88
import {MergeInheritedProperties} from './processors/merge-inherited-properties';
99
import {EntryPointGrouper} from './processors/entry-point-grouper';
1010
import {ReadTypeScriptModules} from 'dgeni-packages/typescript/processors/readTypeScriptModules';
11-
import {TsParser} from 'dgeni-packages/typescript/services/TsParser';
1211
import {TypeFormatFlags} from 'dgeni-packages/node_modules/typescript';
13-
import {sync as globSync} from 'glob';
14-
import * as path from 'path';
1512

1613
// Dgeni packages that the Material docs package depends on.
1714
const jsdocPackage = require('dgeni-packages/jsdoc');
1815
const nunjucksPackage = require('dgeni-packages/nunjucks');
1916
const typescriptPackage = require('dgeni-packages/typescript');
2017

21-
// Project configuration.
22-
const projectRootDir = path.resolve(__dirname, '../..');
23-
const sourceDir = path.resolve(projectRootDir, 'src');
24-
const outputDir = path.resolve(projectRootDir, 'dist/docs/api');
25-
const templateDir = path.resolve(__dirname, './templates');
26-
27-
/** List of CDK packages that need to be documented. */
28-
const cdkPackages = globSync(path.join(sourceDir, 'cdk', '*/'))
29-
.filter(packagePath => !packagePath.endsWith('testing/'))
30-
.map(packagePath => path.basename(packagePath));
31-
32-
/** List of Material packages that need to be documented. */
33-
const materialPackages = globSync(path.join(sourceDir, 'lib', '*/'))
34-
.map(packagePath => path.basename(packagePath));
35-
3618
/**
3719
* Dgeni package for the Angular Material docs. This just defines the package, but doesn't
3820
* generate the docs yet.
@@ -71,11 +53,9 @@ apiDocsPackage.processor(new EntryPointGrouper());
7153
apiDocsPackage.config((log: any) => log.level = 'info');
7254

7355
// Configure the processor for reading files from the file system.
74-
apiDocsPackage.config((readFilesProcessor: any, writeFilesProcessor: any) => {
75-
readFilesProcessor.basePath = sourceDir;
76-
readFilesProcessor.$enabled = false; // disable for now as we are using readTypeScriptModules
77-
78-
writeFilesProcessor.outputFolder = outputDir;
56+
apiDocsPackage.config((readFilesProcessor: any) => {
57+
// Disable we currently only use the "readTypeScriptModules" processor
58+
readFilesProcessor.$enabled = false;
7959
});
8060

8161
// Patches Dgeni's log service to not print warnings about unresolved mixin base symbols.
@@ -104,32 +84,9 @@ apiDocsPackage.config((checkAnchorLinksProcessor: any) => {
10484
});
10585

10686
// Configure the processor for understanding TypeScript.
107-
apiDocsPackage.config((readTypeScriptModules: ReadTypeScriptModules, tsParser: TsParser) => {
108-
readTypeScriptModules.basePath = sourceDir;
87+
apiDocsPackage.config((readTypeScriptModules: ReadTypeScriptModules) => {
10988
readTypeScriptModules.ignoreExportsMatching = [/^_/];
11089
readTypeScriptModules.hidePrivateMembers = true;
111-
112-
const typescriptPathMap: any = {};
113-
114-
cdkPackages.forEach(packageName => {
115-
typescriptPathMap[`@angular/cdk/${packageName}`] = [`./cdk/${packageName}/index.ts`];
116-
});
117-
118-
materialPackages.forEach(packageName => {
119-
typescriptPathMap[`@angular/material/${packageName}`] = [`./lib/${packageName}/index.ts`];
120-
});
121-
122-
// Add proper path mappings to the TSParser service of Dgeni. This ensures that properties
123-
// from mixins (e.g. color, disabled) are showing up properly in the docs.
124-
tsParser.options.paths = typescriptPathMap;
125-
tsParser.options.baseUrl = sourceDir;
126-
127-
// Entry points for docs generation. All publicly exported symbols found through these
128-
// files will have docs generated.
129-
readTypeScriptModules.sourceFiles = [
130-
...cdkPackages.map(packageName => `./cdk/${packageName}/index.ts`),
131-
...materialPackages.map(packageName => `./lib/${packageName}/index.ts`)
132-
];
13390
});
13491

13592
apiDocsPackage.config((tsHost: Host) => {
@@ -148,9 +105,6 @@ apiDocsPackage.config((tsHost: Host) => {
148105

149106
// Configure processor for finding nunjucks templates.
150107
apiDocsPackage.config((templateFinder: any, templateEngine: any) => {
151-
// Where to find the templates for the doc rendering
152-
templateFinder.templateFolders = [templateDir];
153-
154108
// Standard patterns for matching docs to templates
155109
templateFinder.templatePatterns = [
156110
'${ doc.template }',

tools/dgeni/tsconfig.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
{
22
"compilerOptions": {
3-
"experimentalDecorators": true,
43
"noUnusedParameters": true,
54
"noUnusedLocals": true,
65
"lib": ["es2015", "dom", "es2016.array.include"],
7-
"module": "commonjs",
86
"moduleResolution": "node",
9-
"outDir": "../../dist/tools/dgeni",
107
"strictNullChecks": true,
118
"strictFunctionTypes": true,
129
"noImplicitThis": true,
13-
"noEmitOnError": true,
1410
"noImplicitAny": true,
15-
"target": "es5",
1611
"types": [
1712
"node"
1813
]
19-
},
20-
"files": [
21-
"index.ts"
22-
],
23-
"bazelOptions": {
24-
"suppressTsconfigOverrideWarnings": true
2514
}
2615
}

0 commit comments

Comments
 (0)