bazelbuild / bazelbuild/bazel

Allow setting a Skylark rule kind rather than using "magic" assigned identifier

Open
#5,078 7 comments 0 reactions 0 assignees View on GitHub
P2 team-Documentation team-Rules-API type: documentation (cleanup) type: feature request
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.