Skip to content

Commit 180c4bc

Browse files
Enhance documentation of Deprecated annotation (#16195)
Adds documentation for newly supported deprecation of types and aliases (#15962) and parameters (#15999).
1 parent 3d3b786 commit 180c4bc

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/annotations.cr

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
1-
# This annotation marks methods, classes, constants, and macros as deprecated.
1+
# This annotation marks features as deprecated.
22
#
3-
# It receives an optional `StringLiteral` as single argument containing a deprecation notice.
3+
# It can annotate methods, macros, types, constants, aliases and method parameters.
4+
#
5+
# It receives an optional `StringLiteral` as single argument containing a
6+
# deprecation notice.
47
#
58
# ```
69
# @[Deprecated("Use `#bar` instead")]
710
# def foo
811
# end
12+
#
13+
# @[Deprecated("Here may be dragons")]
14+
# class Foo
15+
# end
16+
17+
# def foo(bar, @[Deprecated("Do not try this at home")] baz)
18+
# end
919
# ```
20+
#
21+
# Deprecations are shown in the API docs and the compiler prints a warning when
22+
# using a deprecated feature.
23+
#
24+
# Deprecated types only trigger a warning when they are actually _used_ (e.g.
25+
# calling a class method), not when they're just part of type restriction, for
26+
# example.
27+
# Deprecated parameters only trigger a warning when the particular parameter is
28+
# passed in a call. Calls without this parameter are unaffected.
1029
annotation Deprecated
1130
end
1231

0 commit comments

Comments
 (0)