Allow setting a Skylark rule kind rather than using "magic" assigned identifier
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 72
Description
### 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.
Contributor guide
Research direction
Start by reviewing the Skylark rule() entry point and the documentation examples described in the issue. Done means either rule kinds can be explicitly set independently of the local identifier, or the documentation makes their public visibility and behavior unambiguous.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100