decktile 0.3.2__tar.gz → 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. {decktile-0.3.2 → decktile-0.3.3}/PKG-INFO +20 -2
  2. {decktile-0.3.2 → decktile-0.3.3}/README.md +19 -1
  3. {decktile-0.3.2 → decktile-0.3.3}/pyproject.toml +1 -1
  4. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/cli.py +5 -1
  5. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/seaborn.py +41 -15
  6. decktile-0.3.3/src/decktile/seaborn_styles/hami.py +33 -0
  7. {decktile-0.3.2 → decktile-0.3.3}/tests/test_seaborn_styles.py +25 -0
  8. {decktile-0.3.2 → decktile-0.3.3}/LICENSE +0 -0
  9. {decktile-0.3.2 → decktile-0.3.3}/NOTICE +0 -0
  10. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/__init__.py +0 -0
  11. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/__main__.py +0 -0
  12. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/assets/lucide/VENDORED.md +0 -0
  13. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/assets/lucide/lucide.css +0 -0
  14. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/assets/lucide/lucide.ttf +0 -0
  15. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/parser/__init__.py +0 -0
  16. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/parser/ast.py +0 -0
  17. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/parser/markdown.py +0 -0
  18. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/plugins/cards.py +0 -0
  19. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/plugins/directives.py +0 -0
  20. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/plugins/fenced.py +0 -0
  21. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/plugins/layouts.py +0 -0
  22. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/plugins/lucide.py +0 -0
  23. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/plugins/lucide_font.py +0 -0
  24. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/__init__.py +0 -0
  25. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/html.py +0 -0
  26. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/ir.py +0 -0
  27. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/odf/__init__.py +0 -0
  28. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/odf/geometry.py +0 -0
  29. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/odf/shapes.py +0 -0
  30. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/odf/styles.py +0 -0
  31. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/odp.py +0 -0
  32. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/pdf.py +0 -0
  33. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/pdg.py +0 -0
  34. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/templates/base.css +0 -0
  35. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/templates/decktile.js +0 -0
  36. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/render/templates/shell.html +0 -0
  37. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/seaborn_styles/__init__.py +0 -0
  38. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/seaborn_styles/kubecon_na.py +0 -0
  39. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/seaborn_styles/ossummit_europe.py +0 -0
  40. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/theme/__init__.py +0 -0
  41. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/theme/loader.py +0 -0
  42. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/theme/parser.py +0 -0
  43. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/themes/default.css +0 -0
  44. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/themes/kcd_vietnam.css +0 -0
  45. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/themes/kubecon_china.css +0 -0
  46. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/themes/kubecon_japan.css +0 -0
  47. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/themes/kubecon_na.css +0 -0
  48. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/themes/ossummit_europe.css +0 -0
  49. {decktile-0.3.2 → decktile-0.3.3}/src/decktile/themes/ossummit_korea.css +0 -0
  50. {decktile-0.3.2 → decktile-0.3.3}/tests/__init__.py +0 -0
  51. {decktile-0.3.2 → decktile-0.3.3}/tests/test_cli.py +0 -0
  52. {decktile-0.3.2 → decktile-0.3.3}/tests/test_geometry.py +0 -0
  53. {decktile-0.3.2 → decktile-0.3.3}/tests/test_html.py +0 -0
  54. {decktile-0.3.2 → decktile-0.3.3}/tests/test_ir.py +0 -0
  55. {decktile-0.3.2 → decktile-0.3.3}/tests/test_odf_shapes.py +0 -0
  56. {decktile-0.3.2 → decktile-0.3.3}/tests/test_odp.py +0 -0
  57. {decktile-0.3.2 → decktile-0.3.3}/tests/test_parser.py +0 -0
  58. {decktile-0.3.2 → decktile-0.3.3}/tests/test_pdg.py +0 -0
  59. {decktile-0.3.2 → decktile-0.3.3}/tests/test_video.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: decktile
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Markdown to designed slides: HTML, PDF and editable ODP
5
5
  Author-Email: Reza Jelveh <git@jelveh.me>
6
6
  License: Apache-2.0
@@ -473,7 +473,25 @@ Pre-imported: `sns`, `plt`, `pd`, `np`. Set `seaborn_theme: kcd_vietnam` in
473
473
  frontmatter to apply brand colors from the matching CSS theme file. Colors
474
474
  and fonts are parsed from the `:root` block. Falls
475
475
  back to seaborn palette names (`Paired` is the default, also `deep`,
476
- `muted`, `pastel`, etc.) if no theme CSS matches.
476
+ `muted`, `pastel`, etc.) if no theme CSS matches. `seaborn_theme: hami`
477
+ matches the predictygraph `hami` diagram colours.
478
+
479
+ To keep a chart theme in your own repo, point `seaborn_theme` at a `.toml`
480
+ file, relative to the deck:
481
+
482
+ ```toml
483
+ # brand.toml
484
+ palette = ["#16a34a", "#2563eb", "#ca8a04"]
485
+
486
+ [style] # matplotlib rcParams
487
+ "text.color" = "#1e293b"
488
+ "xtick.color" = "#64748b"
489
+ "axes.facecolor" = "#ffffff"
490
+ ```
491
+
492
+ ```yaml
493
+ seaborn_theme: themes/brand.toml
494
+ ```
477
495
 
478
496
  ### Custom charts with matplotlib
479
497
 
@@ -441,7 +441,25 @@ Pre-imported: `sns`, `plt`, `pd`, `np`. Set `seaborn_theme: kcd_vietnam` in
441
441
  frontmatter to apply brand colors from the matching CSS theme file. Colors
442
442
  and fonts are parsed from the `:root` block. Falls
443
443
  back to seaborn palette names (`Paired` is the default, also `deep`,
444
- `muted`, `pastel`, etc.) if no theme CSS matches.
444
+ `muted`, `pastel`, etc.) if no theme CSS matches. `seaborn_theme: hami`
445
+ matches the predictygraph `hami` diagram colours.
446
+
447
+ To keep a chart theme in your own repo, point `seaborn_theme` at a `.toml`
448
+ file, relative to the deck:
449
+
450
+ ```toml
451
+ # brand.toml
452
+ palette = ["#16a34a", "#2563eb", "#ca8a04"]
453
+
454
+ [style] # matplotlib rcParams
455
+ "text.color" = "#1e293b"
456
+ "xtick.color" = "#64748b"
457
+ "axes.facecolor" = "#ffffff"
458
+ ```
459
+
460
+ ```yaml
461
+ seaborn_theme: themes/brand.toml
462
+ ```
445
463
 
446
464
  ### Custom charts with matplotlib
447
465
 
@@ -23,7 +23,7 @@ dependencies = [
23
23
  ]
24
24
  requires-python = ">=3.11"
25
25
  readme = "README.md"
26
- version = "0.3.2"
26
+ version = "0.3.3"
27
27
 
28
28
  [project.license]
29
29
  text = "Apache-2.0"
@@ -23,7 +23,9 @@ app = typer.Typer(help="Markdown to styled HTML + ODP + PDF", no_args_is_help=Tr
23
23
 
24
24
  @app.callback(invoke_without_command=True)
25
25
  def main(
26
- files: list[Path] | None = typer.Argument(None, help="Markdown files to build; globs like '*.deck.md' or 'talks/**/*.deck.md' are expanded"),
26
+ files: list[Path] | None = typer.Argument(
27
+ None, help="Markdown files to build; globs like '*.deck.md' or 'talks/**/*.deck.md' are expanded"
28
+ ),
27
29
  output_dir: Path | None = typer.Option(None, "-o", "--output-dir", help="Output directory (default: <input>/dist/)"),
28
30
  pdf: bool = typer.Option(False, "--pdf", help="Generate PDF"),
29
31
  odp: bool = typer.Option(False, "--odp", help="Generate ODP (programmatic)"),
@@ -103,6 +105,8 @@ def _build(
103
105
  ) -> None:
104
106
  content = file.read_text(encoding="utf-8")
105
107
  doc = parse(content)
108
+ if doc.meta.seaborn_theme.endswith(".toml"): # downstream theme file, relative to the deck
109
+ doc.meta.seaborn_theme = str((file.parent / doc.meta.seaborn_theme).resolve())
106
110
  dims = doc.meta.dimensions()
107
111
 
108
112
  out_dir = output_dir or file.parent / "dist"
@@ -11,8 +11,10 @@ Only active when seaborn + matplotlib are installed (pdm install -G plot).
11
11
  Falls back to plain code highlighting otherwise.
12
12
 
13
13
  Theme support: the ``seaborn_theme`` frontmatter field accepts either a
14
- seaborn palette name ("Paired", "deep", etc.) or a decktile theme name that
15
- matches a CSS file in ``decktile/themes/<name>.css``. CSS variables are
14
+ seaborn palette name ("Paired", "deep", etc.), a decktile theme name that
15
+ matches a CSS file in ``decktile/themes/<name>.css``, or a path to a ``.toml``
16
+ theme file kept next to the deck (``palette = [...]`` plus ``[style]`` rcParams).
17
+ CSS variables are
16
18
  parsed and mapped to matplotlib rcParams -- no hardcoded color duplication.
17
19
  Style modules in ``decktile.seaborn_styles.<name>`` take precedence over CSS
18
20
  and can set ``seaborn_palette`` to override the default ("Paired").
@@ -21,6 +23,7 @@ and can set ``seaborn_palette`` to override the default ("Paired").
21
23
  import importlib
22
24
  import io
23
25
  import re
26
+ import tomllib
24
27
  from pathlib import Path
25
28
 
26
29
  _DEFAULT_FIGSIZE = (6.4, 4.8)
@@ -75,30 +78,53 @@ def _css_theme_rcparams(name: str) -> dict | None:
75
78
  return style
76
79
 
77
80
 
81
+ def _file_theme(path: Path) -> dict:
82
+ """A downstream theme file: ``palette = [...]`` plus a ``[style]`` table of rcParams."""
83
+ data = tomllib.loads(path.read_text(encoding="utf-8"))
84
+ style = dict(data.get("style", {}))
85
+ if "palette" in data:
86
+ style["seaborn_palette"] = data["palette"]
87
+ return style
88
+
89
+
90
+ def _apply(style: dict) -> None:
91
+ global _palette, _style
92
+ import matplotlib
93
+
94
+ matplotlib.use("Agg")
95
+ import matplotlib.pyplot as plt
96
+ import seaborn as sns
97
+
98
+ palette = style.pop("seaborn_palette", _DEFAULT_PALETTE)
99
+ sns.set_theme(style="darkgrid", palette=palette)
100
+ plt.rcParams.update(style)
101
+ _style, _palette = style, palette
102
+
103
+
78
104
  def set_theme(name: str) -> None:
79
- """Apply a seaborn palette or decktile style by name.
105
+ """Apply a seaborn palette or decktile style by name or theme file.
80
106
 
81
- Resolution order: decktile style module > CSS theme file > palette name.
107
+ Resolution order: ``.toml`` theme file > decktile style module > CSS theme
108
+ file > palette name.
82
109
  """
83
110
  global _palette, _style
84
111
  if not name:
85
112
  name = _DEFAULT_PALETTE
113
+ if name.endswith(".toml"):
114
+ path = Path(name)
115
+ if not path.is_file():
116
+ raise FileNotFoundError(f"seaborn theme file not found: {path}")
117
+ try:
118
+ _apply(_file_theme(path))
119
+ except ImportError:
120
+ _palette, _style = None, None
121
+ return
86
122
  try:
87
123
  # 1) style module (for custom overrides CSS can't express)
88
124
  mod = importlib.import_module(f"decktile.seaborn_styles.{name}")
89
125
  style = dict(getattr(mod, "STYLE", {}))
90
126
  if style:
91
- import matplotlib
92
-
93
- matplotlib.use("Agg")
94
- import matplotlib.pyplot as plt
95
- import seaborn as sns
96
-
97
- palette = style.pop("seaborn_palette", _DEFAULT_PALETTE)
98
- sns.set_theme(style="darkgrid", palette=palette)
99
- plt.rcParams.update(style)
100
- _style = style
101
- _palette = palette
127
+ _apply(style)
102
128
  return
103
129
  except ImportError:
104
130
  pass
@@ -0,0 +1,33 @@
1
+ # SPDX-FileCopyrightText: 2026 Reza Jelveh
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ """Seaborn/matplotlib style matching the HAMi diagrams (predictygraph theme ``hami``).
6
+
7
+ HAMi green #16a34a, blue #2563eb, text #1e293b, muted #64748b, border #cbd5e1.
8
+ """
9
+
10
+ PALETTE = [
11
+ "#16a34a", # HAMi green
12
+ "#2563eb", # blue
13
+ "#0891b2", # cyan
14
+ "#ca8a04", # yellow
15
+ "#7c3aed", # purple
16
+ "#dc2626", # red
17
+ ]
18
+
19
+ STYLE = {
20
+ "seaborn_palette": PALETTE,
21
+ "font.family": "sans-serif",
22
+ "font.sans-serif": ["Source Sans 3", "Source Sans Pro", "Arial", "Helvetica", "Liberation Sans", "sans-serif"],
23
+ "axes.facecolor": "#ffffff",
24
+ "axes.edgecolor": "#cbd5e1",
25
+ "axes.labelcolor": "#1e293b",
26
+ "axes.titlecolor": "#1e293b",
27
+ "text.color": "#1e293b",
28
+ "figure.facecolor": "#ffffff",
29
+ "xtick.color": "#64748b",
30
+ "ytick.color": "#64748b",
31
+ "grid.color": "#f1f5f9",
32
+ "patch.edgecolor": "#16a34a",
33
+ }
@@ -140,3 +140,28 @@ class TestStyleModulePalette:
140
140
  set_theme("ossummit_europe")
141
141
  svg = render_seaborn_svg(self.BAR)
142
142
  assert "#e05845" in svg.lower()
143
+
144
+
145
+ class TestHamiAndFileThemes:
146
+ def test_hami_module(self):
147
+ from decktile.seaborn_styles.hami import STYLE
148
+
149
+ assert STYLE["seaborn_palette"][0] == "#16a34a"
150
+
151
+ def test_toml_theme_file(self, tmp_path):
152
+ import pytest
153
+
154
+ pytest.importorskip("seaborn")
155
+ import decktile.render.seaborn as sb
156
+
157
+ f = tmp_path / "brand.toml"
158
+ f.write_text('palette = ["#112233", "#445566"]\n[style]\n"text.color" = "#010203"\n')
159
+ sb.set_theme(str(f))
160
+ assert sb._palette == ["#112233", "#445566"]
161
+ assert sb._style["text.color"] == "#010203"
162
+
163
+ def test_missing_toml_theme_file(self, tmp_path):
164
+ import pytest
165
+
166
+ with pytest.raises(FileNotFoundError):
167
+ set_theme(str(tmp_path / "nope.toml"))
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes