Skip to content

Commit

Permalink
feat(sdds-acore/theme-builder): Json theme decoding was fixed. Unused…
Browse files Browse the repository at this point in the history
… attrs were removed from playground:theme-builder.
  • Loading branch information
malilex committed Mar 28, 2024
1 parent 5977746 commit 822bb47
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
5 changes: 5 additions & 0 deletions playground/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ buildscript {
}

dependencies {
configurations.all {
resolutionStrategy {
force(libs.base.kotlin.serialization.json)
}
}
classpath(libs.base.gradle.android)
classpath(libs.base.gradle.kotlin)
classpath(libs.base.gradle.detekt)
Expand Down
6 changes: 0 additions & 6 deletions playground/theme-builder/src/main/res/values/attrs.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.sdds.plugin.themebuilder.internal.token.Theme
import com.sdds.plugin.themebuilder.internal.token.TypographyToken
import com.sdds.plugin.themebuilder.internal.utils.ResourceReferenceProvider
import com.sdds.plugin.themebuilder.internal.utils.unsafeLazy
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.decodeFromStream
import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
Expand Down Expand Up @@ -112,10 +112,8 @@ abstract class GenerateThemeTask : DefaultTask() {
dimensGenerator.generate()
}

private fun decodeTheme(): Theme {
val readFile = themeFile.get().asFile.readText()
val theme = Serializer.instance.decodeFromString<Theme>(readFile)
logger.debug("decoded theme $theme")
return theme
}
private fun decodeTheme(): Theme =
themeFile.get().asFile.inputStream().use { stream ->
Serializer.instance.decodeFromStream<Theme>(stream)
}.also { logger.debug("decoded theme $it") }
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ internal class KtFileBuilder(
}

/**
* Добавляет kotlin свойство с именем [name], типом [typeName] и инициализатором [initializer]
* Добавляет kotlin свойство с именем [name], типом [typeName], инициализатором [initializer]
* и описанием (документацией) [description]
* @return [TypeSpec.Builder]
*/
fun TypeSpec.Builder.appendProperty(
Expand All @@ -50,7 +51,8 @@ internal class KtFileBuilder(
) = appendProperty(name, typeName.asTypeName(), initializer, description, this)

/**
* Добавляет kotlin свойство с именем [name], типом [typeName] и инициализатором [initializer]
* Добавляет kotlin свойство с именем [name], типом [typeName], инициализатором [initializer]
* и описанием (документацией) [description]
* @return [TypeSpec.Builder]
*/
fun TypeSpec.Builder.appendProperty(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.sdds.plugin.themebuilder.internal.factory

import com.sdds.plugin.themebuilder.internal.builder.KtFileBuilder
import com.sdds.plugin.themebuilder.internal.builder.XmlDocumentBuilder

/**
* Фабрика для [XmlDocumentBuilder]
* Фабрика для [KtFileBuilder]
* @param packageName название пакета, куда будет сохранен файл
* @author Малышев Александр on 07.03.2024
*/
Expand All @@ -13,7 +12,7 @@ internal class KtFileBuilderFactory(
) {

/**
* Создает [XmlDocumentBuilder]
* Создает [KtFileBuilder]
*/
fun create(fileName: String): KtFileBuilder = KtFileBuilder(packageName, fileName)
}

0 comments on commit 822bb47

Please sign in to comment.