Commit 7fa7957
authored
feat(template): add customizable code generation template system (#249)
* docs(templates): document template system and color mapping in ARCHITECTURE.md
* feat(template): add core template engine with lexer, resolver, and config parser
* feat(gradle-plugin): add templateFile option and functional tests
* chore: bump version and add template integrity check CI
* docs: add template system to CLI, Gradle plugin READMEs, and help output
* feat(playground): add template editor with validation, autocomplete, and persistence
* docs(website): add template system documentation page
* chore: remove conditional check for nodeJS environment setup in pull request workflow
* fix(ci): use explicit bash invocation and numeric comparison in template script
- Invoke template-script.sh via `bash` for portability when executable permissions aren't preserved.
- Use `-eq` instead of `==` for numeric array-length comparison.
* fix(template): consume entire malformed placeholder span as literal in lexer
When tryParsePlaceholder returns null for a `${...}` sequence, consume the entire span up to the closing `}` as literal text instead of just the `$` character. This prevents inner content from being re-interpreted as nested placeholders.
* fix(template): fall through to default preview when template key is null
- When [templates.preview] exists but the template key is null (e.g. empty section), fall through to default preview behavior instead of suppressing preview generation.
- Refactor buildPreview to use a when expression.
* fix(template): use template-aware emission for group fallback and chunk functions
- Extract emitGroupHeader from ImageVectorNodeEmitter so the fallback path in TemplateNodeEmitter still recurses children template-aware.
- Make splitTopLevelParams and findMatchingCloseParen respect string literals, angle brackets, braces, and brackets via a shared NestingTracker.
* fix(template): include fileHeader in definition key validation
Add config.templates.fileHeader to allTemplateTexts so that ${def:...} references in file headers are validated against defined import keys.
* docs: fix templateFile() behavior inconsistencies and chunk:index comment
- Align docs, website, and playground on consistent templateFile() behavior: omitting it in Gradle disables auto-discovery; use common config for inheritance.
- Fix method signature to templateFile(path: RegularFile).
Correct chunk:index comment from 0-based to 1-based.
* fix(template): enhance flag parsing and default differ handling in script
* refactor(ci): use flag-based args and add --default-differ to integrity scripts
Refactor both integrity check scripts to parse flags via a while/case
loop instead of positional arguments. Add --default-differ flag to skip
delta and use plain diff for machine-readable output.
* feat(template): add emitClipPathData function and integrate clip path handling in group parameters
* feat(template): add iconGroup function for enhanced group handling in ImageVector
* feat(template): replace group with iconGroup for improved clip path handling in SVG templates
* fix: bad rebase state
* feat(navigation): implement WebRoute structure for improved routing management
* feat(website): add CodeAwareSpanText component with callout variants
Replaces RichSpanText with a more descriptive name. Renders text that
may contain inline code segments using backtick syntax. Adds typed
CssStyleVariant support with per-CalloutVariant variants (Tip, Warning,
Important) for proper InlineCode colour theming inside callouts.
* refactor(website): convert docs to CodeAwareSpanText and fix Canadian English
Replace Span { Text() InlineCode() } patterns across all five docs
files with CodeAwareSpanText using backtick syntax. Callout blocks
now use typed variants instead of manually resolving InlineCodeVars.
Fix US English spellings in copy text: color to colour in section
titles, descriptions, and variable labels. Code identifiers (Color,
SolidColor, color_mapping) are left unchanged.
* docs(website): add KDoc to WebRoute and CodeAwareSpanText
Add KDoc to WebRoute class, its properties, and companion entries.
Add KDoc to CodeAwareSpanText composable, ComponentKind marker, and
all three callout style variants.
* fix(website): correct CodeAwareSpanText parsing when text starts with backtick
The previous logic dropped leading empty parts and reset the index,
which inverted the even/odd check and rendered code as text and vice
versa. Now iterates all parts using the original split index and
skips empty segments instead.
* fix(website): replace "elision/elides" with "trimming/trims" in copy and tests
Update ToC entry in Templates.kt and test names in
PlaceholderResolverTest.kt to use "trim" instead of "elide".
* refactor(website): convert remaining InlineCode patterns to CodeAwareSpanText
Convert TemplateSystemCallout in CliDocsContent and --max-workers Li
in GradlePluginDocsContent to use CodeAwareSpanText with backtick
syntax. Remove now-unused resolveInlineCodeColors from DocsStyles.
* fix(website): use Canadian English spelling for "customise/customisation"
Replace all US English "customize/customization/customizing" with
"customise/customisation/customising" in website copy across docs,
playground, and landing page.
* refactor(website): replace SpanText with CodeAwareSpanText and update filename casing in documentation
* fix: address code review findings across script, tests, and website
- fix(ci): clean up cli-integrity-check script parameter parsing, remove
vestigial $2 assignment, add --extension required validation, fix
suffix not being set to "optimized" when --optimize flag is passed,
use POSIX = for string comparisons and -eq for numeric comparisons
- fix(gradle-plugin): replace auto-bootstrap with assertion failure for
missing template golden files in functional tests
- fix(website): remove trailing spaces after line-continuation
backslashes in FaqContent shell code block
- fix(website): expand icon namespace scope to include file_header and
preview contexts in TemplateDocsContent
- fix(website): remove editorial inline comment from null-handling
code example in TemplateDocsContent
- fix(website): correct contradictory auto-discovery guidance in
TemplateDocsContent - omitting templateFile() inherits common config
- refactor(website): use lazy delegate for WebRoute.all property
* feat: integrate template configuration support in Processor
* feat: add template option for customizable Kotlin code generation
* feat: add option to disable template auto-discovery in Kotlin code generation1 parent 1d3512a commit 7fa7957
File tree
128 files changed
+14630
-2087
lines changed- .github
- actions
- cli-integrity-check
- template-integrity-check
- workflows
- buildSrc/src/main/kotlin/dev/tonholo/s2c/conventions/kmp/targets
- config
- docs
- gradle
- integrity-check/expected/template
- kotlin-js-store
- playground
- app
- samples/template
- src/main/kotlin/dev/tonholo/svg_to_compose/playground/ui/icon/template
- svg-to-compose-gradle-plugin
- src
- functionalTest/kotlin/dev/tonholo/s2c/gradle
- main/kotlin/dev/tonholo/s2c/gradle
- dsl/parser
- internal/parser
- tasks
- worker
- svg-to-compose
- src
- commonMain/kotlin/dev/tonholo/s2c
- emitter
- imagevector
- template
- config
- lexer
- resolver
- error
- parser
- config
- method
- commonTest/kotlin/dev/tonholo/s2c/emitter
- template
- config
- lexer
- resolver
- nativeMain/kotlin
- website
- editor-wasm
- site
- src/jsMain/kotlin/dev/tonholo/s2c/website
- components
- layouts
- molecules
- playground
- organisms
- docs
- playground
- template
- domain/model/playground/template
- pages/docs
- shiki
- state/playground
- reducer
- theme
- validator/playground/template
- worker
- src/jsMain/kotlin/dev/tonholo/s2c/website/worker
- inject
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
128 files changed
+14630
-2087
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
10 | 39 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
17 | 43 | | |
18 | 44 | | |
19 | 45 | | |
20 | | - | |
| 46 | + | |
21 | 47 | | |
22 | 48 | | |
23 | 49 | | |
24 | 50 | | |
25 | 51 | | |
26 | 52 | | |
27 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
28 | 57 | | |
29 | 58 | | |
30 | 59 | | |
| |||
34 | 63 | | |
35 | 64 | | |
36 | 65 | | |
37 | | - | |
38 | | - | |
| 66 | + | |
| 67 | + | |
39 | 68 | | |
40 | | - | |
| 69 | + | |
41 | 70 | | |
42 | 71 | | |
43 | 72 | | |
| |||
47 | 76 | | |
48 | 77 | | |
49 | 78 | | |
50 | | - | |
51 | | - | |
| 79 | + | |
| 80 | + | |
52 | 81 | | |
53 | 82 | | |
54 | 83 | | |
| |||
64 | 93 | | |
65 | 94 | | |
66 | 95 | | |
67 | | - | |
| 96 | + | |
68 | 97 | | |
69 | 98 | | |
70 | 99 | | |
| |||
96 | 125 | | |
97 | 126 | | |
98 | 127 | | |
99 | | - | |
| 128 | + | |
100 | 129 | | |
101 | 130 | | |
102 | 131 | | |
| |||
106 | 135 | | |
107 | 136 | | |
108 | 137 | | |
109 | | - | |
| 138 | + | |
110 | 139 | | |
111 | 140 | | |
112 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
0 commit comments