aboutsummaryrefslogtreecommitdiffhomepage
path: root/site
diff options
context:
space:
mode:
authorGravatar Laurent Le Brun <laurentlb@google.com>2015-05-06 17:18:17 +0000
committerGravatar Lukacs Berki <lberki@google.com>2015-05-07 14:04:16 +0000
commit6d450dc530ef7d9348dfd3830857a67014b7392f (patch)
tree7cc1b1aa94c054502b5b753a6f49e0d2ef020820 /site
parenta71d47046c4e9e95bfc69c33c9071d5f6ee536e5 (diff)
Skylark documentation: Mention implicit attributes.
-- MOS_MIGRATED_REVID=92937527
Diffstat (limited to 'site')
-rw-r--r--site/docs/skylark/cookbook.md2
-rw-r--r--site/docs/skylark/rules.md6
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