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 for colors and dimensions
- Supports all Android
res/values/types - Native Apple Asset Catalog (
.xcassets) support - Wide Gamut support with automatic sRGB fallbacks
- Built-in validation for resource names and color formats
Installation
pip install resforge
Quick Example
Android (Jetpack Compose)
from resforge.android import ComposeWriter
with ComposeWriter("Color.kt", "com.example.myapplication.ui.theme") as compose:
compose.color(
Purple80="#D0BCFF",
PurpleGrey80="#CCC2DC",
Pink80="#EFB8C8",
Purple40="#6650a4",
PurpleGrey40="#625b71",
Pink40="#7D5260",
)
package com.example.myapplication.ui.theme
import androidx.compose.ui.graphics.Color
val Purple80: Color = Color(0xFFD0BCFF)
val PurpleGrey80: Color = Color(0xFFCCC2DC)
val Pink80: Color = Color(0xFFEFB8C8)
val Purple40: Color = Color(0xFF6650A4)
val PurpleGrey40: Color = Color(0xFF625B71)
val Pink40: Color = Color(0xFF7D5260)
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="#6200EE",
secondary="#03DAC5",
)
res.dimension(
padding_small=dp(8),
text_body=sp(16),
)
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">My App</string>
<string name="welcome_message">Welcome!</string>
<color name="primary">#FF6200EE</color>
<color name="secondary">#FF00FF00</color>
<dimen name="padding_small">8dp</dimen>
<dimen name="text_body">16sp</dimen>
</resources>
Asset Catalog (iOS)
from resforge import Color
from resforge.apple import Appearance, AppleColor, AssetCatalog
with AssetCatalog("App", "Assets") as catalog:
catalog.colorset(
"MyColor",
AppleColor(Color.p3(0.0, 1.0, 0.0)),
AppleColor("#000000", appearances=[Appearance.Dark]),
)
{
"info": {
"author": "xcode",
"version": 1
},
"colors": [
{
"idiom": "universal",
"color": {
"components": {
"red": "0.000",
"green": "1.000",
"blue": "0.000",
"alpha": "1.000"
},
"color-space": "srgb"
}
},
{
"idiom": "universal",
"color": {
"components": {
"red": "0.000",
"green": "1.000",
"blue": "0.000",
"alpha": "1.000"
},
"color-space": "display-p3"
},
"display-gamut": "display-P3"
},
{
"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 dimensions
- Typography
- Images (ImageSet, IconSet,
res/drawablevectors)
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.4.1.tar.gz.
File metadata
- Download URL: resforge-0.4.1.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
340e76064409908a1278fba32cf23da1ba843d453fdcf6732e1a9ac2035117b8
|
|
| MD5 |
4ecd36384cd311379201823e810013fc
|
|
| BLAKE2b-256 |
7959f3d4407a50c6a9f40ad2dcb059429e3947ed06eda7928f96fe716b3509ae
|
Provenance
The following attestation bundles were made for resforge-0.4.1.tar.gz:
Publisher:
publish.yml on kipila-dev/resforge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
resforge-0.4.1.tar.gz -
Subject digest:
340e76064409908a1278fba32cf23da1ba843d453fdcf6732e1a9ac2035117b8 - Sigstore transparency entry: 1603256419
- Sigstore integration time:
-
Permalink:
kipila-dev/resforge@ebcd838555309456a9dd75b40a5053b09abc084c -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/kipila-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ebcd838555309456a9dd75b40a5053b09abc084c -
Trigger Event:
release
-
Statement type:
File details
Details for the file resforge-0.4.1-py3-none-any.whl.
File metadata
- Download URL: resforge-0.4.1-py3-none-any.whl
- Upload date:
- Size: 17.3 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 |
6e7b6def27262a068aa23c9ca4a00188ff0abedc5b69702379ca69f3ff004ea0
|
|
| MD5 |
e566571d748a96209788cd122bd0f6e1
|
|
| BLAKE2b-256 |
955ac3fde11f5d8193052b701fc145a77867bc12e26d583265e155c638a769be
|
Provenance
The following attestation bundles were made for resforge-0.4.1-py3-none-any.whl:
Publisher:
publish.yml on kipila-dev/resforge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
resforge-0.4.1-py3-none-any.whl -
Subject digest:
6e7b6def27262a068aa23c9ca4a00188ff0abedc5b69702379ca69f3ff004ea0 - Sigstore transparency entry: 1603256535
- Sigstore integration time:
-
Permalink:
kipila-dev/resforge@ebcd838555309456a9dd75b40a5053b09abc084c -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/kipila-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ebcd838555309456a9dd75b40a5053b09abc084c -
Trigger Event:
release
-
Statement type: