Skip to content

Commit

Permalink
feat!: Do not dump some settings by default
Browse files Browse the repository at this point in the history
  • Loading branch information
caksoylar committed Mar 28, 2024
1 parent e1c850c commit 692f896
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 122 deletions.
18 changes: 10 additions & 8 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ A mapping of certain field names to their values, characterizing key side drawin
- **`rel_w`**, **`rel_y`** (type: `float`): Delta dimension between external key rectangle and internal key rectangle. _Default:_ `12`, `12`
- **`rx`**, **`ry`** (type: `float`): Curvature of the rounded internal key rectangle. _Default:_ `4`, `4`

#### `svg_style`
#### `svg_style`[^1]

[^1]: Excluded from `keymap dump-config` by default, can be modified by manually adding it to the config file.

The CSS used for the SVG styling. This includes font settings, styling of key and combo rectangles and texts within them, along with some tweaks for external SVG glyphs.
Users are encouraged to not change the default value and use `svg_extra_style` to specify overrides instead.
Expand Down Expand Up @@ -182,7 +184,7 @@ _Type:_ `dict[str, str]`

_Default:_ Empty

#### `glyph_urls`
#### `glyph_urls`[^1]

Mapping of sources to (possibly templated) URLs for fetching SVG glyphs.
For instance, `$$material:settings$$` will use the value for `material` and replace `{}` in the value with `settings`.
Expand All @@ -191,7 +193,7 @@ _Type:_ `dict[str, str]`

_Default:_ See [`config.py`](keymap_drawer/config.py)

#### `use_local_cache`
#### `use_local_cache`[^1]

Use a local filesystem cache on an OS-specific location for downloaded QMK keyboard jsons and SVG glyphs.

Expand Down Expand Up @@ -221,9 +223,9 @@ _Default:_ `false`

#### `raw_binding_map`

Convert raw keycode/binding strings specified as keys to the representations given by their values.[^1]
Convert raw keycode/binding strings specified as keys to the representations given by their values.[^2]

[^1]: The value can be a [`LayoutKey` mapping](KEYMAP_SPEC.md#layers) or a string representing the tap legend.
[^2]: The value can be a [`LayoutKey` mapping](KEYMAP_SPEC.md#layers) or a string representing the tap legend.

If a conversion was made, shortcut any further processing.
E.g. `{"QK_BOOT": "BOOT", "&bootloader": "BOOT"}`.
Expand All @@ -250,7 +252,7 @@ _Default:_ `"toggle"`

#### `trans_legend`

Legend to output for transparent keys.[^1]
Legend to output for transparent keys.[^2]

_Type:_ `str | dict`

Expand Down Expand Up @@ -278,7 +280,7 @@ _Default:_ `["KC_"]`

#### `qmk_keycode_map`

Mapping to convert QMK keycodes to their display forms, applied after removing prefixes in `qmk_remove_keycode_prefix`.[^1]
Mapping to convert QMK keycodes to their display forms, applied after removing prefixes in `qmk_remove_keycode_prefix`.[^2]

_Type:_ `dict[str, str | dict]`

Expand All @@ -295,7 +297,7 @@ _Default:_ `[]`

#### `zmk_keycode_map`

Mapping to convert ZMK keycodes to their display forms, applied after removing prefixes in `zmk_remove_keycode_prefix`.[^1]
Mapping to convert ZMK keycodes to their display forms, applied after removing prefixes in `zmk_remove_keycode_prefix`.[^2]

_Type:_ `dict[str, str | dict]`

Expand Down
234 changes: 120 additions & 114 deletions keymap_drawer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from textwrap import dedent

from pydantic import BaseModel
from pydantic import BaseModel, Field
from pydantic_settings import BaseSettings


Expand Down Expand Up @@ -82,112 +82,115 @@ class KeySidePars(BaseModel):

# style CSS to be output in the SVG
# if you do not need to remove existing definitions, consider using svg_extra_style instead
svg_style: str = dedent(
"""\
/* inherit to force styles through use tags */
svg path {
fill: inherit;
}
/* font and background color specifications */
svg.keymap {
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
font-size: 14px;
font-kerning: normal;
text-rendering: optimizeLegibility;
fill: #24292e;
}
/* default key styling */
rect.key {
fill: #f6f8fa;
}
rect.key, rect.combo {
stroke: #c9cccf;
stroke-width: 1;
}
/* default key side styling, only used is draw_key_sides is set */
rect.side {
filter: brightness(90%);
}
/* color accent for combo boxes */
rect.combo, rect.combo-separate {
fill: #cdf;
}
/* color accent for held keys */
rect.held, rect.combo.held {
fill: #fdd;
}
/* color accent for ghost (optional) keys */
rect.ghost, rect.combo.ghost {
stroke-dasharray: 4, 4;
stroke-width: 2;
}
text {
text-anchor: middle;
dominant-baseline: middle;
}
/* styling for layer labels */
text.label {
font-weight: bold;
text-anchor: start;
stroke: white;
stroke-width: 2;
paint-order: stroke;
}
/* styling for combo tap, and key hold/shifted label text */
text.combo, text.hold, text.shifted {
font-size: 11px;
}
text.hold {
text-anchor: middle;
dominant-baseline: auto;
}
text.shifted {
text-anchor: middle;
dominant-baseline: hanging;
}
/* styling for hold/shifted label text in combo box */
text.combo.hold, text.combo.shifted {
font-size: 8px;
}
/* lighter symbol for transparent keys */
text.trans {
fill: #7b7e81;
}
/* styling for combo dendrons */
path.combo {
stroke-width: 1;
stroke: gray;
fill: none;
}
/* Start Tabler Icons Cleanup */
/* cannot use height/width with glyphs */
.icon-tabler > path {
fill: inherit;
stroke: inherit;
stroke-width: 2;
}
/* hide tabler's default box */
.icon-tabler > path[stroke="none"][fill="none"] {
visibility: hidden;
}
/* End Tabler Icons Cleanup */
"""
svg_style: str = Field(
exclude=True,
default=dedent(
"""\
/* inherit to force styles through use tags */
svg path {
fill: inherit;
}
/* font and background color specifications */
svg.keymap {
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
font-size: 14px;
font-kerning: normal;
text-rendering: optimizeLegibility;
fill: #24292e;
}
/* default key styling */
rect.key {
fill: #f6f8fa;
}
rect.key, rect.combo {
stroke: #c9cccf;
stroke-width: 1;
}
/* default key side styling, only used is draw_key_sides is set */
rect.side {
filter: brightness(90%);
}
/* color accent for combo boxes */
rect.combo, rect.combo-separate {
fill: #cdf;
}
/* color accent for held keys */
rect.held, rect.combo.held {
fill: #fdd;
}
/* color accent for ghost (optional) keys */
rect.ghost, rect.combo.ghost {
stroke-dasharray: 4, 4;
stroke-width: 2;
}
text {
text-anchor: middle;
dominant-baseline: middle;
}
/* styling for layer labels */
text.label {
font-weight: bold;
text-anchor: start;
stroke: white;
stroke-width: 2;
paint-order: stroke;
}
/* styling for combo tap, and key hold/shifted label text */
text.combo, text.hold, text.shifted {
font-size: 11px;
}
text.hold {
text-anchor: middle;
dominant-baseline: auto;
}
text.shifted {
text-anchor: middle;
dominant-baseline: hanging;
}
/* styling for hold/shifted label text in combo box */
text.combo.hold, text.combo.shifted {
font-size: 8px;
}
/* lighter symbol for transparent keys */
text.trans {
fill: #7b7e81;
}
/* styling for combo dendrons */
path.combo {
stroke-width: 1;
stroke: gray;
fill: none;
}
/* Start Tabler Icons Cleanup */
/* cannot use height/width with glyphs */
.icon-tabler > path {
fill: inherit;
stroke: inherit;
stroke-width: 2;
}
/* hide tabler's default box */
.icon-tabler > path[stroke="none"][fill="none"] {
visibility: hidden;
}
/* End Tabler Icons Cleanup */
"""
),
)

# extra CSS to be appended to svg_style
Expand All @@ -208,15 +211,18 @@ class KeySidePars(BaseModel):

# mapping of sources to (possibly templated) URLs for fetching SVG glyphs
# e.g. `$$material:settings$$` will use the value for `material` and replace `{}` with `settings`
glyph_urls: dict[str, str] = {
"tabler": "https://unpkg.com/@tabler/icons/icons/outline/{}.svg",
"mdi": "https://unpkg.com/@mdi/svg/svg/{}.svg",
"mdil": "https://raw.githubusercontent.com/Pictogrammers/MaterialDesignLight/master/svg/{}.svg",
"material": "https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/{}/default/48px.svg",
}
glyph_urls: dict[str, str] = Field(
exclude=True,
default={
"tabler": "https://unpkg.com/@tabler/icons/icons/outline/{}.svg",
"mdi": "https://unpkg.com/@mdi/svg/svg/{}.svg",
"mdil": "https://raw.githubusercontent.com/Pictogrammers/MaterialDesignLight/master/svg/{}.svg",
"material": "https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/{}/default/48px.svg",
},
)

# use a local filesystem cache on an OS-specific location for downloaded QMK keyboard jsons and SVG glyphs
use_local_cache: bool = True
use_local_cache: bool = Field(exclude=True, default=True)


class ParseConfig(BaseSettings, env_prefix="KEYMAP_", extra="ignore"):
Expand Down

0 comments on commit 692f896

Please sign in to comment.