diff --git a/src/main/java/com/google/devtools/build/docgen/annot/GlobalMethods.java b/src/main/java/com/google/devtools/build/docgen/annot/GlobalMethods.java
index 0fdeb668031d15..a61d20261cc084 100644
--- a/src/main/java/com/google/devtools/build/docgen/annot/GlobalMethods.java
+++ b/src/main/java/com/google/devtools/build/docgen/annot/GlobalMethods.java
@@ -40,6 +40,7 @@ enum Environment {
+ " Encyclopedia for extra functions and build rules,"
+ " which can also be used in BUILD files."),
MODULE("MODULE.bazel files", "Methods available in MODULE.bazel files."),
+ REPO("REPO.bazel files", "Methods available in REPO.bazel files."),
VENDOR("VENDOR.bazel files", "Methods available in VENDOR.bazel files."),
WORKSPACE("WORKSPACE files", "Methods available in WORKSPACE files.");
diff --git a/src/main/java/com/google/devtools/build/lib/packages/PackageCallable.java b/src/main/java/com/google/devtools/build/lib/packages/PackageCallable.java
index 0a9efa721c0b07..50411f03e987f7 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/PackageCallable.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/PackageCallable.java
@@ -14,6 +14,8 @@
package com.google.devtools.build.lib.packages;
+import com.google.devtools.build.docgen.annot.GlobalMethods;
+import com.google.devtools.build.docgen.annot.GlobalMethods.Environment;
import java.util.Map;
import net.starlark.java.annot.Param;
import net.starlark.java.annot.StarlarkMethod;
@@ -25,6 +27,7 @@
* Utility class encapsulating the standard definition of the {@code package()} function of BUILD
* files.
*/
+@GlobalMethods(environment = Environment.BUILD)
public class PackageCallable {
protected PackageCallable() {}
@@ -33,8 +36,16 @@ protected PackageCallable() {}
@StarlarkMethod(
name = "package",
- documented = false, // documented in docgen/templates/be/functions.vm
- extraKeywords = @Param(name = "kwargs", defaultValue = "{}"),
+ doc =
+ "Declares metadata that applies to every rule in the package. It must be called at "
+ + "most once within a package (BUILD file). If called, it should be the first call "
+ + "in the BUILD file, right after the load()
statements.",
+ extraKeywords =
+ @Param(
+ name = "kwargs",
+ doc =
+ "See the package()
"
+ + "function in the Build Encyclopedia for applicable arguments."),
useStarlarkThread = true)
public Object packageCallable(Map kwargs, StarlarkThread thread)
throws EvalException {
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RepoFileGlobals.java b/src/main/java/com/google/devtools/build/lib/packages/RepoFileGlobals.java
index 07631e1763e459..8fb5eb5f85bacf 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/RepoFileGlobals.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/RepoFileGlobals.java
@@ -14,6 +14,8 @@
package com.google.devtools.build.lib.packages;
+import com.google.devtools.build.docgen.annot.GlobalMethods;
+import com.google.devtools.build.docgen.annot.GlobalMethods.Environment;
import java.util.Map;
import net.starlark.java.annot.Param;
import net.starlark.java.annot.ParamType;
@@ -24,6 +26,7 @@
import net.starlark.java.eval.StarlarkThread;
/** Definition of the {@code repo()} function used in REPO.bazel files. */
+@GlobalMethods(environment = Environment.REPO)
public final class RepoFileGlobals {
private RepoFileGlobals() {}
@@ -59,8 +62,17 @@ public void ignoreDirectories(Iterable> dirsUnchecked, StarlarkThread thread)
@StarlarkMethod(
name = "repo",
- documented = false, // documented separately
- extraKeywords = @Param(name = "kwargs"),
+ doc =
+ "Declares metadata that applies to every rule in the repository. It must be called at "
+ + "most once per REPO.bazel file. If called, it must be the first call in the "
+ + "REPO.bazel file.",
+ extraKeywords =
+ @Param(
+ name = "kwargs",
+ doc =
+ "The repo()
function accepts exactly the same arguments as the "
+ + "package()
function "
+ + "in BUILD files."),
useStarlarkThread = true)
public void repoCallable(Map kwargs, StarlarkThread thread) throws EvalException {
RepoThreadContext context = RepoThreadContext.fromOrFail(thread, "repo()");