Skip to content

Commit 6dbac49

Browse files
Wyveraldcopybara-github
authored andcommitted
Docgen: Split the "global functions" page into multiple ones
====== - Primary motivation: #16383 - Currently, the pages generated by docgen is a `PageTitle -> Page` map. It's then separated into multiple categories based on the `docCategory` value of the `@StarlarkBuiltin` annotation, with the exception of the "global functions" page, which is special-cased. - This has several issues: for one, the configuration fragment named "proto" has a conflict with the top-level module named "proto", since everything is in the same map (we work around this by naming the latter "ProtoModule", which is wrong and confusing). - For another, we can't easily split the "global functions" page into multiple ones, unless we special-case every one of them. - So we structure the returned pages into a `Category -> [Page]` map. The new category `GLOBAL_FUNCTION` contains a few pages, each of which contains global functions available in a certain environment (see d1c72d7). The other categories are largely unchanged. - We also change the URL format of these pages from `..../lib/$TITLE.html` to `..../lib/$CATEGORY/$TITLE.html`. - The bulk of this CL involves fixing up all links. - This also means that "proto" the configuration fragment and "proto" the top-level module can now both be named "proto". - This does break old links, but I can't find the energy to set up redirects for everything... - Miscellaneous changes: - The `starlark-nav.vm` page is removed; nobody uses it. - Renamed the category overview pages from `..../lib/starlark-$CATEGORY.html` to just `..../lib/$CATEGORY.html`, now that there's no pages directly under `..../lib`. - A bunch of small documentation fixes across the codebase as I went through them. Fixes #16383 PiperOrigin-RevId: 523745069 Change-Id: Idfbb29f1f589bde58ac5a8b199a788245286256a
1 parent 8ec4c50 commit 6dbac49

File tree

89 files changed

+1322
-1402
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1322
-1402
lines changed

site/en/concepts/platforms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ contact [bazel-dev]{: .external}.
418418
[Platforms examples]: https://github.com/hlopko/bazel_platforms_examples
419419
[platform mappings design]: https://docs.google.com/document/d/1Vg_tPgiZbSrvXcJ403vZVAGlsWhH9BUDrAxMOYnO0Ls/edit
420420
[platform Rule]: /reference/be/platform#platform
421-
[register_toolchains Function]: /rules/lib/globals#register_toolchains
421+
[register_toolchains Function]: /rules/lib/globals/workspace#register_toolchains
422422
[Rust rules]: https://github.com/bazelbuild/rules_rust
423423
[select()]: /docs/configurable-attributes
424424
[select() Platforms]: /docs/configurable-attributes#platforms

site/en/concepts/visibility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ Load visibility is available as of Bazel 6.0.
275275
### Declaring load visibility {:#declaring-load-visibility}
276276

277277
To set the load visibility of a `.bzl` file, call the
278-
[`visibility()`](/rules/lib/globals#visibility) function from within the file.
278+
[`visibility()`](/rules/lib/globals/bzl#visibility) function from within the file.
279279
The argument to `visibility()` is a list of package specifications, just like
280280
the [`packages`](/reference/be/functions#package_group.packages) attribute of
281281
`package_group`. However, `visibility()` does not accept negative package

site/en/configure/integrate-cpp.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ should use the helper function available at
1717
[@bazel_tools//tools/cpp:toolchain_utils.bzl](https://source.bazel.build/bazel/+/main:tools/cpp/toolchain_utils.bzl;l=23),
1818
which works both when toolchains are disabled and enabled. To depend on a C++
1919
toolchain in your rule, add a
20-
[`Label`](/rules/lib/attr#label)
20+
[`Label`](/rules/lib/toplevel/attr#label)
2121
attribute named `_cc_toolchain` and point it
2222
to `@bazel_tools//tools/cpp:current_cc_toolchain` (an instance of
2323
`cc_toolchain_alias` rule, that points to the currently selected C++ toolchain).
2424
Then, in the rule implementation, use
2525
[`find_cpp_toolchain(ctx)`](https://source.bazel.build/bazel/+/main:tools/cpp/toolchain_utils.bzl;l=23)
2626
to get the
27-
[`CcToolchainInfo`](/rules/lib/CcToolchainInfo).
27+
[`CcToolchainInfo`](/rules/lib/providers/CcToolchainInfo).
2828
A complete working example can be found
2929
[in the rules_cc examples](https://github.com/bazelbuild/rules_cc/blob/main/examples/write_cc_toolchain_cpu/write_cc_toolchain_cpu.bzl){: .external}.
3030

@@ -42,14 +42,14 @@ you need the following:
4242

4343
* `features` and `action_configs` - these come from the `CcToolchainConfigInfo`
4444
and encapsulated in `CcToolchainInfo`
45-
* `FeatureConfiguration` - returned by [cc_common.configure_features](/rules/lib/cc_common#configure_features)
45+
* `FeatureConfiguration` - returned by [cc_common.configure_features](/rules/lib/toplevel/cc_common#configure_features)
4646
* cc toolchain config variables - returned by
47-
[cc_common.create_compile_variables](/rules/lib/cc_common#create_compile_variables)
47+
[cc_common.create_compile_variables](/rules/lib/toplevel/cc_common#create_compile_variables)
4848
or
49-
[cc_common.create_link_variables](/rules/lib/cc_common#create_link_variables).
49+
[cc_common.create_link_variables](/rules/lib/toplevel/cc_common#create_link_variables).
5050

5151
There still are tool-specific getters, such as
52-
[compiler_executable](/rules/lib/CcToolchainInfo#compiler_executable).
52+
[compiler_executable](/rules/lib/providers/CcToolchainInfo#compiler_executable).
5353
Prefer `get_tool_for_action` over these, as tool-specific getters will
5454
eventually be removed.
5555

@@ -59,10 +59,10 @@ A complete working example can be found
5959
## Implementing Starlark rules that depend on C++ rules and/or that C++ rules can depend on {:#implement-starlark-rules}
6060

6161
Most C++ rules provide
62-
[`CcInfo`](/rules/lib/CcInfo),
63-
a provider containing [`CompilationContext`](/rules/lib/CompilationContext)
62+
[`CcInfo`](/rules/lib/providers/CcInfo),
63+
a provider containing [`CompilationContext`](/rules/lib/builtins/CompilationContext)
6464
and
65-
[`LinkingContext`](/rules/lib/LinkingContext).
65+
[`LinkingContext`](/rules/lib/builtins/LinkingContext).
6666
Through these it is possible to access information such as all transitive headers
6767
or libraries to link. From `CcInfo` and from the `CcToolchainInfo` custom
6868
Starlark rules should be able to get all the information they need.

site/en/docs/bazel-and-apple.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ when building your macOS and iOS projects:
3636

3737
* Modules:
3838

39-
* [`apple_bitcode_mode`](/rules/lib/apple_bitcode_mode)
40-
* [`apple_common`](/rules/lib/apple_common)
41-
* [`apple_platform`](/rules/lib/apple_platform)
42-
* [`apple_platform_type`](/rules/lib/apple_platform_type)
43-
* [`apple_toolchain`](/rules/lib/apple_toolchain)
44-
* [`XcodeVersionConfig`](/rules/lib/XcodeVersionConfig)
39+
* [`apple_bitcode_mode`](/rules/lib/builtins/apple_bitcode_mode)
40+
* [`apple_common`](/rules/lib/toplevel/apple_common)
41+
* [`apple_platform`](/rules/lib/builtins/apple_platform)
42+
* [`apple_platform_type`](/rules/lib/builtins/apple_platform_type)
43+
* [`apple_toolchain`](/rules/lib/builtins/apple_toolchain)
4544

4645
* Configuration fragments:
4746

48-
* [`apple`](/rules/lib/apple)
47+
* [`apple`](/rules/lib/fragments/apple)
4948

5049
* Providers:
5150

52-
* [`ObjcProvider`](/rules/lib/ObjcProvider)
51+
* [`ObjcProvider`](/rules/lib/providers/ObjcProvider)
52+
* [`XcodeVersionConfig`](/rules/lib/providers/XcodeVersionConfig)
5353

5454
## Xcode selection {:#xcode-selection}
5555

@@ -61,7 +61,7 @@ the set of available Xcode versions and sets a default version if
6161
represented in the `--xcode_config` target.
6262

6363
If you do not pass `--xcode_config`, Bazel will use the autogenerated
64-
[`XcodeVersionConfig`](/rules/lib/XcodeVersionConfig) that represents the
64+
[`XcodeVersionConfig`](/rules/lib/providers/XcodeVersionConfig) that represents the
6565
Xcode versions available on your host machine. The default version is
6666
the newest available Xcode version. This is appropriate for local execution.
6767

site/en/docs/bazel-and-java.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,17 @@ The following modules, configuration fragments, and providers will help you
131131
[extend Bazel's capabilities](/extending/concepts) when building your Java
132132
projects:
133133

134-
* Main Java provider: [`java_common`](/rules/lib/java_common)
135-
* Main Java module: [`JavaInfo`](/rules/lib/JavaInfo)
136-
* Configuration fragment: [`java`](/rules/lib/java)
134+
* Main Java module: [`java_common`](/rules/lib/toplevel/java_common)
135+
* Main Java provider: [`JavaInfo`](/rules/lib/providers/JavaInfo)
136+
* Configuration fragment: [`java`](/rules/lib/fragments/java)
137137
* Other modules:
138138

139-
* [`java_annotation_processing`](/rules/lib/java_annotation_processing)
140-
* [`java_compilation_info`](/rules/lib/java_compilation_info)
141-
* [`java_output`](/rules/lib/java_output)
142-
* [`java_output_jars`](/rules/lib/java_output_jars)
143-
* [`JavaRuntimeInfo`](/rules/lib/JavaRuntimeInfo)
144-
* [`JavaToolchainInfo`](/rules/lib/JavaToolchainInfo)
139+
* [`java_annotation_processing`](/rules/lib/builtins/java_annotation_processing)
140+
* [`java_compilation_info`](/rules/lib/providers/java_compilation_info)
141+
* [`java_output`](/rules/lib/builtins/java_output)
142+
* [`java_output_jars`](/rules/lib/providers/java_output_jars)
143+
* [`JavaRuntimeInfo`](/rules/lib/providers/JavaRuntimeInfo)
144+
* [`JavaToolchainInfo`](/rules/lib/providers/JavaToolchainInfo)
145145

146146
## Configuring the Java toolchains {:#config-java-toolchains}
147147

site/en/docs/cc-toolchain-config-reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ Bazel needs to know the following:
2828
If the compiler has support for multiple architectures, Bazel needs to configure
2929
them separately.
3030

31-
[`CcToolchainConfigInfo`](/rules/lib/CcToolchainConfigInfo) is a provider that provides the necessary level of
31+
[`CcToolchainConfigInfo`](/rules/lib/providers/CcToolchainConfigInfo) is a provider that provides the necessary level of
3232
granularity for configuring the behavior of Bazel's C++ rules. By default,
3333
Bazel automatically configures `CcToolchainConfigInfo` for your build, but you
3434
have the option to configure it manually. For that, you need a Starlark rule
3535
that provides the `CcToolchainConfigInfo` and you need to point the
3636
[`toolchain_config`](/reference/be/c-cpp#cc_toolchain.toolchain_config) attribute of the `cc_toolchain` to your rule.
3737
You can create the `CcToolchainConfigInfo` by calling
38-
[`cc_common.create_cc_toolchain_config_info()`](/rules/lib/cc_common#create_cc_toolchain_config_info).
38+
[`cc_common.create_cc_toolchain_config_info()`](/rules/lib/toplevel/cc_common#create_cc_toolchain_config_info).
3939
You can find Starlark constructors for all structs you'll need in the process in
4040
[`@rules_cc//cc:cc_toolchain_config_lib.bzl`](https://github.com/bazelbuild/rules_cc/blob/master/cc/cc_toolchain_config_lib.bzl){: .external}.
4141

site/en/docs/user-manual.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ The label of a platform rule that describes the host system.
13251325
The platforms that are available as execution platforms to run actions.
13261326
Platforms can be specified by exact target, or as a target pattern. These
13271327
platforms will be considered before those declared in the WORKSPACE file by
1328-
[register_execution_platforms()](/rules/lib/globals#register_execution_platforms).
1328+
[register_execution_platforms()](/rules/lib/globals/workspace#register_execution_platforms).
13291329
This option accepts a comma-separated list of platforms in order of priority.
13301330
If the flag is passed multiple times, the most recent overrides.
13311331

@@ -1334,7 +1334,7 @@ If the flag is passed multiple times, the most recent overrides.
13341334
The toolchain rules to be considered during toolchain resolution. Toolchains
13351335
can be specified by exact target, or as a target pattern. These toolchains will
13361336
be considered before those declared in the WORKSPACE file by
1337-
[register_toolchains()](/rules/lib/globals#register_toolchains).
1337+
[register_toolchains()](/rules/lib/globals/workspace#register_toolchains).
13381338

13391339
#### `--toolchain_resolution_debug={{ "<var>" }}regex{{ "</var>" }}` {:#toolchain-resolution-debug}
13401340

site/en/extending/aspects.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Book: /_book.yaml
66
{% include "_buttons.html" %}
77

88
This page explains the basics and benefits of using
9-
[aspects](/rules/lib/globals#aspect) and provides simple and advanced
9+
[aspects](/rules/lib/globals/bzl#aspect) and provides simple and advanced
1010
examples.
1111

1212
Aspects allow augmenting build dependency graphs with additional information
@@ -111,7 +111,7 @@ print_aspect = aspect(
111111
)
112112
```
113113
Aspect definitions are similar to rule definitions, and defined using
114-
the [`aspect`](/rules/lib/globals#aspect) function.
114+
the [`aspect`](/rules/lib/globals/bzl#aspect) function.
115115

116116
Just like a rule, an aspect has an implementation function which in this case is
117117
``_print_aspect_impl``.
@@ -141,12 +141,12 @@ Aspect implementation functions are similar to the rule implementation
141141
functions. They return [providers](/extending/rules#providers), can generate
142142
[actions](/extending/rules#actions), and take two arguments:
143143

144-
* `target`: the [target](/rules/lib/Target) the aspect is being applied to.
145-
* `ctx`: [`ctx`](/rules/lib/ctx) object that can be used to access attributes
144+
* `target`: the [target](/rules/lib/builtins/Target) the aspect is being applied to.
145+
* `ctx`: [`ctx`](/rules/lib/builtins/ctx) object that can be used to access attributes
146146
and generate outputs and actions.
147147

148148
The implementation function can access the attributes of the target rule via
149-
[`ctx.rule.attr`](/rules/lib/ctx#rule). It can examine providers that are
149+
[`ctx.rule.attr`](/rules/lib/builtins/ctx#rule). It can examine providers that are
150150
provided by the target to which it is applied (via the `target` argument).
151151

152152
Aspects are required to return a list of providers. In this example, the aspect
@@ -329,12 +329,12 @@ implementation of aspect A. The providers that a rule implementation propagates
329329
are created and frozen before aspects are applied and cannot be modified from an
330330
aspect. It is an error if a target and an aspect that is applied to it each
331331
provide a provider with the same type, with the exceptions of
332-
[`OutputGroupInfo`](/rules/lib/OutputGroupInfo)
332+
[`OutputGroupInfo`](/rules/lib/providers/OutputGroupInfo)
333333
(which is merged, so long as the
334334
rule and aspect specify different output groups) and
335-
[`InstrumentedFilesInfo`](/rules/lib/InstrumentedFilesInfo)
335+
[`InstrumentedFilesInfo`](/rules/lib/providers/InstrumentedFilesInfo)
336336
(which is taken from the aspect). This means that aspect implementations may
337-
never return [`DefaultInfo`](/rules/lib/DefaultInfo).
337+
never return [`DefaultInfo`](/rules/lib/providers/DefaultInfo).
338338

339339
The parameters and private attributes are passed in the attributes of the
340340
``ctx``. This example references the ``extension`` parameter and determines
@@ -401,4 +401,4 @@ itself, and all of the targets accessible recursively via ``deps``.
401401

402402
## References
403403

404-
* [`aspect` API reference](/rules/lib/globals#aspect)
404+
* [`aspect` API reference](/rules/lib/globals/bzl#aspect)

site/en/extending/concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ they will not be executed.
8383
The two links below will be very useful when writing your own extensions. Keep
8484
them within reach:
8585

86-
* The [API reference](/rules/lib/starlark-overview)
86+
* The [API reference](/rules/lib)
8787

8888
* [Examples](https://github.com/bazelbuild/examples/tree/master/rules)
8989

site/en/extending/config.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This makes it possible to:
1414
* define custom flags for your project, obsoleting the need for
1515
[`--define`](/docs/configurable-attributes#custom-keys)
1616
* write
17-
[transitions](/rules/lib/transition#transition) to configure deps in
17+
[transitions](/rules/lib/builtins/transition#transition) to configure deps in
1818
different configurations than their parents
1919
(such as `--compilation_mode=opt` or `--cpu=arm`)
2020
* bake better defaults into rules (such as automatically build `//my:android_app`
@@ -50,7 +50,7 @@ set via [user-defined transitions](#user-defined-transitions).
5050

5151
Build settings are rules like any other rule and are differentiated using the
5252
Starlark `rule()` function's `build_setting`
53-
[attribute](/rules/lib/globals#rule.build_setting).
53+
[attribute](/rules/lib/globals/bzl#rule.build_setting).
5454

5555
```python
5656
# example/buildsettings/build_settings.bzl
@@ -63,13 +63,13 @@ string_flag = rule(
6363
The `build_setting` attribute takes a function that designates the type of the
6464
build setting. The type is limited to a set of basic Starlark types like
6565
`bool` and `string`. See the `config` module
66-
[documentation](/rules/lib/config) for details. More complicated typing can be
66+
[documentation](/rules/lib/toplevel/config) for details. More complicated typing can be
6767
done in the rule's implementation function. More on this below.
6868

6969
The `config` module's functions takes an optional boolean parameter, `flag`,
7070
which is set to false by default. if `flag` is set to true, the build setting
7171
can be set on the command line by users as well as internally by rule writers
72-
via default values and [transitions](/rules/lib/transition#transition).
72+
via default values and [transitions](/rules/lib/builtins/transition#transition).
7373
Not all settings should be settable by users. For example, if you as a rule
7474
writer have some debug mode that you'd like to turn on inside test rules,
7575
you don't want to give users the ability to indiscriminately turn on that
@@ -80,7 +80,7 @@ feature inside other non-test rules.
8080
Like all rules, build setting rules have [implementation functions](/extending/rules#implementation-function).
8181
The basic Starlark-type value of the build settings can be accessed via the
8282
`ctx.build_setting_value` method. This method is only available to
83-
[`ctx`](/rules/lib/ctx) objects of build setting rules. These implementation
83+
[`ctx`](/rules/lib/builtins/ctx) objects of build setting rules. These implementation
8484
methods can directly forward the build settings value or do additional work on
8585
it, like type checking or more complex struct creation. Here's how you would
8686
implement an `enum`-typed build setting:
@@ -328,7 +328,7 @@ can't customely defined.
328328
Label-typed settings will eventually replace the functionality of late-bound
329329
defaults. Late-bound default attributes are Label-typed attributes whose
330330
final values can be affected by configuration. In Starlark, this will replace
331-
the [`configuration_field`](/rules/lib/globals#configuration_field)
331+
the [`configuration_field`](/rules/lib/globals/bzl#configuration_field)
332332
API.
333333

334334
```python
@@ -388,7 +388,7 @@ config_setting(
388388
## User-defined transitions {:#user-defined-transitions}
389389

390390
A configuration
391-
[transition](/rules/lib/transition#transition)
391+
[transition](/rules/lib/builtins/transition#transition)
392392
maps the transformation from one configured target to another within the
393393
build graph.
394394

@@ -423,7 +423,7 @@ with special restrictions.
423423

424424
In Starlark, transitions are defined much like rules, with a defining
425425
`transition()`
426-
[function](/rules/lib/transition#transition)
426+
[function](/rules/lib/builtins/transition#transition)
427427
and an implementation function.
428428

429429
```python

0 commit comments

Comments
 (0)