Skip to content

Latest commit

 

History

History
257 lines (159 loc) · 14.8 KB

rules_pkl_docs.md

File metadata and controls

257 lines (159 loc) · 14.8 KB

Public API re-exports

pkl_codegen_java_toolchain

load("@rules_pkl//pkl:defs.bzl", "pkl_codegen_java_toolchain")

pkl_codegen_java_toolchain(name, cli)

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
cli - Label optional "@rules_pkl//pkl:pkl_codegen_java_cli"

pkl_doc_toolchain

load("@rules_pkl//pkl:defs.bzl", "pkl_doc_toolchain")

pkl_doc_toolchain(name, cli)

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
cli - Label optional "@rules_pkl//pkl:pkl_doc_cli"

pkl_eval

load("@rules_pkl//pkl:defs.bzl", "pkl_eval")

pkl_eval(name, deps, srcs, data, outs, entrypoints, expression, format, multiple_outputs,
         properties)

Evaluate Pkl module(s).

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Other targets to include in the pkl module path when building this configuration. Must be pkl_* targets. List of labels optional []
srcs The Pkl source files to be evaluated. List of labels optional []
data Files to make available in the filesystem when building this configuration. These can be accessed by relative path. List of labels optional []
outs Names of the output files to generate. Defaults to <rule name>.<format>. If the format attribute is unset, use <rule name>.pcf. Expects a single file if multiple_outputs is not set to True. List of labels optional []
entrypoints The pkl file to use as an entry point (needs to be part of the srcs). Typically a single file. List of labels optional []
expression A pkl expression to evaluate within the module. Note that the format attribute does not affect how this renders. String optional ""
format The format of the generated file to pass when calling pkl. See https://pkl-lang.org/main/current/pkl-cli/index.html#command-eval. String optional ""
multiple_outputs Whether to expect to render multiple file outputs. If outs is specified then individual generated files will be exposed. Otherwise, a single directory, with the name of the target, containing all generated files will be exposed. (see https://pkl-lang.org/main/current/pkl-cli/index.html#command-eval). Boolean optional False
properties Dictionary of name value pairs used to pass in Pkl external properties. See the Pkl docs: https://pkl-lang.org/main/current/pkl-cli/index.html#command-eval Dictionary: String -> String optional {}

pkl_library

load("@rules_pkl//pkl:defs.bzl", "pkl_library")

pkl_library(name, deps, srcs, data)

Collect Pkl sources together so they can be used by other rules_pkl rules.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Other targets to include in the pkl module path when building this library. Must be pkl_* targets. List of labels optional []
srcs The Pkl source files to include in this library. List of labels required
data Files to make available in the filesystem when building this library target. These can be accessed by relative path. List of labels optional []

pkl_package

load("@rules_pkl//pkl:defs.bzl", "pkl_package")

pkl_package(name, srcs, extra_flags, project, strip_prefix)

Prepares a Pkl project to be published as a package as per the pkl project package command, using Bazel. You should have at most one pkl_package rule per pkl_project repo rule.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
srcs - List of labels optional []
extra_flags - List of strings optional []
project - Label required
strip_prefix Strip a directory prefix from the srcs. String optional ""

pkl_test

load("@rules_pkl//pkl:defs.bzl", "pkl_test")

pkl_test(name, deps, srcs, data, outs, entrypoints, expression, format, multiple_outputs,
         properties)

Create a Pkl test that can be run with Bazel.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Other targets to include in the pkl module path when building this configuration. Must be pkl_* targets. List of labels optional []
srcs The Pkl source files to be evaluated. List of labels optional []
data Files to make available in the filesystem when building this configuration. These can be accessed by relative path. List of labels optional []
outs Names of the output files to generate. Defaults to <rule name>.<format>. If the format attribute is unset, use <rule name>.pcf. Expects a single file if multiple_outputs is not set to True. List of labels optional []
entrypoints The pkl file to use as an entry point (needs to be part of the srcs). Typically a single file. List of labels optional []
expression A pkl expression to evaluate within the module. Note that the format attribute does not affect how this renders. String optional ""
format The format of the generated file to pass when calling pkl. See https://pkl-lang.org/main/current/pkl-cli/index.html#command-eval. String optional ""
multiple_outputs Whether to expect to render multiple file outputs. If outs is specified then individual generated files will be exposed. Otherwise, a single directory, with the name of the target, containing all generated files will be exposed. (see https://pkl-lang.org/main/current/pkl-cli/index.html#command-eval). Boolean optional False
properties Dictionary of name value pairs used to pass in Pkl external properties. See the Pkl docs: https://pkl-lang.org/main/current/pkl-cli/index.html#command-eval Dictionary: String -> String optional {}

pkl_toolchain

load("@rules_pkl//pkl:defs.bzl", "pkl_toolchain")

pkl_toolchain(name, cli)

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
cli - Label optional None

pkl_doc

load("@rules_pkl//pkl:defs.bzl", "pkl_doc")

pkl_doc(name, srcs, kwargs)

Generate documentation website for Pkl files.

PARAMETERS

Name Description Default Value
name A unique name for this target. none
srcs The Pkl source files to be documented. none
kwargs Further keyword arguments. E.g. visibility. none

pkl_java_library

load("@rules_pkl//pkl:defs.bzl", "pkl_java_library")

pkl_java_library(name, srcs, module_path, generate_getters, deps, tags, kwargs)

Create a compiled JAR of Java source files generated from Pkl source files.

PARAMETERS

Name Description Default Value
name A unique name for this target. none
srcs The Pkl files that are used to generate the Java source files. none
module_path List of Java module targets. Must export provide the JavaInfo provider. []
generate_getters Generate private final fields and public getter methods instead of public final fields. Defaults to True. None
deps Other targets to include in the Pkl module path when building this Java library. Must be pkl_* targets. []
tags Bazel tags to add to this target. []
kwargs Further keyword arguments. E.g. visibility. none

pkl_test_suite

load("@rules_pkl//pkl:defs.bzl", "pkl_test_suite")

pkl_test_suite(name, srcs, deps, tags, visibility, size, test_suffix, kwargs)

Create a suite of Pkl tests from the provided files.

Given the list of srcs, this macro will generate:

  1. A pkl_test target (with visibility:private) per src that ends with test_suffix
  2. A pkl_library that accumulates any files that don't match test_suffix
  3. A native.test_suite that accumulates all of the pkl_test targets

PARAMETERS

Name Description Default Value
name A unique name for this target. none
srcs The source files, containing Pkl test files. Accepts files with the .pkl extension. none
deps Other targets to include in the Pkl module path when building this configuration. Must be pkl_* targets. None
tags Tags to add to each Pkl test target. []
visibility The visibility of non test Pkl source files. None
size Size of Pkl test. None
test_suffix A custom suffix indicating a source file is a Pkl test file. None
kwargs Further keyword arguments. none