Added more details about the use of configuration fragments in Skylark to the documentation. -- MOS_MIGRATED_REVID=101357875
diff --git a/site/docs/skylark/rules.md b/site/docs/skylark/rules.md index d21ddb1..f450fd0 100644 --- a/site/docs/skylark/rules.md +++ b/site/docs/skylark/rules.md
@@ -219,6 +219,27 @@ `DATA_CFG` is present for legacy reasons and should be used for the `data` attributes. +<a name="fragments"></a> +Configuration Fragments +-------------- + +Rules may access configuration fragments such as `cpp`, `java` and `jvm`. +However, all required fragments have to be declared in order to avoid access +errors: + +```python +def impl(ctx): + # Using ctx.fragments.cpp would lead to an error since it was not declared. + x = ctx.fragments.java + ... + +my_rule = rule( + implementation=impl, + fragments = ["java"], + ... +) +``` + Providers ---------