Skip to content

Commit

Permalink
Refine run_shell_command docs (pantsbuild#19413)
Browse files Browse the repository at this point in the history
This fixes pantsbuild#19347 by excluding references to the not-used
`output_dependencies` field in the documentation of the various
dependencies fields of `run_shell_command`, as well as making some minor
improvements to the docs of `adhoc_tool` and `shell_command`.
  • Loading branch information
huonw authored Jul 6, 2023
1 parent 791b6e0 commit 0551d86
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/python/pants/backend/adhoc/target_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ class AdhocToolOutputDependenciesField(AdhocToolDependenciesField):
alias: ClassVar[str] = "output_dependencies"

help = help_text(
lambda: """
lambda: f"""
Any dependencies that need to be present (as transitive dependencies) whenever the outputs
of this target are consumed (including as dependencies).
See also `{AdhocToolExecutionDependenciesField.alias}` and
`{AdhocToolRunnableDependenciesField.alias}`.
"""
)

Expand All @@ -106,6 +109,9 @@ class AdhocToolExecutionDependenciesField(SpecialCasedDependencies):
If this field is specified, dependencies from `{AdhocToolOutputDependenciesField.alias}`
will not be added to the execution sandbox.
See also `{AdhocToolOutputDependenciesField.alias}` and
`{AdhocToolRunnableDependenciesField.alias}`.
"""
)

Expand All @@ -117,7 +123,7 @@ class AdhocToolRunnableDependenciesField(SpecialCasedDependencies):

help = help_text(
lambda: f"""
The execution dependencies for this command.
The runnable dependencies for this command.
Dependencies specified here are those required to exist on the `PATH` to make the command
complete successfully (interpreters specified in a `#!` command, etc). Note that these
Expand Down
32 changes: 30 additions & 2 deletions src/python/pants/backend/shell/target_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,38 @@ class ShellCommandExecutionDependenciesField(AdhocToolExecutionDependenciesField
pass


class RunShellCommandExecutionDependenciesField(ShellCommandExecutionDependenciesField):
help = help_text(
lambda: f"""
The execution dependencies for this command.
Dependencies specified here are those required to make the command complete successfully
(e.g. file inputs, packages compiled from other targets, etc), but NOT required to make
the outputs of the command useful.
See also `{RunShellCommandRunnableDependenciesField.alias}`.
"""
)


class ShellCommandRunnableDependenciesField(AdhocToolRunnableDependenciesField):
pass


class RunShellCommandRunnableDependenciesField(ShellCommandRunnableDependenciesField):
help = help_text(
lambda: f"""
The runnable dependencies for this command.
Dependencies specified here are those required to exist on the `PATH` to make the command
complete successfully (interpreters specified in a `#!` command, etc). Note that these
dependencies will be made available on the `PATH` with the name of the target.
See also `{RunShellCommandExecutionDependenciesField.alias}`.
"""
)


class ShellCommandSourcesField(MultipleSourcesField):
# We solely register this field for codegen to work.
alias = "_sources"
Expand Down Expand Up @@ -400,8 +428,8 @@ class ShellCommandRunTarget(Target):
alias = "run_shell_command"
core_fields = (
*COMMON_TARGET_FIELDS,
ShellCommandExecutionDependenciesField,
ShellCommandRunnableDependenciesField,
RunShellCommandExecutionDependenciesField,
RunShellCommandRunnableDependenciesField,
ShellCommandCommandField,
RunShellCommandWorkdirField,
)
Expand Down

0 comments on commit 0551d86

Please sign in to comment.