Skip to content

Commit caed8d6

Browse files
authored
docs: generate bzlmod extension docs (#1169)
- Upgrade [bazel-starlib](https://github.com/cgrindel/bazel-starlib) to 0.21.0 to pickup a version of stardoc that supports bzmod documentation generation. - Generate documentation for `swift_deps` bzlmod extension. Closes #1168.
1 parent 633f75d commit caed8d6

File tree

8 files changed

+108
-27
lines changed

8 files changed

+108
-27
lines changed

BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ load(
1111
)
1212
load("//ci:defs.bzl", "ci_workflow")
1313

14+
# Allow docs to access the extensions.bzl
15+
exports_files(["extensions.bzl"])
16+
1417
# MARK: - Bazel Starlark Lint and Formatting
1518

1619
bzlformat_pkg(name = "bzlformat")

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module(
55

66
# MARK: - Runtime Dependencies
77

8-
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.18.1")
8+
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.21.0")
99
bazel_dep(name = "bazel_skylib", version = "1.4.2")
1010
bazel_dep(
1111
name = "rules_go",

docs/BUILD.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ _DOC_INFOS = [
4040
"swift_deps_index",
4141
],
4242
),
43+
doc_infos.new(
44+
name = "bzlmod_extensions",
45+
label = "//:extensions",
46+
symbols = [
47+
"swift_deps",
48+
],
49+
),
4350
]
4451

4552
_DOC_WITH_SYMBOLS = {
@@ -98,6 +105,19 @@ external Swift packages.
98105
symbols = _DOC_WITH_SYMBOLS["internal_rules_and_macros"].symbols,
99106
)
100107

108+
write_header(
109+
name = "bzlmod_extensions_overview_header",
110+
header_content = [
111+
"# Bazel Modules (bzlmod) Extensions",
112+
"",
113+
"""
114+
The bzlmod extensions described below are used by `rules_swift_package_manager` \
115+
to customize the build of the external Swift packages.\
116+
""",
117+
],
118+
symbols = _DOC_WITH_SYMBOLS["bzlmod_extensions"].symbols,
119+
)
120+
101121
doc_for_provs(doc_provs = _ALL_DOC_PROVIDERS)
102122

103123
bzl_library(

docs/bzlmod_extensions_overview.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!-- Generated with Stardoc, Do Not Edit! -->
2+
# Bazel Modules (bzlmod) Extensions
3+
4+
5+
The bzlmod extensions described below are used by `rules_swift_package_manager` to customize the build of the external Swift packages.
6+
7+
On this page:
8+
9+
* [swift_deps](#swift_deps)
10+
11+
12+
<a id="swift_deps"></a>
13+
14+
## swift_deps
15+
16+
<pre>
17+
swift_deps = use_extension("@rules_swift_package_manager//:extensions.bzl", "swift_deps")
18+
swift_deps.configure_package(<a href="#swift_deps.configure_package-name">name</a>, <a href="#swift_deps.configure_package-init_submodules">init_submodules</a>, <a href="#swift_deps.configure_package-patch_args">patch_args</a>, <a href="#swift_deps.configure_package-patch_cmds">patch_cmds</a>, <a href="#swift_deps.configure_package-patch_cmds_win">patch_cmds_win</a>,
19+
<a href="#swift_deps.configure_package-patch_tool">patch_tool</a>, <a href="#swift_deps.configure_package-patches">patches</a>, <a href="#swift_deps.configure_package-recursive_init_submodules">recursive_init_submodules</a>)
20+
swift_deps.from_package(<a href="#swift_deps.from_package-declare_swift_deps_info">declare_swift_deps_info</a>, <a href="#swift_deps.from_package-resolved">resolved</a>, <a href="#swift_deps.from_package-swift">swift</a>)
21+
</pre>
22+
23+
24+
**TAG CLASSES**
25+
26+
<a id="swift_deps.configure_package"></a>
27+
28+
### configure_package
29+
30+
Used to add or override settings for a particular Swift package.
31+
32+
**Attributes**
33+
34+
| Name | Description | Type | Mandatory | Default |
35+
| :------------- | :------------- | :------------- | :------------- | :------------- |
36+
| <a id="swift_deps.configure_package-name"></a>name | The identity (i.e., name in the package's manifest) for the Swift package. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
37+
| <a id="swift_deps.configure_package-init_submodules"></a>init_submodules | Whether to clone submodules in the repository. | Boolean | optional | `False` |
38+
| <a id="swift_deps.configure_package-patch_args"></a>patch_args | The arguments given to the patch tool. Defaults to -p0, however -p1 will usually be needed for patches generated by git. If multiple -p arguments are specified, the last one will take effect.If arguments other than -p are specified, Bazel will fall back to use patch command line tool instead of the Bazel-native patch implementation. When falling back to patch command line tool and patch_tool attribute is not specified, `patch` will be used. | List of strings | optional | `["-p0"]` |
39+
| <a id="swift_deps.configure_package-patch_cmds"></a>patch_cmds | Sequence of Bash commands to be applied on Linux/Macos after patches are applied. | List of strings | optional | `[]` |
40+
| <a id="swift_deps.configure_package-patch_cmds_win"></a>patch_cmds_win | Sequence of Powershell commands to be applied on Windows after patches are applied. If this attribute is not set, patch_cmds will be executed on Windows, which requires Bash binary to exist. | List of strings | optional | `[]` |
41+
| <a id="swift_deps.configure_package-patch_tool"></a>patch_tool | The patch(1) utility to use. If this is specified, Bazel will use the specified patch tool instead of the Bazel-native patch implementation. | String | optional | `""` |
42+
| <a id="swift_deps.configure_package-patches"></a>patches | A list of files that are to be applied as patches after extracting the archive. By default, it uses the Bazel-native patch implementation which doesn't support fuzz match and binary patch, but Bazel will fall back to use patch command line tool if `patch_tool` attribute is specified or there are arguments other than `-p` in `patch_args` attribute. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
43+
| <a id="swift_deps.configure_package-recursive_init_submodules"></a>recursive_init_submodules | Whether to clone submodules recursively in the repository. | Boolean | optional | `True` |
44+
45+
<a id="swift_deps.from_package"></a>
46+
47+
### from_package
48+
49+
Load Swift packages from `Package.swift` and `Package.resolved` files.
50+
51+
**Attributes**
52+
53+
| Name | Description | Type | Mandatory | Default |
54+
| :------------- | :------------- | :------------- | :------------- | :------------- |
55+
| <a id="swift_deps.from_package-declare_swift_deps_info"></a>declare_swift_deps_info | Declare a `swift_deps_info` repository that is used by external tooling (e.g. Swift Gazelle plugin). | Boolean | optional | `False` |
56+
| <a id="swift_deps.from_package-resolved"></a>resolved | A `Package.resolved`. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
57+
| <a id="swift_deps.from_package-swift"></a>swift | A `Package.swift`. | <a href="https://bazel.build/concepts/labels">Label</a> | required | |
58+
59+

docs/internal_rules_and_macros_overview.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Generate a modulemap for an Objective-C module.
2828
| Name | Description | Type | Mandatory | Default |
2929
| :------------- | :------------- | :------------- | :------------- | :------------- |
3030
| <a id="generate_modulemap-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
31-
| <a id="generate_modulemap-deps"></a>deps | The module maps that this module uses. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
31+
| <a id="generate_modulemap-deps"></a>deps | The module maps that this module uses. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
3232
| <a id="generate_modulemap-hdrs"></a>hdrs | The public headers for this module. | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | |
33-
| <a id="generate_modulemap-module_name"></a>module_name | The name of the module. | String | optional | <code>""</code> |
34-
| <a id="generate_modulemap-noop"></a>noop | Designates whether a modulemap should be generated. If <code>False</code>, a modulemap is generated. If <code>True</code>, a modulemap file is not generated and the returned providers are empty. | Boolean | optional | <code>False</code> |
33+
| <a id="generate_modulemap-module_name"></a>module_name | The name of the module. | String | optional | `""` |
34+
| <a id="generate_modulemap-noop"></a>noop | Designates whether a modulemap should be generated. If `False`, a modulemap is generated. If `True`, a modulemap file is not generated and the returned providers are empty. | Boolean | optional | `False` |
3535

3636

3737
<a id="resource_bundle_accessor"></a>
@@ -69,6 +69,6 @@ Generate an Info.plist for an SPM resource bundle.
6969
| Name | Description | Type | Mandatory | Default |
7070
| :------------- | :------------- | :------------- | :------------- | :------------- |
7171
| <a id="resource_bundle_infoplist-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
72-
| <a id="resource_bundle_infoplist-region"></a>region | The localization/region value that should be embedded in the Info.plist. | String | optional | <code>"en"</code> |
72+
| <a id="resource_bundle_infoplist-region"></a>region | The localization/region value that should be embedded in the Info.plist. | String | optional | `"en"` |
7373

7474

0 commit comments

Comments
 (0)