Skip to content

build: remove unused dgeni package configurations #14909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tools/dgeni/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion tools/dgeni/bazel-bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
54 changes: 4 additions & 50 deletions tools/dgeni/index.ts → tools/dgeni/docs-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) => {
Expand All @@ -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 }',
Expand Down
11 changes: 0 additions & 11 deletions tools/dgeni/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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
}
}