-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow setting a Skylark rule kind rather than using "magic" assigned identifier #5078
Comments
@laurentlb Can you take a look here? |
cc @c-parsons |
The kind is a property of the rule, not the target, so it would be a parameter to This should be straightforward to implement (modulo a little refactoring) -- we'd basically immediately "export" the rule with the given kind/name, instead of waiting for the post-assign hook. But the real question is whether it's worth the conceptual complexity to add this feature, and whether there's a demand for it. |
Yes, by "attribute" I meant parameter to the This confusion over the fairly common source of breakage when rules are refactored (there are a fair few number of bugs and corresponding I suspect making the rule kind explicit would help reduce the conceptual complexity a bit, rather than adding to it. In particular, it provides a very accessible location from which to hang documentation noting that "kind" is used by bazel query and similar facilities along with noting that if omitted it takes the default from the variable assignment. Right now, this fact is kind of buried in an offhand sentence in https://docs.bazel.build/versions/master/skylark/rules.html#rule-creation rather than being visible in the reference documentation for the |
See also dup #8640. |
Prioritized because this was identified as useful for migration of native rules to Starlark. |
Any update's here? It would be great to at least have the caveats around rule kind more loudly documented :-) |
Description of the problem / feature request:
Currently, when defining a new rule in Skylark the "kind" is essentially part of the public API. It is user-visible through bazel query and BEP but is taken exclusively from the local identifier on the left hand side of the assignment from the
rule()
function. This (and some documentation examples) easily leads to the mistaken assumption that the rule kind is an internal implementation detail.Ideally, there would either be another way of setting the rule kind, possibly through an attribute. Barring that the documentation should be much more explicit about the visibility of this name. For example:
_not_really_internal = rule( ... )
my_lang_library = _not_really_internal # Rule kind is "_not_really_internal" which is public.
def my_lang_binary(...): # Also Rule kind "_not_really_internal"
_not_really_internal(..., kind="binary")
Developers (reasonably) assume that they have control over the exposed API based on the "public" identifiers, but this assumption is false when applied to the return value of
rule()
and this is non-obvious.Feature requests: what underlying problem are you trying to solve with this feature?
Make the visibility of the rule name more explicit and obvious to developers and maintainers.
The text was updated successfully, but these errors were encountered: