Skip to content

Commit 3241fb7

Browse files
committed
Clean up RestrictTo docs
Bug: 277361689 Test: docs Change-Id: I8be054c846ecbfeded30fa99c1d5e5d7c63171bb
1 parent 5c4b2c0 commit 3241fb7

File tree

1 file changed

+32
-25
lines changed
  • annotation/annotation/src/commonMain/kotlin/androidx/annotation

1 file changed

+32
-25
lines changed

annotation/annotation/src/commonMain/kotlin/androidx/annotation/RestrictTo.kt

+32-25
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,21 @@ package androidx.annotation
1919
import androidx.annotation.RestrictTo.Scope
2020

2121
/**
22-
* Denotes that the annotated element should only be accessed from within a
23-
* specific scope (as defined by [Scope]).
22+
* Denotes that the annotated element should only be accessed from within a specific scope (as
23+
* defined by [Scope]).
2424
*
25-
*
26-
* Example of restricting usage within a library (based on gradle group ID):
25+
* Example of restricting usage within a library (based on Gradle group ID):
2726
* ```
2827
* @RestrictTo(GROUP_ID)
2928
* public void resetPaddingToInitialValues() { ...
3029
* ```
30+
*
3131
* Example of restricting usage to tests:
3232
* ```
3333
* @RestrictTo(Scope.TESTS)
3434
* public abstract int getUserId();
3535
* ```
36+
*
3637
* Example of restricting usage to subclasses:
3738
* ```
3839
* @RestrictTo(Scope.SUBCLASSES)
@@ -53,56 +54,62 @@ import androidx.annotation.RestrictTo.Scope
5354
)
5455
public expect annotation class RestrictTo(
5556
/**
56-
* The scope to which usage should be restricted.
57+
* The scope(s) to which usage should be restricted.
5758
*/
5859
vararg val value: Scope
5960
) {
6061
public enum class Scope {
6162
/**
62-
* Restrict usage to code within the same library (e.g. the same
63-
* gradle group ID and artifact ID).
63+
* Restrict usage to code within the same library (e.g. the same Gradle group ID and
64+
* artifact ID).
6465
*/
6566
LIBRARY,
6667

6768
/**
6869
* Restrict usage to code within the same group of libraries.
69-
* This corresponds to the gradle group ID.
70+
*
71+
* This corresponds to the Gradle group ID.
7072
*/
7173
LIBRARY_GROUP,
7274

7375
/**
74-
* Restrict usage to code within packages whose groups share
75-
* the same library group prefix up to the last ".", so for
76-
* example libraries foo.bar:lib1 and foo.baz:lib2 share
77-
* the prefix "foo." and so they can use each other's
78-
* apis that are restricted to this scope. Similarly for
79-
* com.foo.bar:lib1 and com.foo.baz:lib2 where they share
80-
* "com.foo.". Library com.bar.qux:lib3 however will not
81-
* be able to use the restricted api because it only
82-
* shares the prefix "com." and not all the way until the
83-
* last ".".
76+
* Restrict usage to code within packages whose Gradle group IDs share the same prefix up to
77+
* the last `.` separator.
78+
*
79+
* For example, libraries `foo.bar:lib1` and `foo.baz:lib2` share the `foo.` prefix and can
80+
* therefore use each other's APIs that are restricted to this scope. Similar applies to
81+
* libraries `com.foo.bar:lib1` and `com.foo.baz:lib2`, which share the `com.foo.` prefix.
82+
*
83+
* Library `com.bar.qux:lib3`, however, will not be able to use the restricted API because
84+
* it only shares the prefix `com.` and not all the way until the last `.` separator.
8485
*/
8586
LIBRARY_GROUP_PREFIX,
8687

8788
/**
88-
* Restrict usage to code within the same group ID (based on gradle
89-
* group ID). This is an alias for [LIBRARY_GROUP_PREFIX].
89+
* Restrict usage to code within the same group ID (based on Gradle group ID).
9090
*
91-
* @deprecated Use [LIBRARY_GROUP_PREFIX] instead
91+
* This is an alias for [LIBRARY_GROUP_PREFIX].
9292
*/
93-
@Deprecated("Use LIBRARY_GROUP_PREFIX instead.")
93+
@Deprecated(
94+
message = "Use @RestrictTo(LIBRARY_GROUP_PREFIX) instead",
95+
replaceWith = ReplaceWith(
96+
"LIBRARY_GROUP_PREFIX",
97+
"androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX"
98+
)
99+
)
94100
GROUP_ID,
95101

96102
/**
97-
* Restrict usage to tests.
103+
* Restrict usage to test source sets or code annotated with the [TESTS] restriction scope.
104+
*
105+
* This is equivalent to `@VisibleForTesting(NONE)`.
98106
*/
99107
TESTS,
100108

101109
/**
102110
* Restrict usage to subclasses of the enclosing class.
103111
*
104-
* **Note:** This scope should not be used to annotate
105-
* packages.
112+
* **Note:** This scope should not be used to annotate packages.
106113
*/
107114
SUBCLASSES,
108115
}

0 commit comments

Comments
 (0)