You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/language-reference/pages/index.adoc
+47-1Lines changed: 47 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2736,6 +2736,10 @@ output {
2736
2736
2737
2737
For more on path-based converters, see {uri-stdlib-PcfRenderer-converters}[PcfRenderer.converters].
2738
2738
2739
+
Special <<annotations,Annotations>> may also be used to influence how class properties are rendered.
2740
+
The `ConvertProperty` annotation (and subclasses of it) are automatically applied during.
2741
+
For more on annotation-based converters, see link:{uri-stdlib-ConvertProperty}[ConvertProperty].
2742
+
2739
2743
Sometimes it is useful to directly compute the final module output, bypassing `output.value` and `output.converters`.
2740
2744
To do so, set the link:{uri-stdlib-baseModule}/ModuleOutput#text[output.text] property to a String value:
2741
2745
@@ -3203,6 +3207,7 @@ This section discusses language features that are generally more relevant to tem
3203
3207
<<module-keyword,`module` Keyword>> +
3204
3208
<<glob-patterns,Glob Patterns>> +
3205
3209
<<doc-comments,Doc Comments>> +
3210
+
<<annotations,Annotations>> +
3206
3211
<<name-resolution,Name Resolution>> +
3207
3212
<<reserved-keywords,Reserved Keywords>> +
3208
3213
<<blank-identifiers,Blank Identifiers>> +
@@ -5332,7 +5337,7 @@ Module-level members can be prefixed with `module.` to resolve name conflicts:
5332
5337
/// See [module.pigeon].
5333
5338
----
5334
5339
5335
-
To exclude a member from documentation and code completion, annotate it with `@Unlisted`:
5340
+
To exclude a member from documentation and code completion, <<annotations,annotate>> it with `@Unlisted`:
5336
5341
5337
5342
[source%parsed,{pkl}]
5338
5343
----
@@ -5349,6 +5354,47 @@ The following member links are marked up as code but not rendered as links:footn
5349
5354
5350
5355
Nevertheless, it is a good practice to use member links in the above cases.
5351
5356
5357
+
[[annotations]]
5358
+
=== Annotations
5359
+
5360
+
Annotations are a mechanism to provides extra metadata about Pkl <<modules,modules>>, <<classes,classes>>, <<methods,methods>>, and <<properties,properties>>.
5361
+
They provide metadata about the type or member they annotate that can be via link:{uri-stdlib-reflectModule}[reflection] or Pkl's Java APIs.
5362
+
The most common use cases for annotations are to add metadata to influence behavior of xref:pkl-doc:index.adoc[Pkldoc], code generation tools, or <<module-output,module output>>.
5363
+
5364
+
Annotations are regular Pkl objects whose class extends link:{uri-stdlib-Annotation}[`Annotation`].
5365
+
Annotation instances are defined similarly to regular <<classes, class instances>>, but instead of using the `new` keyword the class name is prefixed with `@`.
5366
+
The object body may be omitted if an annotation's class has no properties or the declared annotation does not override any of the class's default values
5367
+
Multiple annotations may be defined on a member.
5368
+
If the annotated member has a <<doc-comments,doc comment>>, the annotation is defined between the comment and the member.
0 commit comments