Skip to content
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

Undocumented attributes in all Starlark rules: expect_failure, transitive_configs, package_metadata #24948

Open
tetromino opened this issue Jan 16, 2025 · 3 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Documentation Documentation improvements that cannot be directly linked to other team labels team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: bug type: documentation (cleanup)

Comments

@tetromino
Copy link
Contributor

tetromino commented Jan 16, 2025

The following attributes exist in all Starlark rules, but are not documented at https://bazel.build/reference/be/common-definitions#common-attributes despite not being marked as undocumented in the attribute's definition

  • expect_failure - appears to be a moribund feature. Virtually nobody (afaict) is using it. Mark the attribute as undocumented and deprecate via a flag?
    • Note that this is the expect_failure natively-defined rule attribute - not the expect_failure macro parameter defined by skylib's analysistest.make() which uses the allow_analysis_failures mechanism instead.
  • transitive_configs - appears to be a feature which was partially implemented but never got off the ground. A few things inside google are using it, but should they? Mark the attribute as undocumented and deprecate via flag?
  • package_metadata - new attribute used by rules_license somehow? Probably needs to be properly documented in the build encyclopedia.

I noticed these while working on Stardoc support for symbolic macros that inherit attributes from rules. My current thought is to filter out expect_failure and transitive_configs from the user-visible doc output, and leave package_metadata in the list but undocumented (since it's not clear to me what it does).

CC @aiuto @gregestren @comius

@tetromino tetromino added P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Documentation Documentation improvements that cannot be directly linked to other team labels team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: bug type: documentation (cleanup) labels Jan 16, 2025
@aiuto
Copy link
Contributor

aiuto commented Jan 16, 2025

package_metadata allows you to attach pretty much any target label to another as an informational bit an aspect can query. It is the replacement name for applicable_licenses. It is documented at the package level.
But neither ever seems to have be documented as a common attribute.
Looking at history for src/main/java/com/google/devtools/build/docgen/templates/attributes/common I don't find it.
That is the right spot for common attributes, right?

@tetromino
Copy link
Contributor Author

Looking at history for src/main/java/com/google/devtools/build/docgen/templates/attributes/common I don't find it. That is the right spot for common attributes, right?

Yes, that's the right place.

@aiuto
Copy link
Contributor

aiuto commented Jan 16, 2025

Thanks. I'll create a PR to add a minimal doc.
Cooincidentally, I just wrote a longish description of how we use package_metadata to protect against code leaking to certain places. I guess I should sanitize that and do a blog post. That would provide more material for the description. Or, at least a place to link to that has a big example.

copybara-service bot pushed a commit that referenced this issue Jan 16, 2025
#24948

RELNOTES: Add a definition of the pacakge_metadata attribute.
PiperOrigin-RevId: 716390643
Change-Id: I0f981a94c60611fe3805984c8395d46655a1d954
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Documentation Documentation improvements that cannot be directly linked to other team labels team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: bug type: documentation (cleanup)
Projects
None yet
Development

No branches or pull requests

2 participants