Skip to content

Commit

Permalink
Clarify types of ctx.attr.<attr_name> objects.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 179053724
  • Loading branch information
vladmos authored and katre committed Dec 14, 2017
1 parent ab97d78 commit 81a4948
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions site/docs/skylark/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ following attributes: `args`, `flaky`, `local`, `shard_count`, `size`,

Labels listed in `attr` will be inputs to the rule.

To access an attribute in a rule's implementation, use
`ctx.attr.<attribute_name>`. The name and the package of a rule are available
To access an attribute in a rule's implementation, use `ctx.attr.<attribute_name>`.
This field will have the type given in the rule's `attrs` dictionary corresponding to
`<attribute_name>`.

The name and the package of a rule are available
with `ctx.label.name` and `ctx.label.package`.

See [an example](cookbook.md#attr) of using `attr` in a rule.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ public final class SkylarkRuleContext implements SkylarkValue {
+ "<pre class=language-python>list(ctx.attr.&lt;ATTR&gt;.files)[0]</pre>";
public static final String ATTR_DOC =
"A struct to access the values of the attributes. The values are provided by "
+ "the user (if not, a default value is used).";
+ "the user (if not, a default value is used). The attributes of the struct and the "
+ "types of their values correspond to the keys and values of the <code>attrs</code> "
+ "dict provided to the <code>rule</code> function.";
public static final String SPLIT_ATTR_DOC =
"A struct to access the values of attributes with split configurations. If the attribute is "
+ "a label list, the value of split_attr is a dict of the keys of the split (as strings) "
Expand Down

0 comments on commit 81a4948

Please sign in to comment.