Skip to content

Commit bd498eb

Browse files
dwscopybara-github
authored andcommitted
avoid assuming default provider fields on cquery target in the docs
Since we no longer document the struct-based default provider fields for Target, it seems reasonable to stop using them in the docs for cquery. Closes #26293. PiperOrigin-RevId: 772032781 Change-Id: I6a14edc8f7fe5e6dce6fa28f6aa5eb1ac75dd6f6
1 parent ac15666 commit bd498eb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

site/en/query/cquery.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,15 @@ Print a space-separated list of the base names of all files produced by `//foo`:
422422

423423
<pre>
424424
bazel cquery //foo --output=starlark \
425-
--starlark:expr="' '.join([f.basename for f in target.files.to_list()])"
425+
--starlark:expr="' '.join([f.basename for f in providers(target)['DefaultInfo'].files.to_list()])"
426426
</pre>
427427

428428
Print a space-separated list of the paths of all files produced by **rule** targets in
429429
`//bar` and its subpackages:
430430

431431
<pre>
432432
bazel cquery 'kind(rule, //bar/...)' --output=starlark \
433-
--starlark:expr="' '.join([f.path for f in target.files.to_list()])"
433+
--starlark:expr="' '.join([f.path for f in providers(target)['DefaultInfo'].files.to_list()])"
434434
</pre>
435435

436436
Print a list of the mnemonics of all actions registered by `//foo`.
@@ -461,7 +461,7 @@ Starlark functions defined in a file.
461461
$ cat example.cquery
462462

463463
def has_one_output(target):
464-
return len(target.files.to_list()) == 1
464+
return len(providers(target)["DefaultInfo"].files.to_list()) == 1
465465

466466
def format(target):
467467
if has_one_output(target):

0 commit comments

Comments
 (0)