improve documentation for common ctx shortcuts
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the problem / feature request:
ctx has a lot of little magical features such as `ctx.runfiles(collect_default=True)` or `ctx.files.`. While these features are nice for convenience, the docs on them are rather thin - they often say what they do, without spelling out what they are actually short for. This can make it hard to understand:
- what the performance of these things is like - e.g. ctx.files expands depsets, but you can't tell that from it's docs (#6496)
- what to replace these things with when they stop being the right idiom to use; e.g. `ctx.runfiles(collect_default=True)` can be wrong thing to use for rules that want to compile files in their `srcs`, as it'll include the inputs in the runfiles which may not be desired. (example issue: transpiling .js to .js, if you include srcs in runfiles then you end up with the srcs and compiled outputs generating conflicting symlinks)
The docs should be updated to include " is equivalent to ". off the top of my head the following could use this:
- ctx.file
- ctx.files
- ctx.runfiles(collect_default=True) & ctx.runfiles(collect_data= True)
### Feature requests: what underlying problem are you trying to solve with this feature?
Improve documentation of ctx members (https://docs.bazel.build/versions/master/skylark/lib/ctx.html)
Contributor guide
Research direction
Start with the ctx documentation at https://docs.bazel.build/versions/master/skylark/lib/ctx.html and review the entries for ctx.file, ctx.files, and ctx.runfiles(collect_default=True) or ctx.runfiles(collect_data=True). Document what each shortcut is equivalent to, including relevant behavior such as depset expansion and runfiles inclusion, and verify that the resulting explanations address when a more verbose form is preferable.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100