diff options
Diffstat (limited to 'site')
-rw-r--r-- | site/docs/skylark/cookbook.md | 2 | ||||
-rw-r--r-- | site/docs/skylark/rules.md | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/site/docs/skylark/cookbook.md b/site/docs/skylark/cookbook.md index d6ccb7d4ab..1ab6bb51cc 100644 --- a/site/docs/skylark/cookbook.md +++ b/site/docs/skylark/cookbook.md @@ -91,7 +91,7 @@ Example of a rule that shows how to declare attributes and access them. ```python def _impl(ctx): # You may use print for debugging. - print("The number is %s" % ctx.attr.number) + print("Rule name = %s, package = %s" % (ctx.label.name, ctx.label.package)) # This prints the labels of the deps attribute. print("There are %d deps" % len(ctx.attr.deps)) diff --git a/site/docs/skylark/rules.md b/site/docs/skylark/rules.md index 47abb015a0..8339735842 100644 --- a/site/docs/skylark/rules.md +++ b/site/docs/skylark/rules.md @@ -29,6 +29,12 @@ If an attribute starts with `_`, it is private and users cannot set it. It is useful in particular for label attributes (your rule will have an implicit dependency on this label). +The following attributes are implicitely added to every rule: `name`, +`visibility`, `deprecation`, `tags`, `testonly`, `features`. + +To access an attribute, use `ctx.attr.<attribute_name>`. The name and the +package of a rule are available with `ctx.label.name` and `ctx.label.package`. + [See example.](cookbook.md#attr) The rule implementation function |