diff --git a/bzl_library.bzl b/bzl_library.bzl index 1b59440f..ef479494 100644 --- a/bzl_library.bzl +++ b/bzl_library.bzl @@ -46,11 +46,11 @@ bzl_library = rule( implementation = _bzl_library_impl, attrs = { "srcs": attr.label_list( - allow_files = [".bzl"], - doc = "List of `.bzl` files that are processed to create this target.", + allow_files = [".bzl", ".scl"], + doc = "List of `.bzl` and `.scl` files that are processed to create this target.", ), "deps": attr.label_list( - allow_files = [".bzl"], + allow_files = [".bzl", ".scl"], providers = [ [StarlarkLibraryInfo], ], @@ -58,7 +58,7 @@ bzl_library = rule( Starlark files listed in `srcs`.""", ), }, - doc = """Creates a logical collection of Starlark .bzl files. + doc = """Creates a logical collection of Starlark .bzl and .scl files. Example: Suppose your project has the following structure: diff --git a/docs/BUILD b/docs/BUILD index 4d31cd10..a809f2f0 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -14,6 +14,12 @@ stardoc_with_diff_test( out_label = "//docs:build_test_doc.md", ) +stardoc_with_diff_test( + name = "bzl_library", + bzl_library_target = "//:bzl_library", + out_label = "//docs:bzl_library.md", +) + stardoc_with_diff_test( name = "collections", bzl_library_target = "//lib:collections", diff --git a/docs/bzl_library.md b/docs/bzl_library.md new file mode 100755 index 00000000..f4b0dc7e --- /dev/null +++ b/docs/bzl_library.md @@ -0,0 +1,88 @@ + + +Skylib module containing a library rule for aggregating rules files. + + + +## bzl_library + +
+bzl_library(name, deps, srcs)
+
+ +Creates a logical collection of Starlark .bzl and .scl files. + +Example: + Suppose your project has the following structure: + + ``` + [workspace]/ + WORKSPACE + BUILD + checkstyle/ + BUILD + checkstyle.bzl + lua/ + BUILD + lua.bzl + luarocks.bzl + ``` + + In this case, you can have `bzl_library` targets in `checkstyle/BUILD` and + `lua/BUILD`: + + `checkstyle/BUILD`: + + ```python + load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + + bzl_library( + name = "checkstyle-rules", + srcs = ["checkstyle.bzl"], + ) + ``` + + `lua/BUILD`: + + ```python + load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + + bzl_library( + name = "lua-rules", + srcs = [ + "lua.bzl", + "luarocks.bzl", + ], + ) + ``` + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| deps | List of other bzl_library targets that are required by the Starlark files listed in srcs. | List of labels | optional | [] | +| srcs | List of .bzl and .scl files that are processed to create this target. | List of labels | optional | [] | + + + + +## StarlarkLibraryInfo + +
+StarlarkLibraryInfo(srcs, transitive_srcs)
+
+ +Information on contained Starlark rules. + +**FIELDS** + + +| Name | Description | +| :------------- | :------------- | +| srcs | Top level rules files. | +| transitive_srcs | Transitive closure of rules files required for interpretation of the srcs | + +