Skip to content

Commit b9b5e9e

Browse files
committed
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.
1 parent 00d8b78 commit b9b5e9e

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

docs/TEMPLATES.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ When no explicit template path is given, the tool walks up from the output
342342
directory looking for `s2c.template.toml`. This matches the behavior of
343343
`.editorconfig` discovery.
344344

345-
Disable auto-discovery with `--no-template` (CLI) or by omitting
346-
`templateFile()` from the Gradle DSL.
345+
Disable auto-discovery with `--no-template` (CLI). In the Gradle DSL,
346+
omitting `templateFile()` disables auto-discovery for that configuration;
347+
set `templateFile()` in `common` to share a template across all
348+
configurations via inheritance.
347349

348350
## Gradle Plugin: Per-Configuration Templates
349351

@@ -375,7 +377,7 @@ svgToCompose {
375377
destinationPackage("com.example.icons.filled")
376378
icons {
377379
theme("com.example.theme.AppTheme")
378-
// No templateFile() inherits from common or auto-discovery
380+
// No templateFile() -> inherits from common config
379381
}
380382
}
381383
}

playground/s2c.template.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ path_builder = "${def:icon_path}(fill = ${path:fill}, fillAlpha = ${path:fill_al
5757
group_builder = "group(rotate = ${group:rotate}, pivotX = ${group:pivot_x}, pivotY = ${group:pivot_y})"
5858
# chunk_function_name / chunk_function_definition: customize how large icons
5959
# are split into helper functions. ${icon:name} is camelCase, ${chunk:index}
60-
# is the 0-based chunk number, ${chunk:name} is the resolved function name,
60+
# is the 1-based chunk number, ${chunk:name} is the resolved function name,
6161
# and ${chunk:body} is the emitted node code for the chunk.
6262
chunk_function_name = "${icon:name}Part${chunk:index}"
6363
chunk_function_definition = "private fun ImageVector.Builder.${chunk:name}() {\n${chunk:body}\n}"

website/site/src/jsMain/kotlin/dev/tonholo/s2c/website/components/organisms/docs/GradlePluginDocsContent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ private fun IconParserConfigurationSubsection() {
365365
description = "Persist generated files to the source directory (delicate API)",
366366
)
367367
OptionItem(
368-
name = "templateFile(RegularFileProperty)",
368+
name = "templateFile(path: RegularFile)",
369369
description = "Path to an s2c.template.toml file for customizing generated code",
370370
)
371371
}

website/site/src/jsMain/kotlin/dev/tonholo/s2c/website/components/organisms/docs/TemplateDocsContent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private val gradlePerConfigExample = """
202202
| destinationPackage("com.example.icons.filled")
203203
| icons {
204204
| theme("com.example.theme.AppTheme")
205-
| // No templateFile() -> inherits from common or auto-discovery
205+
| // No templateFile() -> inherits from common config
206206
| }
207207
| }
208208
| }

website/site/src/jsMain/kotlin/dev/tonholo/s2c/website/state/playground/TemplateTomlExtensions.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ internal fun String.isTemplateStructuralOnly(): Boolean {
1818
* Returns the TOML string only when it contains real configuration
1919
* beyond section headers and comments (the default placeholder).
2020
*/
21-
internal fun String.takeIfUsableTemplate(): String? =
22-
if (isTemplateStructuralOnly()) null else this
21+
internal fun String.takeIfUsableTemplate(): String? = if (isTemplateStructuralOnly()) null else this

0 commit comments

Comments
 (0)