bazelbuild / bazelbuild/bazel-skylib

bzl_library does not validate the inputs are correct

Open
#568 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
444
Forks
202
PR merge metrics
No merged PRs in 30d

Description

As a common example, many rulesets do not declare all the `deps` of their .bzl files.

Ever since Bazel 7 added the native https://bazel.build/reference/be/general#starlark_doc_extract rule, it makes sense for that to be the behavior of a `bzl_library` target.

This is symmetric with `proto_library` which produces a descriptor as an output.

There's a design smell where a macro has to do this:
https://github.com/bazelbuild/stardoc/blob/master/stardoc/stardoc.bzl#L112-L119
which means that alternative tools that want to read the docs don't know which target to refer to in order to gather that module-as-proto data.

Ideally what should happen:
- starlark_doc_extract in Bazel should have a java_binary that runs the tool outside of that native rule implementation (starlarkification)
- we can attach a validation action to bzl_library targets that executes that tool
- as a bonus, we can also add an OutputGroup to provide that proto data as output

Contributor guide

Open the contributing guide

Research direction

Start with the bzl_library behavior described in the issue and Bazel's native starlark_doc_extract rule. Read the referenced stardoc/stardoc.bzl lines 112-119 to understand the current macro workaround. The work is complete when bzl_library validation and the proposed proto-data output behavior are defined and implemented consistently.

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
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.