Add default_repo_name attribute to starlark_doc_extract#19002
Add default_repo_name attribute to starlark_doc_extract#19002fmeum wants to merge 1 commit intobazelbuild:masterfrom
default_repo_name attribute to starlark_doc_extract#19002Conversation
The specified repository name is used to make repo-relative labels repo-absolute. This applies to default values that are labels as well as the locations of `.bzl` files.
There was a problem hiding this comment.
Thanks you very much for this PR!
But I see a problem in the test output: attribute default label values and origin key labels are rendered with different canonicalizations even though they refer to targets in the same repo. Let me see if there is a simple fix...
|
@tetromino Are you referring to |
I was referring to the fact that we need the same label formatting in all contexts - not just attribute defaults but also e.g. moduleInfo.file and originKey.file |
|
After thinking for a bit and talking to @brandjon, I would prefer to fix this by a different approach in #19009:
|
For labels in the main repo, users may wish one of 2 behaviors: * render labels in display form (without the repo component) - when documenting rules intended for other users of the same repo. (This is the expected use case in an organization's internal monorepo). * render labels with the @repo component included - when documenting rules intended for use from other repos. (This is the expected use case for public rule sets.) Formerly, starlark_doc_extract only supported case 1. We add support for case 2 via the new `render_main_repo_name` attribute. Supporting it means we can't simply use Label.getDisplayForm() any more - we need to post-process the string via a new label renderer. It also turned out that Label.getDisplayForm() fails an assert when using a repo map owned by the non-main repo. This means we always have to use the main repo's repo map for rendering, which in turn means that starlark_doc_extract's label stringification is different depending on whether the starlark_doc_extract target lives in the main repo or a dependency. Arguably, this is the correct thing to do: the owner of the main repo presumably wants to generate documentation with consistent repo names regardless of whether the target lives in the main repo or in a dep. Inspired by @fmeum's work in #19002 Closes #19009. PiperOrigin-RevId: 551594134 Change-Id: Iec4b9479ca9b27babd0435883649802e5cde8aab
The specified repository name is used to make repo-relative labels repo-absolute. This applies to default values that are labels as well as the locations of
.bzlfiles.