Skip to content

bzl_library does not validate the inputs are correct #568

@alexeagle

Description

@alexeagle

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions