diff --git a/src/BUILD.bazel b/src/BUILD.bazel index d0b91185f7f7..48237e8eab97 100644 --- a/src/BUILD.bazel +++ b/src/BUILD.bazel @@ -1,9 +1,13 @@ package(default_visibility = ["//visibility:public"]) -load("//:packages.bzl", "CDK_PACKAGES") +load("//:packages.bzl", "CDK_PACKAGES", "MATERIAL_PACKAGES") load("//tools:defaults.bzl", "ts_library") load("//tools/dgeni:index.bzl", "dgeni_api_docs") +# List that contains all source files that need to be processed by Dgeni. +apiSourceFiles = ["//src/cdk/%s:source-files" % name for name in CDK_PACKAGES] + [ + "//src/lib/%s:source-files" % name for name in MATERIAL_PACKAGES] + exports_files([ "bazel-tsconfig-build.json", "bazel-tsconfig-test.json", @@ -17,7 +21,7 @@ ts_library( dgeni_api_docs( name = "api-docs", - srcs = ["//src/cdk/%s:source-files" % name for name in CDK_PACKAGES] + [ + srcs = apiSourceFiles + [ # Add all Angular packages to the sources because some Material exports use # Angular exports and these should not cause any warnings when Dgeni uses the # type checker to parse our TypeScript sources. @@ -25,5 +29,6 @@ dgeni_api_docs( ], entry_points = { "cdk": CDK_PACKAGES, + "material": MATERIAL_PACKAGES, }, ) diff --git a/src/lib/autocomplete/BUILD.bazel b/src/lib/autocomplete/BUILD.bazel index dc23ddc757ef..6f43bde94ac2 100644 --- a/src/lib/autocomplete/BUILD.bazel +++ b/src/lib/autocomplete/BUILD.bazel @@ -72,3 +72,8 @@ markdown_to_html( name = "overview", srcs = [":autocomplete.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/badge/BUILD.bazel b/src/lib/badge/BUILD.bazel index 71c6bef91421..0980ad769069 100644 --- a/src/lib/badge/BUILD.bazel +++ b/src/lib/badge/BUILD.bazel @@ -45,3 +45,8 @@ markdown_to_html( name = "overview", srcs = [":badge.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/bottom-sheet/BUILD.bazel b/src/lib/bottom-sheet/BUILD.bazel index 6436eb5d7e8f..2d57d61f4973 100644 --- a/src/lib/bottom-sheet/BUILD.bazel +++ b/src/lib/bottom-sheet/BUILD.bazel @@ -64,3 +64,8 @@ markdown_to_html( name = "overview", srcs = [":bottom-sheet.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/button-toggle/BUILD.bazel b/src/lib/button-toggle/BUILD.bazel index eb88a6c8e2fe..c5c269844873 100644 --- a/src/lib/button-toggle/BUILD.bazel +++ b/src/lib/button-toggle/BUILD.bazel @@ -54,3 +54,8 @@ markdown_to_html( name = "overview", srcs = [":button-toggle.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/button/BUILD.bazel b/src/lib/button/BUILD.bazel index 9df6e3d51ec6..a0a3b8c976a6 100644 --- a/src/lib/button/BUILD.bazel +++ b/src/lib/button/BUILD.bazel @@ -54,3 +54,8 @@ markdown_to_html( name = "overview", srcs = [":button.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/card/BUILD.bazel b/src/lib/card/BUILD.bazel index 462c61ffd3b9..77095e4ab46c 100644 --- a/src/lib/card/BUILD.bazel +++ b/src/lib/card/BUILD.bazel @@ -33,3 +33,8 @@ markdown_to_html( name = "overview", srcs = [":card.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/checkbox/BUILD.bazel b/src/lib/checkbox/BUILD.bazel index c3ee0d5e3415..6f0a2b256dcd 100644 --- a/src/lib/checkbox/BUILD.bazel +++ b/src/lib/checkbox/BUILD.bazel @@ -60,3 +60,8 @@ markdown_to_html( name = "overview", srcs = [":checkbox.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/chips/BUILD.bazel b/src/lib/chips/BUILD.bazel index 096dfc17697d..8b26b7ba4603 100644 --- a/src/lib/chips/BUILD.bazel +++ b/src/lib/chips/BUILD.bazel @@ -69,3 +69,8 @@ markdown_to_html( name = "overview", srcs = [":chips.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/core/BUILD.bazel b/src/lib/core/BUILD.bazel index 0c9757b36e2f..d39f8cbaea4d 100644 --- a/src/lib/core/BUILD.bazel +++ b/src/lib/core/BUILD.bazel @@ -120,3 +120,8 @@ markdown_to_html( name = "overview", srcs = ["ripple/ripple.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/datepicker/BUILD.bazel b/src/lib/datepicker/BUILD.bazel index ac916fc1d8ba..a0793d5ecd15 100644 --- a/src/lib/datepicker/BUILD.bazel +++ b/src/lib/datepicker/BUILD.bazel @@ -94,3 +94,8 @@ markdown_to_html( name = "overview", srcs = [":datepicker.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/dialog/BUILD.bazel b/src/lib/dialog/BUILD.bazel index fd6c3733e77f..7eb0f94a651a 100644 --- a/src/lib/dialog/BUILD.bazel +++ b/src/lib/dialog/BUILD.bazel @@ -66,3 +66,8 @@ markdown_to_html( name = "overview", srcs = [":dialog.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/divider/BUILD.bazel b/src/lib/divider/BUILD.bazel index e17a144ec6b9..1539a8491efa 100644 --- a/src/lib/divider/BUILD.bazel +++ b/src/lib/divider/BUILD.bazel @@ -46,3 +46,8 @@ markdown_to_html( name = "overview", srcs = [":divider.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/expansion/BUILD.bazel b/src/lib/expansion/BUILD.bazel index a91afb4cb921..00126f2701cb 100644 --- a/src/lib/expansion/BUILD.bazel +++ b/src/lib/expansion/BUILD.bazel @@ -70,3 +70,8 @@ markdown_to_html( name = "overview", srcs = [":expansion.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/form-field/BUILD.bazel b/src/lib/form-field/BUILD.bazel index 7dc1b5396dd0..cd532e9f0522 100644 --- a/src/lib/form-field/BUILD.bazel +++ b/src/lib/form-field/BUILD.bazel @@ -89,3 +89,8 @@ markdown_to_html( name = "overview", srcs = [":form-field.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/grid-list/BUILD.bazel b/src/lib/grid-list/BUILD.bazel index fe10ea13c70e..48b84065103c 100644 --- a/src/lib/grid-list/BUILD.bazel +++ b/src/lib/grid-list/BUILD.bazel @@ -48,3 +48,8 @@ markdown_to_html( name = "overview", srcs = [":grid-list.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/icon/BUILD.bazel b/src/lib/icon/BUILD.bazel index 48ce6a80f0a8..a8d9cfd49cf0 100644 --- a/src/lib/icon/BUILD.bazel +++ b/src/lib/icon/BUILD.bazel @@ -53,3 +53,8 @@ markdown_to_html( name = "overview", srcs = [":icon.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/input/BUILD.bazel b/src/lib/input/BUILD.bazel index db1cb0266446..afb9bdeb2a29 100644 --- a/src/lib/input/BUILD.bazel +++ b/src/lib/input/BUILD.bazel @@ -56,3 +56,8 @@ markdown_to_html( name = "overview", srcs = [":input.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/list/BUILD.bazel b/src/lib/list/BUILD.bazel index 3eb4face5465..0f8e733d7e92 100644 --- a/src/lib/list/BUILD.bazel +++ b/src/lib/list/BUILD.bazel @@ -60,3 +60,8 @@ markdown_to_html( name = "overview", srcs = [":list.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/menu/BUILD.bazel b/src/lib/menu/BUILD.bazel index 499da78a80ac..c06b60bc067d 100644 --- a/src/lib/menu/BUILD.bazel +++ b/src/lib/menu/BUILD.bazel @@ -68,3 +68,8 @@ markdown_to_html( name = "overview", srcs = [":menu.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/paginator/BUILD.bazel b/src/lib/paginator/BUILD.bazel index 16818e532e27..8bd520b57664 100644 --- a/src/lib/paginator/BUILD.bazel +++ b/src/lib/paginator/BUILD.bazel @@ -54,3 +54,8 @@ markdown_to_html( name = "overview", srcs = [":paginator.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/progress-bar/BUILD.bazel b/src/lib/progress-bar/BUILD.bazel index d5c0093fb99c..88266b722ed1 100644 --- a/src/lib/progress-bar/BUILD.bazel +++ b/src/lib/progress-bar/BUILD.bazel @@ -54,3 +54,8 @@ markdown_to_html( name = "overview", srcs = [":progress-bar.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/progress-spinner/BUILD.bazel b/src/lib/progress-spinner/BUILD.bazel index 91b5fe65c66e..23c6ed30dc78 100644 --- a/src/lib/progress-spinner/BUILD.bazel +++ b/src/lib/progress-spinner/BUILD.bazel @@ -49,3 +49,8 @@ markdown_to_html( name = "overview", srcs = [":progress-spinner.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/radio/BUILD.bazel b/src/lib/radio/BUILD.bazel index cd151efaab08..d28ae7461f62 100644 --- a/src/lib/radio/BUILD.bazel +++ b/src/lib/radio/BUILD.bazel @@ -56,3 +56,8 @@ markdown_to_html( name = "overview", srcs = [":radio.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/select/BUILD.bazel b/src/lib/select/BUILD.bazel index d104e0904da3..d65bdb3c1208 100644 --- a/src/lib/select/BUILD.bazel +++ b/src/lib/select/BUILD.bazel @@ -74,3 +74,8 @@ markdown_to_html( name = "overview", srcs = [":select.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/sidenav/BUILD.bazel b/src/lib/sidenav/BUILD.bazel index 94d181ef5aad..5c008b160eba 100644 --- a/src/lib/sidenav/BUILD.bazel +++ b/src/lib/sidenav/BUILD.bazel @@ -66,3 +66,8 @@ markdown_to_html( name = "overview", srcs = [":sidenav.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/slide-toggle/BUILD.bazel b/src/lib/slide-toggle/BUILD.bazel index 2c5ff61433a2..84a160769ed0 100644 --- a/src/lib/slide-toggle/BUILD.bazel +++ b/src/lib/slide-toggle/BUILD.bazel @@ -61,3 +61,8 @@ markdown_to_html( name = "overview", srcs = [":slide-toggle.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/slider/BUILD.bazel b/src/lib/slider/BUILD.bazel index 099292a493e6..b6193babf350 100644 --- a/src/lib/slider/BUILD.bazel +++ b/src/lib/slider/BUILD.bazel @@ -62,3 +62,8 @@ markdown_to_html( name = "overview", srcs = [":slider.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/snack-bar/BUILD.bazel b/src/lib/snack-bar/BUILD.bazel index c3b88f54a586..eb8a8943b9ff 100644 --- a/src/lib/snack-bar/BUILD.bazel +++ b/src/lib/snack-bar/BUILD.bazel @@ -67,3 +67,8 @@ markdown_to_html( name = "overview", srcs = [":snack-bar.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/sort/BUILD.bazel b/src/lib/sort/BUILD.bazel index 20b6e985ae05..ae3db6135f1f 100644 --- a/src/lib/sort/BUILD.bazel +++ b/src/lib/sort/BUILD.bazel @@ -55,3 +55,8 @@ markdown_to_html( name = "overview", srcs = [":sort.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/stepper/BUILD.bazel b/src/lib/stepper/BUILD.bazel index 4f690649cae8..2ac9807ea7f6 100644 --- a/src/lib/stepper/BUILD.bazel +++ b/src/lib/stepper/BUILD.bazel @@ -75,3 +75,8 @@ markdown_to_html( name = "overview", srcs = [":stepper.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/table/BUILD.bazel b/src/lib/table/BUILD.bazel index d02da67869dd..7571a1fbf7dd 100644 --- a/src/lib/table/BUILD.bazel +++ b/src/lib/table/BUILD.bazel @@ -55,3 +55,8 @@ markdown_to_html( name = "overview", srcs = [":table.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/tabs/BUILD.bazel b/src/lib/tabs/BUILD.bazel index 35bccdbf58a1..3e258eee6dc9 100644 --- a/src/lib/tabs/BUILD.bazel +++ b/src/lib/tabs/BUILD.bazel @@ -102,3 +102,8 @@ markdown_to_html( name = "overview", srcs = [":tabs.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/toolbar/BUILD.bazel b/src/lib/toolbar/BUILD.bazel index 34c4fc5bc6a8..6af2e5c3d5d5 100644 --- a/src/lib/toolbar/BUILD.bazel +++ b/src/lib/toolbar/BUILD.bazel @@ -51,6 +51,11 @@ markdown_to_html( srcs = [":toolbar.md"], ) +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) + diff --git a/src/lib/tooltip/BUILD.bazel b/src/lib/tooltip/BUILD.bazel index 5319e8a453b2..615e8b7693e9 100644 --- a/src/lib/tooltip/BUILD.bazel +++ b/src/lib/tooltip/BUILD.bazel @@ -70,3 +70,8 @@ markdown_to_html( name = "overview", srcs = [":tooltip.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/lib/tree/BUILD.bazel b/src/lib/tree/BUILD.bazel index 08b4aa494c53..a666bd2c6e68 100644 --- a/src/lib/tree/BUILD.bazel +++ b/src/lib/tree/BUILD.bazel @@ -50,3 +50,8 @@ markdown_to_html( name = "overview", srcs = [":tree.md"], ) + +filegroup( + name = "source-files", + srcs = glob(["**/*.ts"]), +) diff --git a/src/material-examples/BUILD.bazel b/src/material-examples/BUILD.bazel index 5088d638fdfa..9b62acfb36c6 100644 --- a/src/material-examples/BUILD.bazel +++ b/src/material-examples/BUILD.bazel @@ -51,7 +51,8 @@ package_docs_content( "//src/lib:overviews": "overviews/material", "//src/cdk:overviews": "overviews/cdk", - # TODO(devversion): we need to also package the API html files here + # Package the API docs for the Material and CDK package into the docs-content + "//src:api-docs": "api-docs", } ) diff --git a/tools/dgeni/bazel-bin.ts b/tools/dgeni/bazel-bin.ts index 3f0973f61497..ef1d918b3945 100644 --- a/tools/dgeni/bazel-bin.ts +++ b/tools/dgeni/bazel-bin.ts @@ -67,7 +67,9 @@ if (require.main === module) { // inherited class members across entry points or packages. entryPoints.forEach(entryPointName => { const entryPointPath = `${packageName}/${entryPointName}`; - const entryPointIndexPath = `${entryPointPath}/index.ts`; + // For the entry point path we temporarily want to replace "material" with "lib", as + // our package source folder does not align with the entry-point name. + const entryPointIndexPath = `${entryPointPath.replace('material', 'lib')}/index.ts`; tsParser.options.paths![`@angular/${entryPointPath}`] = [entryPointIndexPath]; readTypeScriptModules.sourceFiles.push(entryPointIndexPath); diff --git a/tools/dgeni/index.bzl b/tools/dgeni/index.bzl index 8438b0e8c9a5..9fc0177f7593 100644 --- a/tools/dgeni/index.bzl +++ b/tools/dgeni/index.bzl @@ -7,7 +7,8 @@ def _dgeni_api_docs(ctx): args = ctx.actions.args() expected_outputs = []; - output_directory = ctx.actions.declare_directory(ctx.attr.name) + output_dir_name = ctx.attr.name; + output_dir_path = "%s/%s/%s" % (ctx.bin_dir.path, ctx.label.package, output_dir_name) # Do nothing if there are no input files. Bazel will throw if we schedule an action # that returns no outputs. @@ -26,7 +27,7 @@ def _dgeni_api_docs(ctx): # Pass the path to the output directory. This will be used to instruct Dgeni where the docs # output should be written to. (e.g. bazel-out/bin/src/docs-content) - args.add(output_directory.path) + args.add(output_dir_path) # Pass each specified entry point and it's corresponding entry points to Dgeni. This will then # be used to resolve the files that need to be parsed by Dgeni. @@ -34,6 +35,22 @@ def _dgeni_api_docs(ctx): args.add(package_name) args.add_joined(entry_points, join_with = ",") + for entry_point in entry_points: + expected_outputs += [ + # Declare the output for the current entry-point. The output file will always follow the + # same format: "{output_folder}/{package_name}-{entry_point_name}.html" + # (e.g. "api-docs/material-slider.html") + ctx.actions.declare_file("%s/%s-%s.html" % (output_dir_name, package_name, entry_point)) + ] + + # Small workaround that ensures that the "ripple" API doc is properly exposed as an output + # of the packaging rule. Technically Dgeni should not output the "ripple" directory as + # it's own entry-point. TODO(devversion): Support sub API docs for entry-points + if package_name == "material": + expected_outputs += [ + ctx.actions.declare_file("%s/%s-%s.html" % (output_dir_name, package_name, "ripple")) + ] + # Run the Dgeni bazel executable which builds the documentation output based on the # configured rule attributes. ctx.actions.run( @@ -41,13 +58,11 @@ def _dgeni_api_docs(ctx): # templates are available in the sandbox execution and can be read by Dgeni. inputs = input_files + ctx.files._dgeni_templates, executable = ctx.executable._dgeni_bin, - outputs = [output_directory], + outputs = expected_outputs, arguments = [args], ) - # TODO(devversion): We can construct a list of output files that will be generated. This would - # improve hermeticity and Bazel's caching mechanism for this rule. - return DefaultInfo(files = depset([output_directory])) + return DefaultInfo(files = depset(expected_outputs)) """ Rule definition for the "dgeni_api_docs" rule that can generate API documentation