A type-safe Python DSL for cross-platform mobile resource generation
Project description
resforge
A type-safe Python DSL for generating native Android and iOS resources from design tokens.
Features
- Fluent, Pythonic API
- Jetpack Compose theme generation with type-safe color and dimension properties
- Supports all Android
res/values/types - Native Apple Asset Catalog (
.xcassets) with dark mode support - Built-in validation for resource names and color formats
Installation
pip install resforge
Quick Example
Android (Jetpack Compose)
from resforge.android import ComposeWriter, dp
with ComposeWriter("Theme.kt", "dev.kipila.example") as compose:
compose.dimension(border=dp(8))
with compose.object_("AppColors") as colors:
colors.color(primary="#FF0000", background="#FFFFFF")
package dev.kipila.example
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
val border: Dp = 8.dp
object AppColors {
val primary: Color = Color(0xFFFF0000)
val background: Color = Color(0xFFFFFFFF)
}
Android (XML Resources)
from resforge.android import ValuesWriter, dp, sp
with ValuesWriter("res/values/resources.xml") as res:
res.string(
app_name="My App",
welcome_message="Welcome!",
)
res.color(
primary="#FF6200EE",
secondary="#FF03DAC5",
)
res.dimension(
padding_small=dp(8),
text_body=sp(16),
)
<resources>
<string name="app_name">My App</string>
<string name="welcome_message">Welcome!</string>
<color name="primary">#FF6200EE</color>
<color name="secondary">#FF03DAC5</color>
<dimen name="padding_small">8dp</dimen>
<dimen name="text_body">16sp</dimen>
</resources>
Asset Catalog (iOS)
from resforge.apple import Appearance, AppleColor, AssetCatalog
with AssetCatalog("App", "Assets") as ac:
ac.colorset(
"Background",
"#ffffff",
AppleColor("#000000", appearances=[Appearance.Dark]),
)
{
"info": {
"author": "xcode",
"version": 1
},
"colors": [
{
"idiom": "universal",
"color": {
"components": {
"red": "1.000",
"green": "1.000",
"blue": "1.000",
"alpha": "1.000"
},
"color-space": "srgb"
}
},
{
"idiom": "universal",
"color": {
"components": {
"red": "0.000",
"green": "0.000",
"blue": "0.000",
"alpha": "1.000"
},
"color-space": "srgb"
},
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
]
}
]
}
Roadmap
- SwiftUI color extension generation (
SwiftUIWriter) - Asset Catalog image support (ImageSet, IconSet)
- Android
res/drawablevector asset support
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file resforge-0.3.0.tar.gz.
File metadata
- Download URL: resforge-0.3.0.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb8bc9fa207639a271705083eb713f6b5bc85a3cf971c688f72b68f5bc03ffa8
|
|
| MD5 |
f924457fe890749fc513078d756214e2
|
|
| BLAKE2b-256 |
cbc0239203d2744f45a588cceb58e08ef2367f11d0b4fe80b90fe71a371b7aaa
|
Provenance
The following attestation bundles were made for resforge-0.3.0.tar.gz:
Publisher:
publish.yml on ok100/resforge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
resforge-0.3.0.tar.gz -
Subject digest:
eb8bc9fa207639a271705083eb713f6b5bc85a3cf971c688f72b68f5bc03ffa8 - Sigstore transparency entry: 1392739245
- Sigstore integration time:
-
Permalink:
ok100/resforge@025db76ceb22921dac1765b3a148682d82f1e6a6 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/ok100
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@025db76ceb22921dac1765b3a148682d82f1e6a6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file resforge-0.3.0-py3-none-any.whl.
File metadata
- Download URL: resforge-0.3.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c0f386114a47e3f317c32d9942ab048cbf9acb119b3a770099ed9f541e404f5
|
|
| MD5 |
4469f7603d959e0f87fb669740340cf9
|
|
| BLAKE2b-256 |
0d0cf5e04249acc9b590482262668a16b9dafe8f61541a330d54564b5afa31ea
|
Provenance
The following attestation bundles were made for resforge-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on ok100/resforge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
resforge-0.3.0-py3-none-any.whl -
Subject digest:
9c0f386114a47e3f317c32d9942ab048cbf9acb119b3a770099ed9f541e404f5 - Sigstore transparency entry: 1392739249
- Sigstore integration time:
-
Permalink:
ok100/resforge@025db76ceb22921dac1765b3a148682d82f1e6a6 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/ok100
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@025db76ceb22921dac1765b3a148682d82f1e6a6 -
Trigger Event:
release
-
Statement type: