aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/MethodLibrary.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/SkylarkNestedSet.java10
2 files changed, 10 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/MethodLibrary.java b/src/main/java/com/google/devtools/build/lib/packages/MethodLibrary.java
index 7b00ea0d1e..23e54a1507 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/MethodLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/MethodLibrary.java
@@ -709,10 +709,10 @@ public class MethodLibrary {
};
@SkylarkBuiltin(name = "set", returnType = SkylarkNestedSet.class,
- doc = "Creates a set from the <code>items</code>. The set supports nesting other sets of the"
- + " same element type in it. For this reason sets are also referred to as <i>nested sets</i>"
- + " (all Skylark sets are nested sets). A desired iteration order can also be specified.<br>"
- + " Examples:<br><pre class=\"language-python\">set([1, set([2, 3]), 2])\n"
+ doc = "Creates a <a href=\"#modules.set\">set</a> from the <code>items</code>."
+ + " The set supports nesting other sets of the same element"
+ + " type in it. A desired iteration order can also be specified.<br>"
+ + " Examples:<br><pre class=\"language-python\">set([\"a\", \"b\"])\n"
+ "set([1, 2, 3], order=\"compile\")</pre>",
optionalParams = {
@Param(name = "items", type = SkylarkList.class,
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkNestedSet.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkNestedSet.java
index 39441b004f..cd2f0ab5c3 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkNestedSet.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkNestedSet.java
@@ -35,15 +35,17 @@ import javax.annotation.Nullable;
*/
@SkylarkModule(name = "set",
doc = "A language built-in type that supports (nested) sets. "
- + "Sets can be created using the global <code>set</code> function, and they "
- + "support the <code>+</code> operator to extend the set with more elements or to nest "
- + "other sets inside of it. Examples:<br>"
+ + "Sets can be created using the <a href=\"#modules._top_level.set\">set</a> function, and "
+ + "they support the <code>+</code> operator to extend the set with more elements or "
+ + "to nest other sets inside of it. Examples:<br>"
+ "<pre class=language-python>s = set([1, 2])\n"
+ "s += [3] # s == {1, 2, 3}\n"
+ "s += set([4, 5]) # s == {1, 2, 3, {4, 5}}</pre>"
+ "Note that in these examples <code>{..}</code> is not a valid literal to create sets. "
+ "Sets have a fixed generic type, so <code>set([1]) + [\"a\"]</code> or "
- + "<code>set([1]) + set([\"a\"])</code> results in an error.")
+ + "<code>set([1]) + set([\"a\"])</code> results in an error.<br>"
+ + "When aggregating data from providers, nested sets can take significantly less "
+ + "memory than other types as the subsets can be shared.")
@Immutable
public final class SkylarkNestedSet implements Iterable<Object> {