Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reference docs for BUILD file symbols #216

Merged
merged 7 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions docs/reference/build-file-symbols/PANTS_VERSION.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: PANTS_VERSION
description: |
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`PANTS_VERSION`} signature={``}>

</BuildFileSymbol>
15 changes: 15 additions & 0 deletions docs/reference/build-file-symbols/__defaults__.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: __defaults__
description: |
Provide default field values.
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`__defaults__`} signature={`(*args: 'SetDefaultsT', ignore_unknown_fields: 'bool' = False, ignore_unknown_targets: 'bool' = False, **kwargs) -> 'None'`}>

Provide default field values.

Learn more https://www.pantsbuild.org/2.22/docs/using-pants/key-concepts/targets-and-build-files#field-default-values

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/__dependencies_rules__.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: __dependencies_rules__
description: |
Declare dependencies rules.
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`__dependencies_rules__`} signature={`(*args, **kwargs) -> 'None'`}>

Declare dependencies rules.

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/__dependents_rules__.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: __dependents_rules__
description: |
Declare dependents rules.
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`__dependents_rules__`} signature={`(*args, **kwargs) -> 'None'`}>

Declare dependents rules.

</BuildFileSymbol>
9 changes: 9 additions & 0 deletions docs/reference/build-file-symbols/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"label": "BUILD file symbols",
"link": {
"type": "generated-index",
"slug": "/reference/build-file-symbols",
"title": "BUILD file symbols"
},
"position": 5
}
17 changes: 17 additions & 0 deletions docs/reference/build-file-symbols/build_file_dir.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: build_file_dir
description: |
Returns the path to the directory of the current BUILD file.
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`build_file_dir`} signature={`() -> 'PurePath'`}>

Returns the path to the directory of the current BUILD file.

The returned value is an instance of `PurePath` to make path name manipulations easy.

See: https://docs.python.org/3/library/pathlib.html#pathlib.PurePath

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/duplicate_rule.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: duplicate_rule
description: |
DeployJarDuplicateRule(pattern: 'str', action: 'str')
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`duplicate_rule`} signature={`(pattern: 'str', action: 'str') -> None`}>

DeployJarDuplicateRule(pattern: &#x27;str&#x27;, action: &#x27;str&#x27;)

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/env.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: env
description: |
Reference environment variable.
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`env`} signature={`(name: 'str', *args, **kwargs) -> 'Any'`}>

Reference environment variable.

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/http_source.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: http_source
description: |
http_source(url: 'str', *, len: 'int', sha256: 'str', filename: 'str' = '')
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`http_source`} signature={`(url: 'str', *, len: 'int', sha256: 'str', filename: 'str' = '')`}>

http_source(url: &#x27;str&#x27;, \*, len: &#x27;int&#x27;, sha256: &#x27;str&#x27;, filename: &#x27;str&#x27; = &#x27;&#x27;)

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/jvm_exclude.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: jvm_exclude
description: |
JvmArtifactExclusion(group: 'str', artifact: 'str | None' = None)
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`jvm_exclude`} signature={`(group: 'str', artifact: 'str | None' = None) -> None`}>

JvmArtifactExclusion(group: &#x27;str&#x27;, artifact: &#x27;str | None&#x27; = None)

</BuildFileSymbol>
16 changes: 16 additions & 0 deletions docs/reference/build-file-symbols/node_build_script.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: node_build_script
description: |
A build script, mapped from the `scripts` section of a package.json file.
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`node_build_script`} signature={`(entry_point: 'str', output_directories: 'Iterable[str]' = (), output_files: 'Iterable[str]' = (), extra_caches: 'Iterable[str]' = (), extra_env_vars: 'Iterable[str]' = ()) -> 'NodeBuildScript'`}>

A build script, mapped from the `scripts` section of a package.json file.

Either the `output_directories` or the `output_files` argument has to be set to capture the
output artifacts of the build.

</BuildFileSymbol>
16 changes: 16 additions & 0 deletions docs/reference/build-file-symbols/node_test_script.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: node_test_script
description: |
The test script for this package, mapped from the `scripts` section of a package.json
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`node_test_script`} signature={`(entry_point: 'str' = 'test', report_args: 'Iterable[str]' = (), report_output_files: 'Iterable[str]' = (), report_output_directories: 'Iterable[str]' = (), coverage_args: 'Iterable[str]' = (), coverage_output_files: 'Iterable[str]' = (), coverage_output_directories: 'Iterable[str]' = (), coverage_entry_point: 'str | None' = None) -> 'NodeTestScript'`}>

The test script for this package, mapped from the `scripts` section of a package.json
file. The pointed to script should accept a variadic number of ([ARG]...) path arguments.

This entry point is the &#x22;test&#x22; script, by default.

</BuildFileSymbol>
16 changes: 16 additions & 0 deletions docs/reference/build-file-symbols/parametrize.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: parametrize
description: |
A builtin function/dataclass that can be used to parametrize Targets.
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`parametrize`} signature={`(*args: 'str', **kwargs: 'Any') -> 'None'`}>

A builtin function/dataclass that can be used to parametrize Targets.

Parametrization is applied between TargetAdaptor construction and Target instantiation, which
means that individual Field instances need not be aware of it.

</BuildFileSymbol>
52 changes: 52 additions & 0 deletions docs/reference/build-file-symbols/per_platform.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: per_platform
description: |
An object containing differing homogeneous platform-dependent values.
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`per_platform`} signature={`(linux_arm64: '_T | None' = None, linux_x86_64: '_T | None' = None, macos_arm64: '_T | None' = None, macos_x86_64: '_T | None' = None) -> None`}>

An object containing differing homogeneous platform-dependent values.

The values should be evaluated for the execution environment, and not the host environment
(I.e. it should be evaluated in a `rule` which requests `Platform`).

Expected usage is roughly:

```python
class MyFieldType(...):
value = str | per_platform[str]

@classmethod
def compute_value( # type: ignore[override]
cls,
raw_value: Optional[Union[str, per_platform[str]]],
address: Address,
) -> Optional[Union[str, per_platform[str]]]:
if isinstance(raw_value, per_platform):
# NOTE: Ensure the values are homogeneous
raw_value.check_types(str)

return raw_value

...

@rule
async def my_rule(..., platform: Platform) -> ...:
field_value = target[MyFieldType].value

if isinstance(field_value, per_platform):
field_value = field_value.get_value_for_platform(platform)

...
```

NOTE: Support for this object should be heavily weighed, as it would be inappropriate to use in
certain contexts (such as the `source` field in a `foo_source` target, where the intent is to
support differing source files based on platform. The result would be that dependency inference
(and therefore the dependencies field) wouldn&#x27;t be knowable on the host, which is not something
the engine can support yet).

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/python_artifact.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: python_artifact
description: |
Represents a Python setup.py-based project.
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`python_artifact`} signature={`(**kwargs) -> None`}>

Represents a Python setup.py-based project.

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/scala_exclude.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: scala_exclude
description: |
ScalaArtifactExclusion(group: 'str', artifact: 'str | None' = None, crossversion: 'str' = 'binary')
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`scala_exclude`} signature={`(group: 'str', artifact: 'str | None' = None, crossversion: 'str' = 'binary') -> None`}>

ScalaArtifactExclusion(group: &#x27;str&#x27;, artifact: &#x27;str | None&#x27; = None, crossversion: &#x27;str&#x27; = &#x27;binary&#x27;)

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/setup_py.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: setup_py
description: |
Represents a Python setup.py-based project.
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`setup_py`} signature={`(**kwargs) -> None`}>

Represents a Python setup.py-based project.

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/shading_keep.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: shading_keep
description: |
JvmShadingKeepRule(pattern: 'str')
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`shading_keep`} signature={`(pattern: 'str') -> None`}>

JvmShadingKeepRule(pattern: &#x27;str&#x27;)

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/shading_relocate.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: shading_relocate
description: |
JvmShadingRelocateRule(package: 'str', into: 'str | None' = None)
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`shading_relocate`} signature={`(package: 'str', into: 'str | None' = None) -> None`}>

JvmShadingRelocateRule(package: &#x27;str&#x27;, into: &#x27;str | None&#x27; = None)

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/shading_rename.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: shading_rename
description: |
JvmShadingRenameRule(pattern: 'str', replacement: 'str')
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`shading_rename`} signature={`(pattern: 'str', replacement: 'str') -> None`}>

JvmShadingRenameRule(pattern: &#x27;str&#x27;, replacement: &#x27;str&#x27;)

</BuildFileSymbol>
13 changes: 13 additions & 0 deletions docs/reference/build-file-symbols/shading_zap.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: shading_zap
description: |
JvmShadingZapRule(pattern: 'str')
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`shading_zap`} signature={`(pattern: 'str') -> None`}>

JvmShadingZapRule(pattern: &#x27;str&#x27;)

</BuildFileSymbol>
22 changes: 22 additions & 0 deletions docs/reference/build-file-symbols/stevedore_namespace.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: stevedore_namespace
description: |
str(object='') -> str
---

import BuildFileSymbol from "@site/src/components/reference/BuildFileSymbol";

<BuildFileSymbol name={`stevedore_namespace`} signature={``}>

str(object=&#x27;&#x27;) -&#x3E; str
str(bytes_or_buffer[, encoding[, errors]]) -&#x3E; str

Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.**str**() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to &#x27;strict&#x27;.

</BuildFileSymbol>
1 change: 1 addition & 0 deletions docs/reference/global-options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Global options
description: |
Options to control the overall behavior of Pants.
sidebar_position: 1
---

import Option from "@site/src/components/reference/Option";
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/goals/_category_.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"type": "generated-index",
"slug": "/reference/goals",
"title": "Goals"
}
},
"position": 2
}
3 changes: 2 additions & 1 deletion docs/reference/subsystems/_category_.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"type": "generated-index",
"slug": "/reference/subsystems",
"title": "Subsystems"
}
},
"position": 3
}
3 changes: 2 additions & 1 deletion docs/reference/targets/_category_.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"type": "generated-index",
"slug": "/reference/targets",
"title": "Targets"
}
},
"position": 4
}
Loading
Loading