Use native starlark_doc_extract rule for doc extraction if it is available#166
Use native starlark_doc_extract rule for doc extraction if it is available#166
Conversation
Warning: requires Bazel at HEAD and enabling the --experimental_enable_starlark_doc_extract flag.
…rresponding bzl_library deps
These will be used only in starlark_doc_extract mode.
| * Formats the label of the .bzl module being documented for use in documentation, falling back to | ||
| * "..." if the label is not available. | ||
| */ | ||
| // TODO(arostovtsev): we ought to add an option to semi-canonicalize .bzl file labels in the local |
There was a problem hiding this comment.
I can look into fixing this as a follow-up based on native.module_name.
There was a problem hiding this comment.
Unfortunately, native.module_name can only be used in the loading phase :/
There was a problem hiding this comment.
My idea was to add a module_name parameter to the stardoc macro that uses native.module_name as the default.
There was a problem hiding this comment.
On further reflection, I think the right place to fix this should be in starlark_doc_extract - we want to be able to optionally provide the local repo name for all labels (including e.g. label attribute defaults), in the proto output as well as in markdown.
The starlark macro can then provide the local repo map (obtained from native.module_name or a manual override for cases where the recommended repo name for a module's users is different from the module name) to the starlark_doc_extract target.
There was a problem hiding this comment.
When you say "local repo name", which name are you referring to exactly? The apparent name used by the root module?
What would comprise the "local repo map" that you would want to have passed into the rule?
There was a problem hiding this comment.
By "local repo", I mean the repo of the stardoc (and starlark_doc_extract) target.
Currently, starlark_doc_extract treats that repo as if it were the main repo for the purpose of stringifying labels in proto output. This behavior made sense to me at the time when I implemented it because it meant starlark_doc_extract's output is the same regardless of whether doc targets are being built in their own repo or by a user of the repo, and thus made golden tests sane/predictable.
In retrospect, the correct behavior should have been to allow the name of the local repo to be remapped to a custom one when stringifying labels.
There was a problem hiding this comment.
I submitted bazelbuild/bazel#19002, please let me know whether this is what you had in mind.
…D) in update-stardoc-tests.sh
To ensure we are testing starlark_doc_extract
starlark_doc_extractnative rule for doc extraction instead of the legacy pre-built extraction jar. This behavior can be disabled by passinguse_starlark_doc_extract = Falseto thestardocmacro.starlark_doc_extract).but alas, we don't have a good way to get the name of the local repo from Starlark when bzlmod is enabled.
starlark_doc_extract-enabled) and legacy flavors.Fixes #69
Fixes #76
Fixes #81
Fixes #123