Skip to content

Update: improve annotations.md introduction#5361

Merged
budindepunk merged 10 commits intomasterfrom
docs-annotations-update
Feb 11, 2026
Merged

Update: improve annotations.md introduction#5361
budindepunk merged 10 commits intomasterfrom
docs-annotations-update

Conversation

@budindepunk
Copy link
Collaborator

Re: KT-84121

@budindepunk budindepunk requested a review from serras February 9, 2026 09:51
@budindepunk budindepunk requested a review from a team as a code owner February 9, 2026 09:51
[//]: # (title: Annotations)

Annotations are a means of attaching metadata to code. To declare an annotation, put the `annotation` modifier in front of a class:
Annotations are tags used to attach metadata to code. They provide additional information about tagged code elements without altering the program's execution.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without altering the program's execution

This is not strictly true. Some annotations are required, for example, to specify how to serialize a value into a JSON. If that annotation is not present, the program would behave differently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other important examples are Dependency Injection frameworks.

Annotations are a means of attaching metadata to code. To declare an annotation, put the `annotation` modifier in front of a class:
Annotations are tags used to attach metadata to code. They provide additional information about tagged code elements without altering the program's execution.

Annotations are used by the compiler and runtime processors to simplify and automate common tasks, such as generating boilerplate code, enforcing coding standards or writing documentation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before: some annotations are also visible during runtime (there's a specific retention for this), and they are widely used in the JVM world.

Copy link
Contributor

@serras serras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current text make it seem like annotations are a compile-only thing, when in fact they are also very important at runtime.

@budindepunk budindepunk requested a review from serras February 9, 2026 10:13
Copy link
Collaborator

@sarahhaggarty sarahhaggarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start! I made some suggestions to make the text more active, simplify some of the wording, and connect the first two parts a bit better. Ping me if anything is unclear or you have questions! :)

[//]: # (title: Annotations)

Annotations are a means of attaching metadata to code. To declare an annotation, put the `annotation` modifier in front of a class:
Annotations are tags used to attach metadata to source code.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use some passive constructions. Can you make it more active by making it clear what the active subject is? For example, here it could be: "Annotations are tags that you can use to attach metadata to your code."

Annotations are a means of attaching metadata to code. To declare an annotation, put the `annotation` modifier in front of a class:
Annotations are tags used to attach metadata to source code.

During compilation and runtime, annotations are processed by different tools and frameworks to simplify and automate common tasks, such as generating boilerplate code, enforcing coding standards or writing documentation.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you combine this with the first sentence? The first sentence explains about how annotations add metadata so it would be nice to understand how that metadata is used in the following sentence. For example, by a processor to generate additional code.

This sentence is also quite long so please break it into two :)


During compilation and runtime, annotations are processed by different tools and frameworks to simplify and automate common tasks, such as generating boilerplate code, enforcing coding standards or writing documentation.

> To learn more about annotation processing in Kotlin, see [KSP](ksp-overview.md)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you introduce KSP as an acronym here? :)

Also, "annotation processing" isn't easy for a beginner to understand so could it be explained more simply like "If you want to generate code from annotations, Kotlin provides Kotlin Symbol Processing (KSP)."?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I am in doubt because beginners reading about annotations are likely to be using external annotation processors, and therefore not need KSP at all. They will just need to annotate their code in the way the processor they want to use tells them to, and if they set up the processor the code will be generated.

KSP is mostly relevant to people who want to develop their own processor, and for whom the phrase "annotation processor" is clear. So I think if the specific phrase is not there they might not realize that KSP is what they need to develop those processors. I would expect a beginner to understand that this note is related to a more advanced subject and skip it. I'll try to make that more explicit. How about "when you're ready to develop your own annotation processors, you can use the Kotlin Symbol Processing (KSP) API"?


## Declaration

To declare an annotation, put the `annotation` modifier in front of a class:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To declare an annotation, put the `annotation` modifier in front of a class:
Annotations are a special type of class. To declare an annotation, use the `annotation` keyword before the class declaration:

Outside of the scope I shared. But since we're here!

Carolina Silva Rode added 2 commits February 10, 2026 09:44
Copy link
Collaborator

@sarahhaggarty sarahhaggarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just one last suggestion but then LGTM!

Co-authored-by: Sarah Haggarty <81160244+sarahhaggarty@users.noreply.github.com>
@budindepunk budindepunk merged commit 13f49ca into master Feb 11, 2026
5 checks passed
@budindepunk budindepunk deleted the docs-annotations-update branch February 11, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants