Skip to content

Commit cd2c9c7

Browse files
authored
Merge pull request #12 from Commit451/feat/tools-ignore-lint
feat: add tools:ignore support to all add methods
2 parents 250b654 + 50f30da commit cd2c9c7

22 files changed

Lines changed: 402 additions & 35 deletions

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,42 @@ val poet = ResourcesPoet.create()
8888

8989
We do not allow configuration of more complicated resources like `drawable` and `anim` in the creation sense.
9090

91+
## Suppressing Lint Warnings
92+
93+
You can add `tools:ignore` to suppress Android lint warnings on individual resources or at the top level:
94+
95+
```kotlin
96+
// Per-resource ignore
97+
val poet = ResourcesPoet.create()
98+
.addString("app_name", "Test", toolsIgnore = "UnusedResource")
99+
.addColor("color_primary", "#FF0000", toolsIgnore = "UnusedIds")
100+
```
101+
102+
```xml
103+
<resources xmlns:tools="http://schemas.android.com/tools">
104+
<string name="app_name" tools:ignore="UnusedResource">Test</string>
105+
<color name="color_primary" tools:ignore="UnusedIds">#FF0000</color>
106+
</resources>
107+
```
108+
109+
You can also set `tools:ignore` at the top-level `<resources>` element to suppress warnings for all resources in the file:
110+
111+
```kotlin
112+
val poet = ResourcesPoet.create()
113+
.toolsIgnore("UnusedResource,TypographyDashes")
114+
.addString("somekey", "something-else")
115+
.addString("anotherkey", "another-value")
116+
```
117+
118+
```xml
119+
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="UnusedResource,TypographyDashes">
120+
<string name="somekey">something-else</string>
121+
<string name="anotherkey">another-value</string>
122+
</resources>
123+
```
124+
125+
Top-level and per-element ignores can be combined — the top-level applies to all children, and per-element ignores override or add to it.
126+
91127
License
92128
--------
93129

0 commit comments

Comments
 (0)