Skip to content

Commit 6b3f87e

Browse files
devversionmmalerba
authored andcommitted
build: generate api docs for all tertiary entry-points (#17293)
Updates our Dgeni setup to generate API docs for all entry-points which are configured in the `cdk/config.bzl` or `material/config.bzl` file. This basically means that we now generate API docs for `material/*/testing` entry-points and for `cdk/testing/*`. Removes the code that made `cdk/testing` a separate sub package. This involves more code than just treating it as "real" entry-point (for which we generate bundles etc.).
1 parent 711a33e commit 6b3f87e

File tree

30 files changed

+238
-97
lines changed

30 files changed

+238
-97
lines changed

src/BUILD.bazel

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ package(default_visibility = ["//visibility:public"])
22

33
load("@npm_bazel_typescript//:index.bzl", "ts_config")
44
load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS")
5-
load("//src/material:config.bzl", "MATERIAL_ENTRYPOINTS")
5+
load("//src/material:config.bzl", "MATERIAL_ENTRYPOINTS", "MATERIAL_TESTING_ENTRYPOINTS")
66
load("//tools:defaults.bzl", "ts_library")
77
load("//tools/dgeni:index.bzl", "dgeni_api_docs")
88

9+
cdkApiEntryPoints = CDK_ENTRYPOINTS
10+
11+
materialApiEntryPoints = MATERIAL_ENTRYPOINTS + MATERIAL_TESTING_ENTRYPOINTS
12+
913
# List that contains all source files that need to be processed by Dgeni.
10-
apiSourceFiles = ["//src/cdk/%s:source-files" % name for name in CDK_ENTRYPOINTS] + [
11-
"//src/material/%s:source-files" % name
12-
for name in MATERIAL_ENTRYPOINTS
13-
]
14+
apiSourceFiles = ["//src/cdk/%s:source-files" % name for name in cdkApiEntryPoints] + \
15+
["//src/material/%s:source-files" % name for name in materialApiEntryPoints]
1416

1517
exports_files([
1618
"bazel-tsconfig-build.json",
@@ -42,8 +44,8 @@ dgeni_api_docs(
4244
"@npm//@angular/platform-browser",
4345
],
4446
entry_points = {
45-
"cdk": CDK_ENTRYPOINTS,
46-
"material": MATERIAL_ENTRYPOINTS,
47+
"cdk": cdkApiEntryPoints,
48+
"material": materialApiEntryPoints,
4749
},
4850
tags = ["docs-package"],
4951
)

src/cdk/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,14 @@ ng_package(
5757
entry_point = ":public-api.ts",
5858
packages = [
5959
"//src/cdk/schematics:npm_package",
60-
"//src/cdk/testing:npm_package",
6160
],
6261
tags = ["release-package"],
6362
deps = CDK_TARGETS,
6463
)
6564

6665
filegroup(
6766
name = "overviews",
68-
srcs = ["//src/cdk/%s:overview" % name for name in CDK_ENTRYPOINTS],
67+
# Only secondary entry-points declare overview files currently. Entry-points
68+
# which contain a slash are not in the top-level and do not have an overview.
69+
srcs = ["//src/cdk/%s:overview" % ep for ep in CDK_ENTRYPOINTS if not "/" in ep],
6970
)

src/cdk/config.bzl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ CDK_ENTRYPOINTS = [
1818
"text-field",
1919
"tree",
2020
"testing",
21+
"testing/protractor",
22+
"testing/testbed",
2123
]
2224

23-
# List of all entry-point targets of the Angular Material package. Note that
24-
# we do not want to include "testing" here as it will be treated as a standalone
25-
# sub-package of the "ng_package".
26-
CDK_TARGETS = ["//src/cdk"] + \
27-
["//src/cdk/%s" % ep for ep in CDK_ENTRYPOINTS if not ep == "testing"]
25+
# List of all entry-point targets of the Angular Material package.
26+
CDK_TARGETS = ["//src/cdk"] + ["//src/cdk/%s" % ep for ep in CDK_ENTRYPOINTS]
2827

2928
# Within the CDK, only a few targets have sass libraries which need to be
3029
# part of the release package. This list declares all CDK targets with sass

src/cdk/testing/BUILD.bazel

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
43
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")
54
load("//tools:defaults.bzl", "markdown_to_html", "ng_web_test_suite", "ts_library")
65

@@ -15,15 +14,6 @@ ts_library(
1514
module_name = "@angular/cdk/testing",
1615
)
1716

18-
npm_package(
19-
name = "npm_package",
20-
deps = [
21-
":testing",
22-
"//src/cdk/testing/protractor",
23-
"//src/cdk/testing/testbed",
24-
],
25-
)
26-
2717
markdown_to_html(
2818
name = "overview",
2919
srcs = ["testing.md"],

src/cdk/testing/protractor/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ ts_library(
1414
"@npm//protractor",
1515
],
1616
)
17+
18+
filegroup(
19+
name = "source-files",
20+
srcs = glob(["**/*.ts"]),
21+
)

src/cdk/testing/testbed/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ ts_library(
1515
"@npm//@angular/core",
1616
],
1717
)
18+
19+
filegroup(
20+
name = "source-files",
21+
srcs = glob(["**/*.ts"]),
22+
)

src/material/autocomplete/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ ts_library(
1515
],
1616
)
1717

18+
filegroup(
19+
name = "source-files",
20+
srcs = glob(["**/*.ts"]),
21+
)
22+
1823
ng_test_library(
1924
name = "harness_tests_lib",
2025
srcs = ["shared.spec.ts"],

src/material/button/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ ts_library(
1515
],
1616
)
1717

18+
filegroup(
19+
name = "source-files",
20+
srcs = glob(["**/*.ts"]),
21+
)
22+
1823
ng_test_library(
1924
name = "harness_tests_lib",
2025
srcs = ["shared.spec.ts"],

src/material/checkbox/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ ts_library(
1515
],
1616
)
1717

18+
filegroup(
19+
name = "source-files",
20+
srcs = glob(["**/*.ts"]),
21+
)
22+
1823
ng_test_library(
1924
name = "harness_tests_lib",
2025
srcs = ["shared.spec.ts"],

src/material/dialog/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ ts_library(
1616
],
1717
)
1818

19+
filegroup(
20+
name = "source-files",
21+
srcs = glob(["**/*.ts"]),
22+
)
23+
1924
ng_test_library(
2025
name = "harness_tests_lib",
2126
srcs = ["shared.spec.ts"],

src/material/menu/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ ts_library(
1515
],
1616
)
1717

18+
filegroup(
19+
name = "source-files",
20+
srcs = glob(["**/*.ts"]),
21+
)
22+
1823
ng_test_library(
1924
name = "harness_tests_lib",
2025
srcs = ["shared.spec.ts"],

src/material/progress-bar/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ ts_library(
1515
],
1616
)
1717

18+
filegroup(
19+
name = "source-files",
20+
srcs = glob(["**/*.ts"]),
21+
)
22+
1823
ng_test_library(
1924
name = "harness_tests_lib",
2025
srcs = ["shared.spec.ts"],

src/material/progress-spinner/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ ts_library(
1616
],
1717
)
1818

19+
filegroup(
20+
name = "source-files",
21+
srcs = glob(["**/*.ts"]),
22+
)
23+
1924
ng_test_library(
2025
name = "harness_tests_lib",
2126
srcs = ["shared.spec.ts"],

src/material/radio/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ ts_library(
1515
],
1616
)
1717

18+
filegroup(
19+
name = "source-files",
20+
srcs = glob(["**/*.ts"]),
21+
)
22+
1823
ng_test_library(
1924
name = "harness_tests_lib",
2025
srcs = ["shared.spec.ts"],

src/material/sidenav/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ ts_library(
1515
],
1616
)
1717

18+
filegroup(
19+
name = "source-files",
20+
srcs = glob(["**/*.ts"]),
21+
)
22+
1823
ng_test_library(
1924
name = "harness_tests_lib",
2025
srcs = ["shared.spec.ts"],

src/material/slide-toggle/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ ts_library(
1515
],
1616
)
1717

18+
filegroup(
19+
name = "source-files",
20+
srcs = glob(["**/*.ts"]),
21+
)
22+
1823
ng_test_library(
1924
name = "harness_tests_lib",
2025
srcs = ["shared.spec.ts"],

src/material/slider/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ ts_library(
1515
],
1616
)
1717

18+
filegroup(
19+
name = "source-files",
20+
srcs = glob(["**/*.ts"]),
21+
)
22+
1823
ng_test_library(
1924
name = "harness_tests_lib",
2025
srcs = ["shared.spec.ts"],

src/material/snack-bar/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ ts_library(
1414
],
1515
)
1616

17+
filegroup(
18+
name = "source-files",
19+
srcs = glob(["**/*.ts"]),
20+
)
21+
1722
ng_test_library(
1823
name = "harness_tests_lib",
1924
srcs = ["shared.spec.ts"],

src/material/tabs/testing/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ ts_library(
1515
],
1616
)
1717

18+
filegroup(
19+
name = "source-files",
20+
srcs = glob(["**/*.ts"]),
21+
)
22+
1823
ng_test_library(
1924
name = "harness_tests_lib",
2025
srcs = ["shared.spec.ts"],

tools/dgeni/bazel-bin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {TsParser} from 'dgeni-packages/typescript/services/TsParser';
44
import {readFileSync} from 'fs';
55
import {join, relative} from 'path';
66
import {apiDocsPackage} from './docs-package';
7+
import {EntryPointGrouper} from './processors/entry-point-grouper';
78

89
/**
910
* Determines the command line arguments for the current Bazel action. Since this action can
@@ -39,6 +40,7 @@ if (require.main === module) {
3940
// Configure the Dgeni docs package to respect our passed options from the Bazel rule.
4041
apiDocsPackage.config(function(readTypeScriptModules: ReadTypeScriptModules,
4142
tsParser: TsParser,
43+
entryPointGrouper: EntryPointGrouper,
4244
templateFinder: any,
4345
writeFilesProcessor: any,
4446
readFilesProcessor: any) {
@@ -73,6 +75,7 @@ if (require.main === module) {
7375
const entryPointPath = `${packageName}/${entryPointName}`;
7476
const entryPointIndexPath = `${entryPointPath}/index.ts`;
7577

78+
entryPointGrouper.entryPoints.push(entryPointPath);
7679
tsParser.options.paths![`@angular/${entryPointPath}`] = [entryPointIndexPath];
7780
readTypeScriptModules.sourceFiles.push(entryPointIndexPath);
7881
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
2+
3+
/** Gets all class like export documents which the given doc inherits from. */
4+
export function getInheritedDocsOfClass(doc: ClassLikeExportDoc): ClassLikeExportDoc[] {
5+
const directBaseDocs = [
6+
...doc.implementsClauses.filter(clause => clause.doc).map(d => d.doc!),
7+
...doc.extendsClauses.filter(clause => clause.doc).map(d => d.doc!),
8+
];
9+
10+
return [
11+
...directBaseDocs,
12+
// recursively collect base documents of direct base documents.
13+
...directBaseDocs.reduce(
14+
(res: ClassLikeExportDoc[], d) => res.concat(getInheritedDocsOfClass(d)), []),
15+
];
16+
}

tools/dgeni/common/decorators.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export function isDeprecatedDoc(doc: any) {
4242
return (doc.tags && doc.tags.tags || []).some((tag: any) => tag.tagName === 'deprecated');
4343
}
4444

45-
/** Whether the given document is annotated with the "@docs-primary-module" jsdoc tag. */
46-
export function isPrimaryModuleDoc(doc: any) {
45+
/** Whether the given document is annotated with the "@docs-primary-export" jsdoc tag. */
46+
export function isPrimaryExportDoc(doc: any) {
4747
return (doc.tags && doc.tags.tags || [])
48-
.some((tag: any) => tag.tagName === 'docs-primary-module');
48+
.some((tag: any) => tag.tagName === 'docs-primary-export');
4949
}
5050

5151
export function getDirectiveSelectors(classDoc: CategorizedClassDoc) {

tools/dgeni/common/dgeni-definitions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ export interface CategorizedClassDoc extends ClassExportDoc, CategorizedClassLik
3030
isDirective: boolean;
3131
isService: boolean;
3232
isNgModule: boolean;
33+
isTestHarness: boolean;
3334
directiveExportAs?: string | null;
3435
directiveSelectors?: string[];
3536
directiveMetadata: Map<string, any> | null;
3637
extendedDoc: ClassLikeExportDoc | undefined;
38+
inheritedDocs: ClassLikeExportDoc[];
3739
}
3840

3941
/** Extended Dgeni property-member document that includes extracted Angular metadata. */

tools/dgeni/docs-package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ apiDocsPackage.config(function(parseTagsProcessor: any) {
7979
parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions.concat([
8080
{name: 'docs-private'},
8181
{name: 'docs-public'},
82-
{name: 'docs-primary-module'},
82+
{name: 'docs-primary-export'},
8383
{name: 'breaking-change'},
8484
]);
8585
});

tools/dgeni/index.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ def _dgeni_api_docs(ctx):
4040
expected_outputs += [
4141
# Declare the output for the current entry-point. The output file will always follow the
4242
# same format: "{output_folder}/{package_name}-{entry_point_name}.html"
43-
# (e.g. "api-docs/material-slider.html")
44-
ctx.actions.declare_file("%s/%s-%s.html" % (output_dir_name, package_name, entry_point)),
43+
# (e.g. "api-docs/material-slider-testing.html")
44+
ctx.actions.declare_file("%s/%s-%s.html" %
45+
(output_dir_name, package_name, entry_point.replace("/", "-"))),
4546
]
4647

4748
# Small workaround that ensures that the "ripple" API doc is properly exposed as an output

0 commit comments

Comments
 (0)